improve Ada exception catchpoint MI notification
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.ada / mi_catch_ex.exp
1 # Copyright 2011 Free Software Foundation, Inc.
2 #
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.
7 #
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.
12 #
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/>.
15
16 load_lib "ada.exp"
17
18 set testdir "mi_catch_ex"
19 set testfile "${testdir}/foo"
20 set srcfile ${srcdir}/${subdir}/${testfile}.adb
21 set binfile ${objdir}/${subdir}/${testfile}
22
23 file mkdir ${objdir}/${subdir}/${testdir}
24 if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug additional_flags=-gnata ]] != "" } {
25 return -1
26 }
27
28 # Some global variables used to simplify the maintenance of some of
29 # the regular expressions below.
30 set any_nb "\[0-9\]+"
31 set eol "\[\r\n\]+"
32
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.
36
37 clean_restart ${testfile}
38
39 if ![runto_main] then {
40 fail "Cannot run to main, testcase aborted"
41 return 0
42 }
43
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 $" {
47 pass $msg
48 }
49 -re "Cannot break on __gnat_raise_nodefer_with_msg in this configuration\.\[\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
52 # catchpoints.
53 unsupported $msg
54 return -1
55 }
56 }
57
58 # Now, we can start the GDB/MI testing itself...
59
60 load_lib mi-support.exp
61 set MIFLAGS "-i=mi"
62
63 gdb_exit
64 if [mi_gdb_start] {
65 continue
66 }
67
68 mi_delete_breakpoints
69 mi_gdb_reinitialize_dir $srcdir/$subdir
70 mi_gdb_load ${binfile}
71
72 ####################################
73 # 1. Try catching all exceptions. #
74 ####################################
75
76 if ![mi_run_to_main] then {
77 fail "Cannot run to main, testcase aborted"
78 return 0
79 }
80
81 mi_gdb_test "catch exception"
82
83 mi_execute_to "exec-continue" \
84 "breakpoint-hit\",disp=\"keep\",bkptno=\"$any_nb\",exception-name=\"CONSTRAINT_ERROR" \
85 "foo" "" ".*" ".*" \
86 ".*" \
87 "continue to exception catchpoint hit"
88
89 mi_execute_to "exec-continue" \
90 "breakpoint-hit\",disp=\"keep\",bkptno=\"$any_nb\",exception-name=\"PROGRAM_ERROR" \
91 "foo" "" ".*" ".*" \
92 ".*" \
93 "continue to exception catchpoint hit"
94
95 ################################################
96 # 2. Try catching only some of the exceptions. #
97 ################################################
98
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.
108
109 if ![mi_run_to_main] then {
110 fail "Cannot run to main, testcase aborted"
111 return 0
112 }
113
114 mi_gdb_test "catch exception Program_Error"
115
116 mi_gdb_test "catch assert"
117
118 mi_gdb_test "catch exception unhandled"
119
120 mi_execute_to "exec-continue" \
121 "breakpoint-hit\",disp=\"keep\",bkptno=\"$any_nb\",exception-name=\"PROGRAM_ERROR" \
122 "foo" "" ".*" ".*" \
123 ".*" \
124 "continue to exception catchpoint hit"
125
126 mi_execute_to "exec-continue" \
127 "breakpoint-hit\",disp=\"keep\",bkptno=\"$any_nb" \
128 "foo" "" ".*" ".*" \
129 ".*" \
130 "continue to exception catchpoint hit"
131
132 mi_execute_to "exec-continue" \
133 "breakpoint-hit\",disp=\"keep\",bkptno=\"$any_nb\",exception-name=\"CONSTRAINT_ERROR" \
134 "foo" "" ".*" ".*" \
135 ".*" \
136 "continue to exception catchpoint hit"
137
This page took 0.038093 seconds and 5 git commands to generate.