]>
Commit | Line | Data |
---|---|---|
1d506c26 | 1 | # Copyright (C) 2008-2024 Free Software Foundation, Inc. |
e7fbb131 PA |
2 | |
3 | # This program is free software; you can redistribute it and/or modify | |
4 | # it under the terms of the GNU General Public License as published by | |
5 | # the Free Software Foundation; either version 3 of the License, or | |
6 | # (at your option) any later version. | |
7 | # | |
8 | # This program is distributed in the hope that it will be useful, | |
9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 | # GNU General Public License for more details. | |
12 | # | |
13 | # You should have received a copy of the GNU General Public License | |
14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
15 | ||
16 | # This file is part of the GDB testsuite. | |
17 | ||
a2c09bd0 DE |
18 | load_lib gdb-python.exp |
19 | ||
d6195dc9 | 20 | require allow_shlib_tests allow_python_tests |
e7fbb131 | 21 | |
b4a58790 TT |
22 | standard_testfile |
23 | ||
e7fbb131 PA |
24 | set libfile "py-shared-sl" |
25 | set libsrc ${libfile}.c | |
b4a58790 | 26 | set library [standard_output_file ${libfile}.sl] |
e7fbb131 PA |
27 | |
28 | if { [gdb_compile_shlib ${srcdir}/${subdir}/${libsrc} ${library} "debug"] != "" } { | |
84c93cd5 | 29 | untested "failed to compile shared library" |
e7fbb131 PA |
30 | return -1 |
31 | } | |
32 | ||
33 | set exec_opts [list debug shlib=${library}] | |
34 | ||
35 | if { [gdb_compile ${srcdir}/${subdir}/${srcfile} ${binfile} executable $exec_opts] != "" } { | |
84c93cd5 | 36 | untested "failed to compile" |
e7fbb131 PA |
37 | return -1 |
38 | } | |
39 | ||
e7fbb131 | 40 | # Start with a fresh gdb. |
b4a58790 | 41 | clean_restart $testfile |
d9019901 | 42 | gdb_load_shlib ${library} |
e7fbb131 | 43 | |
e7fbb131 PA |
44 | # The following tests require execution. |
45 | ||
b0e16ca5 | 46 | if {![runto_main]} { |
e7fbb131 PA |
47 | return 0 |
48 | } | |
49 | ||
50 | runto [gdb_get_line_number "Break to end."] | |
51 | ||
52 | # Test gdb.solib_name | |
53 | gdb_test "p &func1" "" "func1 address" | |
33b5899f | 54 | gdb_py_test_silent_cmd "python func1 = gdb.history(0)" "Acquire func1 address" 1 |
d19ca0b3 TT |
55 | gdb_test "python print (gdb.solib_name(int(func1)))" "py-shared-sl.sl" \ |
56 | "test func1 solib location" | |
57 | gdb_test "python print (gdb.solib_name(func1))" "py-shared-sl.sl" \ | |
58 | "test func1 solib location using Value" | |
e7fbb131 PA |
59 | |
60 | gdb_test "p &main" "" "main address" | |
33b5899f | 61 | gdb_py_test_silent_cmd "python main = gdb.history(0)" "Acquire main address" 1 |
edae3fd6 | 62 | gdb_test "python print (gdb.solib_name(int(main)))" "None" "test main solib location" |
1b40ec05 TT |
63 | |
64 | if {[is_lp64_target]} { | |
65 | gdb_test "python print (len(\[gdb.solib_name(0xffffffffffffffff)\]))" "1" | |
66 | } |