1 # Copyright 2011-2019 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 standard_ada_testfile foo
20 if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug additional_flags=-gnata ]] != "" } {
24 # A global variable used to simplify the maintenance of some of
25 # the regular expressions below.
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.
32 clean_restart ${testfile}
34 if ![runto_main] then {
35 fail "cannot run to main, testcase aborted"
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 $" {
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
53 # Now, we can start the GDB/MI testing itself...
55 load_lib mi-support.exp
63 #############################################
64 # 1. Try catching all exceptions handlers. #
65 #############################################
67 if ![mi_run_to_main] then {
68 fail "cannot run to main, testcase aborted"
72 mi_gdb_test "-catch-handlers" \
73 "\\^done,bkptno=\"$decimal\",bkpt={.*disp=\"keep\",enabled=\"y\",addr=\"$hex\",what=\"all Ada exceptions handlers\",.*}" \
74 "catch all exceptions handlers"
76 # Continue to exception handler.
78 proc continue_to_exception_handler { test line } {
82 mi_send_resuming_command "exec-continue" "$test"
84 # Now MI stream output.
86 "breakpoint-hit\",disp=\"keep\",bkptno=\"$decimal\",exception-name=\"exception\"?" \
87 "foo" "" ".*" "$line" \
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
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" \
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" \
106 ##########################################################
107 # 2. Try catching only some of the exceptions handlers. #
108 ##########################################################
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
117 if ![mi_run_to_main] then {
118 fail "cannot run to main, testcase aborted"
122 mi_gdb_test "-catch-handlers -e Constraint_Error" \
123 "\\^done,bkptno=\"$decimal\",bkpt={.*disp=\"keep\",enabled=\"y\",addr=\"$hex\",what=\"`Constraint_Error' Ada exception handlers\",.*}" \
124 "catch Constraint_Error"
126 mi_execute_to "exec-continue" \
127 "breakpoint-hit\",disp=\"keep\",bkptno=\"$decimal\",exception-name=\"exception\"?" \
128 "foo" "" ".*" "$bp_ce_location" \
130 "continue to exception catchpoint hit"
133 mi_send_resuming_command "exec-continue" "continuing to inferior exit"
134 mi_expect_stop "exited-normally" "" "" "" "" "" "exit normally"