1 # Copyright
2019 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
]
63 set status [remote_exec host
"$gnatbind -shared foo"]
64 if {[lindex $
status 0] == 0} {
72 if {[istarget
"*-*-mingw*"]
73 ||
[istarget
*-*-cygwin
*]
75 ||
[istarget arm
*-*-symbianelf
*]} {
76 #
Do not need anything.
78 } elseif
{[istarget
*-*-freebsd
*] ||
[istarget
*-*-openbsd
*]} {
79 set linkarg
"-Wl,-rpath,$outdir"
81 set linkarg
"-Wl,-rpath,\\\$ORIGIN"
83 set status [remote_exec host
"$gnatlink foo $linkarg -Wl,-lsome_package"]
84 if {[lindex $
status 0] == 0} {
92 clean_restart $
{testfile
}
94 if {![runto_main
]} then {
98 gdb_test
"catch exception some_kind_of_error" \
99 "Catchpoint \[0-9\]+: `some_kind_of_error' Ada exception"
102 "Catchpoint \[0-9\]+, .* at .*foo\.adb:\[0-9\]+.*" \
103 "caught the exception"