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