1 # Copyright 2011-2023 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}
40 set msg "insert catchpoint on all Ada exceptions handlers"
41 gdb_test_multiple "catch handlers" $msg {
42 -re "Catchpoint $decimal: all Ada exceptions handlers$eol$gdb_prompt $" {
45 -re "Your Ada runtime appears to be missing some debugging information.*\[\r\n\]+$gdb_prompt $" {
46 # If the runtime was not built with enough debug information,
47 # or if it was stripped, we can not test exception
54 # Now, we can start the GDB/MI testing itself...
56 load_lib mi-support.exp
59 mi_clean_restart $binfile
61 #############################################
62 # 1. Try catching all exceptions handlers. #
63 #############################################
65 with_test_prefix "scenario 1" {
66 if {[mi_runto_main] < 0} {
71 mi_gdb_test "-catch-handlers" \
72 "\\^done,bkptno=\"$decimal\",bkpt={.*disp=\"keep\",enabled=\"y\",what=\"all Ada exceptions handlers\",.*}" \
73 "catch all exceptions handlers"
75 # Continue to exception handler.
77 proc continue_to_exception_handler { test line } {
81 mi_send_resuming_command "exec-continue" "$test"
83 # Now MI stream output.
85 "breakpoint-hit\",disp=\"keep\",bkptno=\"$decimal\",exception-name=\"exception\"?" \
86 "foo" "" ".*" "$line" \
91 # We don't have the exception name info when stopping at the exception handlers
92 # catchpoints so we use source line to check if the inferior stops at the
95 set bp_ce_location [gdb_get_line_number "BREAK1" ${testdir}/foo.adb]
96 continue_to_exception_handler \
97 "continue until CE handling caught by all-exceptions handlers catchpoint" \
100 set bp_pe_location [gdb_get_line_number "BREAK2" ${testdir}/foo.adb]
101 continue_to_exception_handler \
102 "continue until PE handling caught by all-exceptions handlers catchpoint" \
105 ##########################################################
106 # 2. Try catching only some of the exceptions handlers. #
107 ##########################################################
109 # Here is the scenario:
110 # - Restart the debugger from scratch, runto_main
111 # - We'll catch only "Constraint_Error handlers"
112 # - continue, we should stop at the Constraint_Error exception handler
113 # - continue, we should not stop at the Program_Error exception handler
116 with_test_prefix "scenario 2" {
117 mi_delete_breakpoints
118 if {[mi_runto_main] < 0} {
123 mi_gdb_test "-catch-handlers -e Constraint_Error" \
124 "\\^done,bkptno=\"$decimal\",bkpt={.*disp=\"keep\",enabled=\"y\",what=\"`Constraint_Error' Ada exception handlers\",.*}" \
125 "catch Constraint_Error"
127 mi_execute_to "exec-continue" \
128 "breakpoint-hit\",disp=\"keep\",bkptno=\"$decimal\",exception-name=\"exception\"?" \
129 "foo" "" ".*" "$bp_ce_location" \
131 "continue to exception catchpoint hit"
134 mi_send_resuming_command "exec-continue" "continuing to inferior exit"
135 mi_expect_stop "exited-normally" "" "" "" "" "" "exit normally"