1 # Copyright 2019-2021 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 if {[skip_shlib_tests]} {
22 if { [skip_ada_tests] } { return -1 }
24 standard_ada_testfile foo
26 set srcfile2 [file join [file dirname $srcfile] some_package.adb]
27 set sofile [standard_output_file libsome_package.so]
29 set outdir [file dirname $binfile]
31 # Create the shared library.
32 if {[gdb_compile_shlib $srcfile2 $sofile {ada debug}] != ""} {
36 # Set linkarg such that the executable can find the shared library.
37 if {[istarget "*-*-mingw*"]
38 || [istarget *-*-cygwin*]
40 || [istarget arm*-*-symbianelf*]} {
41 # Do not need anything.
43 } elseif {[istarget *-*-freebsd*] || [istarget *-*-openbsd*]} {
44 set linkarg "-Wl,-rpath,$outdir"
46 set linkarg "-Wl,-rpath,\\\$ORIGIN"
49 # Make sure we link against the shared GNAT run time.
50 set gnatbind_options [list -bargs -shared -margs]
52 # Link against the shared library.
53 set gnatlink_options [list -largs $linkarg -Wl,-lsome_package -margs]
55 set options [list debug]
56 foreach option [concat $gnatbind_options $gnatlink_options] {
57 lappend options [concat "additional_flags=" $option]
61 if {[gdb_compile_ada $srcfile $binfile executable $options] != ""} {
65 clean_restart ${testfile}
67 if {![runto_main]} then {
71 set can_catch_exceptions 0
72 gdb_test_multiple "catch exception some_kind_of_error" "" {
73 -re "Catchpoint \[0-9\]+: `some_kind_of_error' Ada exception\r\n$gdb_prompt $" {
75 set can_catch_exceptions 1
78 -re "Your Ada runtime appears to be missing some debugging information.\r\nCannot insert Ada exception catchpoint in this configuration.\r\n$gdb_prompt $" {
79 unsupported $gdb_test_name
83 if { $can_catch_exceptions } {
85 "Catchpoint \[0-9\]+, .* at .*foo\.adb:\[0-9\]+.*" \
86 "caught the exception"
88 gdb_test "print \$_ada_exception = some_package.some_kind_of_error'Address" \