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 if { [skip_ada_tests] } { return -1 }
24 standard_ada_testfile foo
26 set ofile ${binfile}.o
28 set srcfile2 [file join [file dirname $srcfile] some_package.adb]
29 set ofile2 [standard_output_file some_package.o]
30 set sofile [standard_output_file libsome_package.so]
32 set outdir [file dirname $binfile]
34 # To make an Ada shared library we have to jump through a number of
37 # First compile to a .o. We can't compile directly to a .so because
39 # $ gcc -g -shared -fPIC -o qqz.o some_package.adb
40 # gcc: error: -c or -S required for Ada
41 # And, we can't compile in "ada" mode because dejagnu will try to
42 # invoke gnatmake, which we don't want.
43 if {[target_compile_ada_from_dir $outdir $srcfile2 $ofile2 \
44 object {debug additional_flags=-fPIC}] != ""} {
48 # Now turn the .o into a shared library.
49 if {[gdb_compile_shlib $ofile2 $sofile \
50 {debug additional_flags=-fPIC}] != ""} {
54 # Now we can compile the main program to an object file; but again, we
55 # can't compile directly using gnatmake.
56 if {[target_compile_ada_from_dir $outdir $srcfile $ofile object debug] != ""} {
60 set gnatbind [find_ada_tool gnatbind]
61 set gnatlink [find_ada_tool gnatlink]
64 # Test if gnatbind is supported
65 set status [remote_exec host "$gnatbind --version"]
66 if {[lindex $status 0] == -1} {
67 unsupported "gnatbind foo"
71 set status [remote_exec host "$gnatbind -shared foo"]
72 if {[lindex $status 0] == 0} {
79 # Test if gnatlink is supported
80 set status [remote_exec host "$gnatlink --version"]
81 if {[lindex $status 0] == -1} {
82 unsupported "gnatlink foo"
86 if {[istarget "*-*-mingw*"]
87 || [istarget *-*-cygwin*]
89 || [istarget arm*-*-symbianelf*]} {
90 # Do not need anything.
92 } elseif {[istarget *-*-freebsd*] || [istarget *-*-openbsd*]} {
93 set linkarg "-Wl,-rpath,$outdir"
95 set linkarg "-Wl,-rpath,\\\$ORIGIN"
97 set status [remote_exec host "$gnatlink foo $linkarg -Wl,-lsome_package"]
98 if {[lindex $status 0] == 0} {
106 clean_restart ${testfile}
108 if {![runto_main]} then {
112 set can_catch_exceptions 0
113 gdb_test_multiple "catch exception some_kind_of_error" "" {
114 -re "Catchpoint \[0-9\]+: `some_kind_of_error' Ada exception\r\n$gdb_prompt $" {
116 set can_catch_exceptions 1
119 -re "Your Ada runtime appears to be missing some debugging information.\r\nCannot insert Ada exception catchpoint in this configuration.\r\n$gdb_prompt $" {
120 unsupported $gdb_test_name
124 if { $can_catch_exceptions } {
126 "Catchpoint \[0-9\]+, .* at .*foo\.adb:\[0-9\]+.*" \
127 "caught the exception"
129 gdb_test "print \$_ada_exception = some_package.some_kind_of_error'Address" \