]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.ada/mi_catch_ex_hand.exp
Change Ada catchpoints to be bp_catchpoint
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.ada / mi_catch_ex_hand.exp
1 # Copyright 2011-2019 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 load_lib "ada.exp"
17
18 standard_ada_testfile foo
19
20 if {[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.
26 set 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
32 clean_restart ${testfile}
33
34 if ![runto_main] then {
35 fail "cannot run to main, testcase aborted"
36 return 0
37 }
38
39 set msg "insert catchpoint on all Ada exceptions handlers"
40 gdb_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
55 load_lib mi-support.exp
56 set MIFLAGS "-i=mi"
57
58 gdb_exit
59 if [mi_gdb_start] {
60 continue
61 }
62
63 #############################################
64 # 1. Try catching all exceptions handlers. #
65 #############################################
66
67 if ![mi_run_to_main] then {
68 fail "cannot run to main, testcase aborted"
69 return 0
70 }
71
72 mi_gdb_test "-catch-handlers" \
73 "\\^done,bkptno=\"$decimal\",bkpt={.*disp=\"keep\",enabled=\"y\",what=\"all Ada exceptions handlers\",.*}" \
74 "catch all exceptions handlers"
75
76 # Continue to exception handler.
77
78 proc continue_to_exception_handler { test line } {
79
80 global decimal
81
82 mi_send_resuming_command "exec-continue" "$test"
83
84 # Now MI stream output.
85 mi_expect_stop \
86 "breakpoint-hit\",disp=\"keep\",bkptno=\"$decimal\",exception-name=\"exception\"?" \
87 "foo" "" ".*" "$line" \
88 ".*" \
89 $test
90 }
91
92 # We don't have the exception name info when stopping at the exception handlers
93 # catchpoints so we use source line to check if the inferior stops at the
94 # right location.
95
96 set bp_ce_location [gdb_get_line_number "BREAK1" ${testdir}/foo.adb]
97 continue_to_exception_handler \
98 "continue until CE handling caught by all-exceptions handlers catchpoint" \
99 "$bp_ce_location"
100
101 set bp_pe_location [gdb_get_line_number "BREAK2" ${testdir}/foo.adb]
102 continue_to_exception_handler \
103 "continue until PE handling caught by all-exceptions handlers catchpoint" \
104 "$bp_pe_location"
105
106 ##########################################################
107 # 2. Try catching only some of the exceptions handlers. #
108 ##########################################################
109
110 # Here is the scenario:
111 # - Restart the debugger from scratch, runto_main
112 # - We'll catch only "Constraint_Error handlers"
113 # - continue, we should stop at the Constraint_Error exception handler
114 # - continue, we should not stop at the Program_Error exception handler
115 # but exit instead.
116
117 if ![mi_run_to_main] then {
118 fail "cannot run to main, testcase aborted"
119 return 0
120 }
121
122 mi_gdb_test "-catch-handlers -e Constraint_Error" \
123 "\\^done,bkptno=\"$decimal\",bkpt={.*disp=\"keep\",enabled=\"y\",what=\"`Constraint_Error' Ada exception handlers\",.*}" \
124 "catch Constraint_Error"
125
126 mi_execute_to "exec-continue" \
127 "breakpoint-hit\",disp=\"keep\",bkptno=\"$decimal\",exception-name=\"exception\"?" \
128 "foo" "" ".*" "$bp_ce_location" \
129 ".*" \
130 "continue to exception catchpoint hit"
131
132 # Exit the inferior.
133 mi_send_resuming_command "exec-continue" "continuing to inferior exit"
134 mi_expect_stop "exited-normally" "" "" "" "" "" "exit normally"
135
136 mi_gdb_exit
137 return 0