-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathpy-minsymbol.exp
More file actions
62 lines (51 loc) · 3.14 KB
/
py-minsymbol.exp
File metadata and controls
62 lines (51 loc) · 3.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# Copyright (C) 2010-2015 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# This file is part of the GDB testsuite. It tests the mechanism
# exposing values to Python.
load_lib gdb-python.exp
standard_testfile
if {[prepare_for_testing $testfile.exp $testfile $srcfile debug]} {
return -1
}
# Skip all tests if Python scripting is not enabled.
if { [skip_python_tests] } { continue }
# Test looking up missing value
gdb_test "python print (gdb.lookup_minimal_symbol('xyz'))" "None" "lookup missing symbol"
# Test looking up a minimal symbol of text type
gdb_test "print text_msym" " = \{<text variable, no debug info>\} 0x\[0-9a-f\]* <text_msym>" "locate text_msym with print"
gdb_py_test_silent_cmd "python x = gdb.lookup_minimal_symbol('text_msym')" "Lookup text_msym" 1
gdb_test "python print (x)" "text_msym" "lookup text min sym"
gdb_test "python print (x.name)" "text_msym" "get text minsym name"
gdb_test "python print (x.linkage_name)" "text_msym" "get text minsym linkage_name"
# Using asm() ends up inventing a compiler-dependent filename
gdb_test "python print (x.filename)" ".*" "get text minsym filename"
gdb_test "python print (x.print_name)" "text_msym" "get text minsym print_name"
gdb_test "python print (x.section)" ".text" "get text minsym section"
gdb_test "python print (x.value())" "0x\[0-9a-f\]*.*" "get text minsym value"
gdb_test "python print (x.value().type)" "void \\(\\*\\)\\(\\)" "get text minsym value type"
# Test looking up a minimal symbol of data type
gdb_test "print (void *)data_msym" "0x\[0-9a-f\]*.*" "locate data_msym with print"
gdb_py_test_silent_cmd "python x = gdb.lookup_minimal_symbol('data_msym')" "Lookup data_msym" 1
gdb_test "python print (x.name)" "data_msym" "get data minsym name"
gdb_test "python print (x.linkage_name)" "data_msym" "get data minsym linkage_name"
# Using asm() ends up inventing a compiler-dependent filename
gdb_test "python print (x.filename)" ".*" "get data minsym filename"
gdb_test "python print (x.print_name)" "data_msym" "get data minsym print_name"
gdb_test "python print (x.section)" ".data" "get data minsym section"
gdb_test "python print (x.value())" "0x\[0-9a-f\]*.*" "get data minsym value"
gdb_test "python print(gdb.lookup_minimal_symbol('data_msym2', 'foobar.c'))" "None" "Lookup data_msym2 in foobar.c src"
gdb_test "python print(gdb.lookup_minimal_symbol('data_msym2', 'py-minsymbol.c'))" "data_msym2" "Lookup data_msym2 in py-minsymbol.c src"
gdb_unload
gdb_test "python print (x.is_valid())" "False" "Test symbol non-validity"
gdb_test_no_output "python a = None" "Test symbol destructor"