1 # Copyright 2019-2024 Free Software Foundation, Inc. 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 require allow_shlib_tests 17 18 load_lib "ada.exp" 19 20 require allow_ada_tests shared_gnat_runtime_has_debug_info 21 22 standard_ada_testfile foo 23 24 set srcfile2 [file join [file dirname $srcfile] some_package.adb] 25 set sofile [standard_output_file libsome_package.so] 26 27 set outdir [file dirname $binfile] 28 29 # Create the shared library. 30 if {[gdb_compile_shlib $srcfile2 $sofile {ada debug}] != ""} { 31 return -1 32 } 33 34 # Set linkarg such that the executable can find the shared library. 35 if {[istarget "*-*-mingw*"] 36 || [istarget *-*-cygwin*] 37 || [istarget *-*-pe*]} { 38 # Do not need anything. 39 set linkarg "" 40 } elseif {[istarget *-*-freebsd*] || [istarget *-*-openbsd*]} { 41 set linkarg "-Wl,-rpath,$outdir" 42 } else { 43 set linkarg "-Wl,-rpath,\\\$ORIGIN" 44 } 45 46 # Make sure we link against the shared GNAT run time. 47 set gnatbind_options [list -bargs -shared -margs] 48 49 # Link against the shared library. 50 set gnatlink_options [list -largs $linkarg -Wl,-lsome_package -margs] 51 52 set options [list debug] 53 foreach option [concat $gnatbind_options $gnatlink_options] { 54 lappend options [concat "additional_flags=" $option] 55 } 56 57 # Create executable. 58 if {[gdb_compile_ada $srcfile $binfile executable $options] != ""} { 59 return -1 60 } 61 62 clean_restart ${testfile} 63 64 # Do whatever is necessary to make sure that the shared library is 65 # loaded for remote targets. 66 gdb_load_shlib $sofile 67 68 if {![runto_main]} { 69 return 0 70 } 71 72 gdb_test "catch exception some_kind_of_error" \ 73 "Catchpoint \[0-9\]+: `some_kind_of_error' Ada exception" 74 75 gdb_test "cont" \ 76 "Catchpoint \[0-9\]+, .* at .*foo\.adb:\[0-9\]+.*" \ 77 "caught the exception" 78 79 gdb_test "print \$_ada_exception = some_package.some_kind_of_error'Address" \ 80 " = true" 81