1 # Copyright 2011-2021 Free Software Foundation, Inc.
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.
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.
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/>.
18 if { [skip_ada_tests] } { return -1 }
20 standard_ada_testfile foo
22 if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug additional_flags=-gnata ]] != "" } {
26 # A global variable used to simplify the maintenance of some of
27 # the regular expressions below.
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.
34 clean_restart ${testfile}
36 if ![runto_main] then {
37 fail "cannot run to main, testcase aborted"
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 $" {
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
55 # Now, we can start the GDB/MI testing itself...
57 load_lib mi-support.exp
60 mi_clean_restart $binfile
62 #############################################
63 # 1. Try catching all exceptions handlers. #
64 #############################################
66 with_test_prefix "scenario 1" {
67 if {[mi_runto_main] < 0} {
68 fail "cannot run to main, testcase aborted"
73 mi_gdb_test "-catch-handlers" \
74 "\\^done,bkptno=\"$decimal\",bkpt={.*disp=\"keep\",enabled=\"y\",what=\"all Ada exceptions handlers\",.*}" \
75 "catch all exceptions handlers"
77 # Continue to exception handler.
79 proc continue_to_exception_handler { test line } {
83 mi_send_resuming_command "exec-continue" "$test"
85 # Now MI stream output.
87 "breakpoint-hit\",disp=\"keep\",bkptno=\"$decimal\",exception-name=\"exception\"?" \
88 "foo" "" ".*" "$line" \
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
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" \
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" \
107 ##########################################################
108 # 2. Try catching only some of the exceptions handlers. #
109 ##########################################################
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
118 with_test_prefix "scenario 2" {
119 mi_delete_breakpoints
120 if {[mi_runto_main] < 0} {
121 fail "cannot run to main, testcase aborted"
126 mi_gdb_test "-catch-handlers -e Constraint_Error" \
127 "\\^done,bkptno=\"$decimal\",bkpt={.*disp=\"keep\",enabled=\"y\",what=\"`Constraint_Error' Ada exception handlers\",.*}" \
128 "catch Constraint_Error"
130 mi_execute_to "exec-continue" \
131 "breakpoint-hit\",disp=\"keep\",bkptno=\"$decimal\",exception-name=\"exception\"?" \
132 "foo" "" ".*" "$bp_ce_location" \
134 "continue to exception catchpoint hit"
137 mi_send_resuming_command "exec-continue" "continuing to inferior exit"
138 mi_expect_stop "exited-normally" "" "" "" "" "" "exit normally"