]>
Commit | Line | Data |
---|---|---|
b811d2c2 | 1 | # Copyright (C) 2008-2020 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 | ||
e7fbb131 PA |
20 | if {[skip_shlib_tests]} { |
21 | return 0 | |
22 | } | |
23 | ||
b4a58790 TT |
24 | standard_testfile |
25 | ||
e7fbb131 PA |
26 | set libfile "py-shared-sl" |
27 | set libsrc ${libfile}.c | |
b4a58790 | 28 | set library [standard_output_file ${libfile}.sl] |
e7fbb131 PA |
29 | |
30 | if { [gdb_compile_shlib ${srcdir}/${subdir}/${libsrc} ${library} "debug"] != "" } { | |
84c93cd5 | 31 | untested "failed to compile shared library" |
e7fbb131 PA |
32 | return -1 |
33 | } | |
34 | ||
35 | set exec_opts [list debug shlib=${library}] | |
36 | ||
37 | if { [gdb_compile ${srcdir}/${subdir}/${srcfile} ${binfile} executable $exec_opts] != "" } { | |
84c93cd5 | 38 | untested "failed to compile" |
e7fbb131 PA |
39 | return -1 |
40 | } | |
41 | ||
e7fbb131 | 42 | # Start with a fresh gdb. |
b4a58790 | 43 | clean_restart $testfile |
d9019901 | 44 | gdb_load_shlib ${library} |
e7fbb131 PA |
45 | |
46 | # Skip all tests if Python scripting is not enabled. | |
47 | if { [skip_python_tests] } { continue } | |
48 | ||
49 | # The following tests require execution. | |
50 | ||
51 | if ![runto_main] then { | |
bc6c7af4 | 52 | fail "can't run to main" |
e7fbb131 PA |
53 | return 0 |
54 | } | |
55 | ||
56 | runto [gdb_get_line_number "Break to end."] | |
57 | ||
58 | # Test gdb.solib_name | |
59 | gdb_test "p &func1" "" "func1 address" | |
60 | gdb_py_test_silent_cmd "python func1 = gdb.history(0)" "Aquire func1 address" 1 | |
9325cb04 PK |
61 | if { $gdb_py_is_py3k == 1 } { |
62 | gdb_py_test_silent_cmd "python long = int" "" 0 | |
63 | } | |
64 | gdb_test "python print (gdb.solib_name(long(func1)))" "py-shared-sl.sl" "test func1 solib location" | |
e7fbb131 PA |
65 | |
66 | gdb_test "p &main" "" "main address" | |
67 | gdb_py_test_silent_cmd "python main = gdb.history(0)" "Aquire main address" 1 | |
9325cb04 | 68 | gdb_test "python print (gdb.solib_name(long(main)))" "None" "test main solib location" |
1b40ec05 TT |
69 | |
70 | if {[is_lp64_target]} { | |
71 | gdb_test "python print (len(\[gdb.solib_name(0xffffffffffffffff)\]))" "1" | |
72 | } |