Fix test names starting with uppercase output by basic functions
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.ada / catch_ex.exp
1 # Copyright 2007-2016 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 standard_ada_testfile foo
19
20 if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug additional_flags=-gnata ]] != "" } {
21 return -1
22 }
23
24 clean_restart ${testfile}
25
26 # Some global variables used to simplify the maintenance of some of
27 # the regular expressions below.
28 set any_nb "\[0-9\]+"
29 set any_addr "0x\[0-9a-zA-Z\]+"
30 set eol "\[\r\n\]+"
31 set sp "\[ \t\]*"
32
33 set info_break_header "Num${sp}Type${sp}Disp${sp}Enb${sp}Address${sp}What"
34 set catch_exception_info \
35 "$any_nb${sp}breakpoint${sp}keep${sp}y${sp}$any_addr${sp}all Ada exceptions"
36
37 ####################################
38 # 1. Try catching all exceptions. #
39 ####################################
40
41 if ![runto_main] then {
42 fail "cannot run to main, testcase aborted"
43 return 0
44 }
45
46 set msg "insert catchpoint on all Ada exceptions"
47 gdb_test_multiple "catch exception" $msg {
48 -re "Catchpoint $any_nb: all Ada exceptions$eol$gdb_prompt $" {
49 pass $msg
50 }
51 -re "Your Ada runtime appears to be missing some debugging information.*$eol$gdb_prompt $" {
52 # If the runtime was not built with enough debug information,
53 # or if it was stripped, we can not test exception
54 # catchpoints.
55 unsupported $msg
56 return -1
57 }
58 }
59
60 gdb_test "info break" \
61 "$info_break_header$eol.*$catch_exception_info" \
62 "info break, catch all Ada exceptions"
63
64 set catchpoint_msg \
65 "Catchpoint $any_nb, CONSTRAINT_ERROR at $any_addr in foo \\\(\\\).*at .*foo.adb:$any_nb"
66 gdb_test "continue" \
67 "Continuing\.$eol$catchpoint_msg$eol.*SPOT1" \
68 "continuing to first exception"
69
70 set catchpoint_msg \
71 "Catchpoint $any_nb, PROGRAM_ERROR at $any_addr in foo \\\(\\\).*at .*foo.adb:$any_nb"
72 gdb_test "continue" \
73 "Continuing\.$eol$catchpoint_msg$eol.*SPOT2" \
74 "continuing to second exception"
75
76 ################################################
77 # 2. Try catching only some of the exceptions. #
78 ################################################
79
80 # Here is the scenario:
81 # - Restart the debugger from scratch, runto_main
82 # - We'll catch only "Program_Error"
83 # We'll catch assertions
84 # We'll catch unhandled exceptions
85 # - continue, we should see the first Program_Error exception
86 # - continue, we should see the failed assertion
87 # - continue, we should see the unhandled Constrait_Error exception
88 # - continue, the program exits.
89
90 if ![runto_main] then {
91 fail "cannot run to main, testcase aborted"
92 return 0
93 }
94
95 gdb_test "catch exception Program_Error" \
96 "Catchpoint $any_nb: \`Program_Error' Ada exception" \
97 "insert catchpoint on Program_Error"
98
99 gdb_test "catch assert" \
100 "Catchpoint $any_nb: failed Ada assertions" \
101 "insert catchpoint on failed assertions"
102
103 gdb_test "catch exception unhandled" \
104 "Catchpoint $any_nb: unhandled Ada exceptions" \
105 "insert catchpoint on unhandled exceptions"
106
107 set catch_exception_entry \
108 "$any_nb${sp}breakpoint${sp}keep${sp}y${sp}$any_addr${sp}\`Program_Error' Ada exception"
109 set catch_assert_entry \
110 "$any_nb${sp}breakpoint${sp}keep${sp}y${sp}$any_addr${sp}failed Ada assertions"
111 set catch_unhandled_entry \
112 "$any_nb${sp}breakpoint${sp}keep${sp}y${sp}$any_addr${sp}unhandled Ada exceptions"
113
114 gdb_test "info break" \
115 "$info_break_header$eol.*$catch_exception_entry$eol$catch_assert_entry$eol$catch_unhandled_entry" \
116 "info break, second run"
117
118 set catchpoint_msg \
119 "Catchpoint $any_nb, PROGRAM_ERROR at $any_addr in foo \\\(\\\).*at .*foo.adb:$any_nb"
120 gdb_test "continue" \
121 "Continuing\.$eol$catchpoint_msg$eol.*SPOT2" \
122 "continuing to Program_Error exception"
123
124 set catchpoint_msg \
125 "Catchpoint $any_nb, failed assertion at $any_addr in foo \\\(\\\).*at .*foo.adb:$any_nb"
126 gdb_test "continue" \
127 "Continuing\.$eol$catchpoint_msg$eol.*SPOT3" \
128 "continuing to failed assertion"
129
130 set catchpoint_msg \
131 "Catchpoint $any_nb, unhandled CONSTRAINT_ERROR at $any_addr in foo \\\(\\\).*at .*foo.adb:$any_nb"
132 gdb_test "continue" \
133 "Continuing\.$eol$catchpoint_msg$eol.*SPOT4" \
134 "continuing to unhandled exception"
135
136 gdb_test "continue" \
137 "Continuing\..*$inferior_exited_re.*" \
138 "continuing to program completion"
139
140 #################################
141 # 3. Try temporary catchpoints. #
142 #################################
143
144 # Scenario:
145 # - Insert a temporary catchpoint on all exceptions.
146 # - Run to that catchpoint
147 # - Continue; we should reach the program's exit, not stopping
148 # at any of the other exceptions that are being raised inside
149 # the program.
150
151 if ![runto_main] then {
152 fail "cannot run to main, testcase aborted"
153 return 0
154 }
155
156 gdb_test "tcatch exception" \
157 "Temporary catchpoint $any_nb: all Ada exceptions"
158
159 set temp_catchpoint_msg \
160 "Temporary catchpoint $any_nb, CONSTRAINT_ERROR at $any_addr in foo \\\(\\\).*at .*foo.adb:$any_nb"
161 gdb_test "continue" \
162 "Continuing\.$eol$temp_catchpoint_msg$eol.*SPOT1" \
163 "continuing to temporary catchpoint"
164
165 gdb_test "continue" \
166 "Continuing\..*$inferior_exited_re.*" \
167 "continuing to program completion"
168
169
170
This page took 0.032767 seconds and 4 git commands to generate.