1 # Copyright 2019-2020 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 standard_ada_testfile foo
24 set ofile ${binfile}.o
26 set srcfile2 [file join [file dirname $srcfile] some_package.adb]
27 set ofile2 [standard_output_file some_package.o]
28 set sofile [standard_output_file libsome_package.so]
30 set outdir [file dirname $binfile]
32 # To make an Ada shared library we have to jump through a number of
35 # First compile to a .o. We can't compile directly to a .so because
37 # $ gcc -g -shared -fPIC -o qqz.o some_package.adb
38 # gcc: error: -c or -S required for Ada
39 # And, we can't compile in "ada" mode because dejagnu will try to
40 # invoke gnatmake, which we don't want.
41 if {[target_compile_ada_from_dir $outdir $srcfile2 $ofile2 \
42 object {debug additional_flags=-fPIC}] != ""} {
46 # Now turn the .o into a shared library.
47 if {[gdb_compile_shlib $ofile2 $sofile \
48 {debug additional_flags=-fPIC}] != ""} {
52 # Now we can compile the main program to an object file; but again, we
53 # can't compile directly using gnatmake.
54 if {[target_compile_ada_from_dir $outdir $srcfile $ofile object debug] != ""} {
58 set gnatbind [find_ada_tool gnatbind]
59 set gnatlink [find_ada_tool gnatlink]
62 # Test if gnatbind is supported
63 set status [remote_exec host "$gnatbind --version"]
64 if {[lindex $status 0] == -1} {
65 unsupported "gnatbind foo"
69 set status [remote_exec host "$gnatbind -shared foo"]
70 if {[lindex $status 0] == 0} {
77 # Test if gnatlink is supported
78 set status [remote_exec host "$gnatlink --version"]
79 if {[lindex $status 0] == -1} {
80 unsupported "gnatlink foo"
84 if {[istarget "*-*-mingw*"]
85 || [istarget *-*-cygwin*]
87 || [istarget arm*-*-symbianelf*]} {
88 # Do not need anything.
90 } elseif {[istarget *-*-freebsd*] || [istarget *-*-openbsd*]} {
91 set linkarg "-Wl,-rpath,$outdir"
93 set linkarg "-Wl,-rpath,\\\$ORIGIN"
95 set status [remote_exec host "$gnatlink foo $linkarg -Wl,-lsome_package"]
96 if {[lindex $status 0] == 0} {
104 clean_restart ${testfile}
106 if {![runto_main]} then {
110 set can_catch_exceptions 0
111 gdb_test_multiple "catch exception some_kind_of_error" "" {
112 -re "Catchpoint \[0-9\]+: `some_kind_of_error' Ada exception\r\n$gdb_prompt $" {
114 set can_catch_exceptions 1
117 -re "Your Ada runtime appears to be missing some debugging information.\r\nCannot insert Ada exception catchpoint in this configuration.\r\n$gdb_prompt $" {
118 unsupported $gdb_test_name
122 if { $can_catch_exceptions } {
124 "Catchpoint \[0-9\]+, .* at .*foo\.adb:\[0-9\]+.*" \
125 "caught the exception"
127 gdb_test "print \$_ada_exception = some_package.some_kind_of_error'Address" \