1 # Copyright 2011-2012 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 set testdir "mi_catch_ex"
19 set testfile "${testdir}/foo"
20 set srcfile ${srcdir}/${subdir}/${testfile}.adb
21 set binfile ${objdir}/${subdir}/${testfile}
23 file mkdir ${objdir}/${subdir}/${testdir}
24 if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug additional_flags=-gnata ]] != "" } {
28 # Some global variables used to simplify the maintenance of some of
29 # the regular expressions below.
33 # Before going any further, verify that we can insert exception
34 # catchpoints... That way, we won't have to do this while doing
35 # the actual GDB/MI testing.
37 clean_restart ${testfile}
39 if ![runto_main] then {
40 fail "Cannot run to main, testcase aborted"
44 set msg "insert catchpoint on all Ada exceptions"
45 gdb_test_multiple "catch exception" $msg {
46 -re "Catchpoint $any_nb: all Ada exceptions$eol$gdb_prompt $" {
49 -re "Your Ada runtime appears to be missing some debugging information.*\[\r\n\]+$gdb_prompt $" {
50 # If the runtime was not built with enough debug information,
51 # or if it was stripped, we can not test exception
58 # Now, we can start the GDB/MI testing itself...
60 load_lib mi-support.exp
69 mi_gdb_reinitialize_dir $srcdir/$subdir
70 mi_gdb_load ${binfile}
72 ####################################
73 # 1. Try catching all exceptions. #
74 ####################################
76 if ![mi_run_to_main] then {
77 fail "Cannot run to main, testcase aborted"
81 mi_gdb_test "catch exception"
83 mi_execute_to "exec-continue" \
84 "breakpoint-hit\",disp=\"keep\",bkptno=\"$any_nb\",exception-name=\"CONSTRAINT_ERROR" \
87 "continue to exception catchpoint hit"
89 mi_execute_to "exec-continue" \
90 "breakpoint-hit\",disp=\"keep\",bkptno=\"$any_nb\",exception-name=\"PROGRAM_ERROR" \
93 "continue to exception catchpoint hit"
95 ################################################
96 # 2. Try catching only some of the exceptions. #
97 ################################################
99 # Here is the scenario:
100 # - Restart the debugger from scratch, runto_main
101 # - We'll catch only "Program_Error"
102 # We'll catch assertions
103 # We'll catch unhandled exceptions
104 # - continue, we should see the first Program_Error exception
105 # - continue, we should see the failed assertion
106 # - continue, we should see the unhandled Constrait_Error exception
107 # - continue, the program exits.
109 if ![mi_run_to_main] then {
110 fail "Cannot run to main, testcase aborted"
114 mi_gdb_test "catch exception Program_Error"
116 mi_gdb_test "catch assert"
118 mi_gdb_test "catch exception unhandled"
120 mi_execute_to "exec-continue" \
121 "breakpoint-hit\",disp=\"keep\",bkptno=\"$any_nb\",exception-name=\"PROGRAM_ERROR" \
124 "continue to exception catchpoint hit"
126 mi_execute_to "exec-continue" \
127 "breakpoint-hit\",disp=\"keep\",bkptno=\"$any_nb" \
130 "continue to exception catchpoint hit"
132 mi_execute_to "exec-continue" \
133 "breakpoint-hit\",disp=\"keep\",bkptno=\"$any_nb\",exception-name=\"CONSTRAINT_ERROR" \
136 "continue to exception catchpoint hit"