Automatic Copyright Year update after running gdb/copyright.py
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.ada / catch_ex_std.exp
CommitLineData
88b9d363 1# Copyright 2019-2022 Free Software Foundation, Inc.
2ff0a947
TT
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
16if {[skip_shlib_tests]} {
17 return 0
18}
19
20load_lib "ada.exp"
21
7a82e903
PA
22if { [skip_ada_tests] } { return -1 }
23
2ff0a947
TT
24standard_ada_testfile foo
25
2ff0a947 26set srcfile2 [file join [file dirname $srcfile] some_package.adb]
2ff0a947
TT
27set sofile [standard_output_file libsome_package.so]
28
29set outdir [file dirname $binfile]
30
a406a98e 31# Create the shared library.
2f413264 32if {[gdb_compile_shlib $srcfile2 $sofile {ada debug}] != ""} {
2ff0a947
TT
33 return -1
34}
35
5d7e6ed0
TV
36# Set linkarg such that the executable can find the shared library.
37if {[istarget "*-*-mingw*"]
38 || [istarget *-*-cygwin*]
18b8df43 39 || [istarget *-*-pe*]} {
5d7e6ed0
TV
40 # Do not need anything.
41 set linkarg ""
42} elseif {[istarget *-*-freebsd*] || [istarget *-*-openbsd*]} {
43 set linkarg "-Wl,-rpath,$outdir"
44} else {
45 set linkarg "-Wl,-rpath,\\\$ORIGIN"
2ff0a947
TT
46}
47
5d7e6ed0
TV
48# Make sure we link against the shared GNAT run time.
49set gnatbind_options [list -bargs -shared -margs]
2ff0a947 50
5d7e6ed0
TV
51# Link against the shared library.
52set gnatlink_options [list -largs $linkarg -Wl,-lsome_package -margs]
2ff0a947 53
5d7e6ed0
TV
54set options [list debug]
55foreach option [concat $gnatbind_options $gnatlink_options] {
56 lappend options [concat "additional_flags=" $option]
57}
58
59# Create executable.
60if {[gdb_compile_ada $srcfile $binfile executable $options] != ""} {
61 return -1
2ff0a947
TT
62}
63
64clean_restart ${testfile}
65
66if {![runto_main]} then {
67 return 0
68}
69
60ff3cd7
AB
70set can_catch_exceptions 0
71gdb_test_multiple "catch exception some_kind_of_error" "" {
72 -re "Catchpoint \[0-9\]+: `some_kind_of_error' Ada exception\r\n$gdb_prompt $" {
73 pass $gdb_test_name
74 set can_catch_exceptions 1
75 }
2ff0a947 76
60ff3cd7
AB
77 -re "Your Ada runtime appears to be missing some debugging information.\r\nCannot insert Ada exception catchpoint in this configuration.\r\n$gdb_prompt $" {
78 unsupported $gdb_test_name
79 }
80}
37f6a7f4 81
60ff3cd7
AB
82if { $can_catch_exceptions } {
83 gdb_test "cont" \
84 "Catchpoint \[0-9\]+, .* at .*foo\.adb:\[0-9\]+.*" \
85 "caught the exception"
86
87 gdb_test "print \$_ada_exception = some_package.some_kind_of_error'Address" \
88 " = true"
89}
This page took 0.355578 seconds and 4 git commands to generate.