]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.ada/mi_catch_ex_hand.exp
[gdb/testsuite] Fix duplicate test-names in gdb.ada
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.ada / mi_catch_ex_hand.exp
CommitLineData
b811d2c2 1# Copyright 2011-2020 Free Software Foundation, Inc.
bea298f9
XR
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
16load_lib "ada.exp"
17
18standard_ada_testfile foo
19
20if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug additional_flags=-gnata ]] != "" } {
21 return -1
22}
23
24# A global variable used to simplify the maintenance of some of
25# the regular expressions below.
26set eol "\[\r\n\]+"
27
28# Before going any further, verify that we can insert exception
29# handlers catchpoints... That way, we won't have to do this while
30# doing the actual GDB/MI testing.
31
32clean_restart ${testfile}
33
34if ![runto_main] then {
35 fail "cannot run to main, testcase aborted"
36 return 0
37}
38
39set msg "insert catchpoint on all Ada exceptions handlers"
40gdb_test_multiple "catch handlers" $msg {
41 -re "Catchpoint $decimal: all Ada exceptions handlers$eol$gdb_prompt $" {
42 pass $msg
43 }
44 -re "Your Ada runtime appears to be missing some debugging information.*\[\r\n\]+$gdb_prompt $" {
45 # If the runtime was not built with enough debug information,
46 # or if it was stripped, we can not test exception
47 # catchpoints.
48 unsupported $msg
49 return -1
50 }
51}
52
53# Now, we can start the GDB/MI testing itself...
54
55load_lib mi-support.exp
56set MIFLAGS "-i=mi"
57
58gdb_exit
59if [mi_gdb_start] {
60 continue
61}
62
63#############################################
64# 1. Try catching all exceptions handlers. #
65#############################################
66
dbb0ab10
TV
67with_test_prefix "scenario 1" {
68 if ![mi_run_to_main] then {
69 fail "cannot run to main, testcase aborted"
70 return 0
71 }
bea298f9
XR
72}
73
74mi_gdb_test "-catch-handlers" \
f06f1252 75 "\\^done,bkptno=\"$decimal\",bkpt={.*disp=\"keep\",enabled=\"y\",what=\"all Ada exceptions handlers\",.*}" \
bea298f9
XR
76 "catch all exceptions handlers"
77
78# Continue to exception handler.
79
80proc continue_to_exception_handler { test line } {
81
82 global decimal
83
84 mi_send_resuming_command "exec-continue" "$test"
85
86 # Now MI stream output.
87 mi_expect_stop \
88 "breakpoint-hit\",disp=\"keep\",bkptno=\"$decimal\",exception-name=\"exception\"?" \
89 "foo" "" ".*" "$line" \
90 ".*" \
91 $test
92}
93
94# We don't have the exception name info when stopping at the exception handlers
95# catchpoints so we use source line to check if the inferior stops at the
96# right location.
97
98set bp_ce_location [gdb_get_line_number "BREAK1" ${testdir}/foo.adb]
99continue_to_exception_handler \
100 "continue until CE handling caught by all-exceptions handlers catchpoint" \
101 "$bp_ce_location"
102
103set bp_pe_location [gdb_get_line_number "BREAK2" ${testdir}/foo.adb]
104continue_to_exception_handler \
105 "continue until PE handling caught by all-exceptions handlers catchpoint" \
106 "$bp_pe_location"
107
108##########################################################
109# 2. Try catching only some of the exceptions handlers. #
110##########################################################
111
112# Here is the scenario:
113# - Restart the debugger from scratch, runto_main
114# - We'll catch only "Constraint_Error handlers"
115# - continue, we should stop at the Constraint_Error exception handler
116# - continue, we should not stop at the Program_Error exception handler
117# but exit instead.
118
dbb0ab10
TV
119with_test_prefix "scenario 2" {
120 if ![mi_run_to_main] then {
121 fail "cannot run to main, testcase aborted"
122 return 0
123 }
bea298f9
XR
124}
125
126mi_gdb_test "-catch-handlers -e Constraint_Error" \
f06f1252 127 "\\^done,bkptno=\"$decimal\",bkpt={.*disp=\"keep\",enabled=\"y\",what=\"`Constraint_Error' Ada exception handlers\",.*}" \
bea298f9
XR
128 "catch Constraint_Error"
129
130mi_execute_to "exec-continue" \
131 "breakpoint-hit\",disp=\"keep\",bkptno=\"$decimal\",exception-name=\"exception\"?" \
132 "foo" "" ".*" "$bp_ce_location" \
133 ".*" \
134 "continue to exception catchpoint hit"
135
136# Exit the inferior.
137mi_send_resuming_command "exec-continue" "continuing to inferior exit"
138mi_expect_stop "exited-normally" "" "" "" "" "" "exit normally"
139
140mi_gdb_exit
141return 0