dwarf_lang_to_enum_language: Map new DWARF5 constants
[binutils-gdb.git] / gdb / testsuite / gdb.python / py-shared.exp
blob9be5aa467e299fd95c791245bb911f28314a069d
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
22 standard_testfile
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"
30 return -1
33 set exec_opts [list debug shlib=${library}]
35 if { [gdb_compile ${srcdir}/${subdir}/${srcfile} ${binfile} executable $exec_opts] != "" } {
36 untested "failed to compile"
37 return -1
40 # Start with a fresh gdb.
41 clean_restart $testfile
42 gdb_load_shlib ${library}
44 # The following tests require execution.
46 if {![runto_main]} {
47 return 0
50 runto [gdb_get_line_number "Break to end."]
52 # Test gdb.solib_name
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))" \
69 [multi_line \
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))" \
74 [multi_line \
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\"))" \
79 [multi_line \
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'"]