Commit | Line | Data |
---|---|---|
88b9d363 | 1 | # Copyright 2011-2022 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 | ||
16 | load_lib "ada.exp" | |
17 | ||
7a82e903 PA |
18 | if { [skip_ada_tests] } { return -1 } |
19 | ||
bea298f9 XR |
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 | ||
b75d55d4 | 60 | mi_clean_restart $binfile |
bea298f9 XR |
61 | |
62 | ############################################# | |
63 | # 1. Try catching all exceptions handlers. # | |
64 | ############################################# | |
65 | ||
dbb0ab10 | 66 | with_test_prefix "scenario 1" { |
b75d55d4 | 67 | if {[mi_runto_main] < 0} { |
dbb0ab10 TV |
68 | fail "cannot run to main, testcase aborted" |
69 | return 0 | |
70 | } | |
bea298f9 XR |
71 | } |
72 | ||
73 | mi_gdb_test "-catch-handlers" \ | |
f06f1252 | 74 | "\\^done,bkptno=\"$decimal\",bkpt={.*disp=\"keep\",enabled=\"y\",what=\"all Ada exceptions handlers\",.*}" \ |
bea298f9 XR |
75 | "catch all exceptions handlers" |
76 | ||
77 | # Continue to exception handler. | |
78 | ||
79 | proc continue_to_exception_handler { test line } { | |
80 | ||
81 | global decimal | |
82 | ||
83 | mi_send_resuming_command "exec-continue" "$test" | |
84 | ||
85 | # Now MI stream output. | |
86 | mi_expect_stop \ | |
87 | "breakpoint-hit\",disp=\"keep\",bkptno=\"$decimal\",exception-name=\"exception\"?" \ | |
88 | "foo" "" ".*" "$line" \ | |
89 | ".*" \ | |
90 | $test | |
91 | } | |
92 | ||
93 | # We don't have the exception name info when stopping at the exception handlers | |
94 | # catchpoints so we use source line to check if the inferior stops at the | |
95 | # right location. | |
96 | ||
97 | set bp_ce_location [gdb_get_line_number "BREAK1" ${testdir}/foo.adb] | |
98 | continue_to_exception_handler \ | |
99 | "continue until CE handling caught by all-exceptions handlers catchpoint" \ | |
100 | "$bp_ce_location" | |
101 | ||
102 | set bp_pe_location [gdb_get_line_number "BREAK2" ${testdir}/foo.adb] | |
103 | continue_to_exception_handler \ | |
104 | "continue until PE handling caught by all-exceptions handlers catchpoint" \ | |
105 | "$bp_pe_location" | |
106 | ||
107 | ########################################################## | |
108 | # 2. Try catching only some of the exceptions handlers. # | |
109 | ########################################################## | |
110 | ||
111 | # Here is the scenario: | |
112 | # - Restart the debugger from scratch, runto_main | |
113 | # - We'll catch only "Constraint_Error handlers" | |
114 | # - continue, we should stop at the Constraint_Error exception handler | |
115 | # - continue, we should not stop at the Program_Error exception handler | |
116 | # but exit instead. | |
117 | ||
dbb0ab10 | 118 | with_test_prefix "scenario 2" { |
8c8bd0ba | 119 | mi_delete_breakpoints |
b75d55d4 | 120 | if {[mi_runto_main] < 0} { |
dbb0ab10 TV |
121 | fail "cannot run to main, testcase aborted" |
122 | return 0 | |
123 | } | |
bea298f9 XR |
124 | } |
125 | ||
126 | mi_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 | ||
130 | mi_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. | |
137 | mi_send_resuming_command "exec-continue" "continuing to inferior exit" | |
138 | mi_expect_stop "exited-normally" "" "" "" "" "" "exit normally" | |
139 | ||
140 | mi_gdb_exit | |
141 | return 0 |