1 # Copyright 2011-2024 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 require allow_ada_tests gnat_runtime_has_debug_info
20 standard_ada_testfile foo
22 if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug additional_flags=-gnata ]] != "" } {
26 load_lib mi-support.exp
29 mi_clean_restart $binfile
31 #############################################
32 # 1. Try catching all exceptions handlers. #
33 #############################################
35 with_test_prefix "scenario 1" {
36 if {[mi_runto_main] < 0} {
41 mi_gdb_test "-catch-handlers" \
42 "\\^done,bkptno=\"$decimal\",bkpt={.*disp=\"keep\",enabled=\"y\",what=\"all Ada exceptions handlers\",.*}" \
43 "catch all exceptions handlers"
45 # Continue to exception handler.
47 proc continue_to_exception_handler { test line } {
51 mi_send_resuming_command "exec-continue" "$test"
53 # Now MI stream output.
55 "\"breakpoint-hit\",disp=\"keep\",bkptno=\"$decimal\",exception-name=\"exception\"" \
56 "foo" "" ".*" "$line" \
61 # We don't have the exception name info when stopping at the exception handlers
62 # catchpoints so we use source line to check if the inferior stops at the
65 set bp_ce_location [gdb_get_line_number "BREAK1" ${testdir}/foo.adb]
66 continue_to_exception_handler \
67 "continue until CE handling caught by all-exceptions handlers catchpoint" \
70 set bp_pe_location [gdb_get_line_number "BREAK2" ${testdir}/foo.adb]
71 continue_to_exception_handler \
72 "continue until PE handling caught by all-exceptions handlers catchpoint" \
75 ##########################################################
76 # 2. Try catching only some of the exceptions handlers. #
77 ##########################################################
79 # Here is the scenario:
80 # - Restart the debugger from scratch, runto_main
81 # - We'll catch only "Constraint_Error handlers"
82 # - continue, we should stop at the Constraint_Error exception handler
83 # - continue, we should not stop at the Program_Error exception handler
86 with_test_prefix "scenario 2" {
88 if {[mi_runto_main] < 0} {
93 mi_gdb_test "-catch-handlers -e Constraint_Error" \
94 "\\^done,bkptno=\"$decimal\",bkpt={.*disp=\"keep\",enabled=\"y\",what=\"`Constraint_Error' Ada exception handlers\",.*}" \
95 "catch Constraint_Error"
97 mi_execute_to "exec-continue" \
98 "\"breakpoint-hit\",disp=\"keep\",bkptno=\"$decimal\",exception-name=\"exception\"" \
99 "foo" "" ".*" "$bp_ce_location" \
101 "continue to exception catchpoint hit"
104 mi_send_resuming_command "exec-continue" "continuing to inferior exit"
105 mi_expect_stop "exited-normally" "" "" "" "" "" "exit normally"