1 # Copyright
(C
) 2008-2024 Free Software Foundation
, Inc.
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.
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.
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
/>.
16 # This file is part of the GDB testsuite.
18 load_lib gdb
-python.exp
20 require allow_shlib_tests allow_python_tests
24 set libfile
"py-shared-sl"
25 set libsrc $
{libfile
}.c
26 set library
[standard_output_file $
{libfile
}.sl
]
28 if { [gdb_compile_shlib $
{srcdir
}/$
{subdir
}/$
{libsrc
} $
{library
} "debug"] != "" } {
29 untested
"failed to compile shared library"
33 set exec_opts
[list debug shlib
=$
{library
}]
35 if { [gdb_compile $
{srcdir
}/$
{subdir
}/$
{srcfile
} $
{binfile
} executable $exec_opts
] != "" } {
36 untested
"failed to compile"
40 # Start with a fresh gdb.
41 clean_restart $testfile
42 gdb_load_shlib $
{library
}
44 # The following tests require execution.
50 runto
[gdb_get_line_number
"Break to end."]
53 gdb_test
"p &func1" "" "func1 address"
54 gdb_py_test_silent_cmd
"python func1 = gdb.history(0)" "Acquire func1 address" 1
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"
60 gdb_test
"p &main" "" "main address"
61 gdb_py_test_silent_cmd
"python main = gdb.history(0)" "Acquire main address" 1
62 gdb_test
"python print (gdb.solib_name(int(main)))" "None" "test main solib location"
64 if {[is_lp64_target
]} {
65 gdb_test
"python print (len(\[gdb.solib_name(0xffffffffffffffff)\]))" "1"
68 gdb_test
"python print(gdb.solib_name(-1))" \
70 "Python Exception <class 'OverflowError'>: can't convert negative int to unsigned" \
71 "Error occurred in Python: can't convert negative int to unsigned"]
73 gdb_test
"python print(gdb.current_progspace().solib_name(-1))" \
75 "Python Exception <class 'OverflowError'>: can't convert negative int to unsigned" \
76 "Error occurred in Python: can't convert negative int to unsigned"]
78 gdb_test
"python print(gdb.current_progspace().solib_name(\"string\"))" \
80 "Python Exception <class 'ValueError'>: invalid literal for int\\(\\) with base 10: 'string'" \
81 "Error occurred in Python: invalid literal for int\\(\\) with base 10: 'string'"]