gdb: make get_dyn_prop a method of struct type
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.ada / catch_ex_std.exp
1 # Copyright 2019-2020 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 if {[skip_shlib_tests]} {
17 return 0
18 }
19
20 load_lib "ada.exp"
21
22 standard_ada_testfile foo
23
24 set ofile ${binfile}.o
25
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]
29
30 set outdir [file dirname $binfile]
31
32 # To make an Ada shared library we have to jump through a number of
33 # hoops.
34
35 # First compile to a .o. We can't compile directly to a .so because
36 # GCC rejects that:
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}] != ""} {
43 return -1
44 }
45
46 # Now turn the .o into a shared library.
47 if {[gdb_compile_shlib $ofile2 $sofile \
48 {debug additional_flags=-fPIC}] != ""} {
49 return -1
50 }
51
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] != ""} {
55 return -1
56 }
57
58 set gnatbind [find_ada_tool gnatbind]
59 set gnatlink [find_ada_tool gnatlink]
60
61 with_cwd $outdir {
62 # Test if gnatbind is supported
63 set status [remote_exec host "$gnatbind --version"]
64 if {[lindex $status 0] == -1} {
65 unsupported "gnatbind foo"
66 return -1
67 }
68 # Bind.
69 set status [remote_exec host "$gnatbind -shared foo"]
70 if {[lindex $status 0] == 0} {
71 pass "gnatbind foo"
72 } else {
73 fail "gnatbind foo"
74 return -1
75 }
76
77 # Test if gnatlink is supported
78 set status [remote_exec host "$gnatlink --version"]
79 if {[lindex $status 0] == -1} {
80 unsupported "gnatlink foo"
81 return -1
82 }
83 # Finally, link.
84 if {[istarget "*-*-mingw*"]
85 || [istarget *-*-cygwin*]
86 || [istarget *-*-pe*]
87 || [istarget arm*-*-symbianelf*]} {
88 # Do not need anything.
89 set linkarg ""
90 } elseif {[istarget *-*-freebsd*] || [istarget *-*-openbsd*]} {
91 set linkarg "-Wl,-rpath,$outdir"
92 } else {
93 set linkarg "-Wl,-rpath,\\\$ORIGIN"
94 }
95 set status [remote_exec host "$gnatlink foo $linkarg -Wl,-lsome_package"]
96 if {[lindex $status 0] == 0} {
97 pass "gnatlink foo"
98 } else {
99 fail "gnatlink foo"
100 return -1
101 }
102 }
103
104 clean_restart ${testfile}
105
106 if {![runto_main]} then {
107 return 0
108 }
109
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 $" {
113 pass $gdb_test_name
114 set can_catch_exceptions 1
115 }
116
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
119 }
120 }
121
122 if { $can_catch_exceptions } {
123 gdb_test "cont" \
124 "Catchpoint \[0-9\]+, .* at .*foo\.adb:\[0-9\]+.*" \
125 "caught the exception"
126
127 gdb_test "print \$_ada_exception = some_package.some_kind_of_error'Address" \
128 " = true"
129 }
This page took 0.032403 seconds and 4 git commands to generate.