Commit | Line | Data |
---|---|---|
11bc5fe4 | 1 | # Copyright 2018-2020 Free Software Foundation, Inc. |
395507f6 XR |
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 bla | |
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 | ###################################################################### | |
27 | # 1. Try catching all exceptions to check that runtime supports it. # | |
28 | ###################################################################### | |
29 | ||
30 | set eol "\[\r\n\]+" | |
31 | set sp "\[ \t\]*" | |
32 | ||
33 | if ![runto_main] then { | |
34 | fail "cannot run to main, testcase aborted" | |
35 | return 0 | |
36 | } | |
37 | ||
38 | set msg "insert catchpoint on all Ada exceptions" | |
39 | gdb_test_multiple "catch exception" $msg { | |
40 | -re "Catchpoint $decimal: all Ada exceptions$eol$gdb_prompt $" { | |
41 | pass $msg | |
42 | } | |
43 | -re "Your Ada runtime appears to be missing some debugging information.*$eol$gdb_prompt $" { | |
44 | # If the runtime was not built with enough debug information, | |
45 | # or if it was stripped, we can not test exception | |
46 | # catchpoints. | |
47 | unsupported $msg | |
48 | return -1 | |
49 | } | |
50 | } | |
51 | ||
52 | ################################################## | |
53 | # 2. Try catching conditional failed assertion. # | |
54 | ################################################## | |
55 | ||
56 | # Here is the scenario: | |
57 | # - Restart the debugger from scratch, runto_main | |
58 | # We'll catch assertions if Global_Var = 2 | |
59 | # - continue, we should see the second failed assertion | |
60 | # - continue, the program exits. | |
61 | ||
62 | if ![runto_main] then { | |
63 | fail "cannot run to main, testcase aborted" | |
64 | return 0 | |
65 | } | |
66 | ||
67 | gdb_test "catch assert if Global_Var = 2" \ | |
68 | "Catchpoint $decimal: failed Ada assertions" \ | |
69 | "insert catchpoint on failed assertions with condition" | |
70 | ||
71 | # Check that condition is stored and properly displayed. | |
72 | ||
f06f1252 | 73 | set exp_bp ".*$decimal${sp}catchpoint${sp}keep${sp}y${sp}failed Ada assertions$eol${sp}stop only if Global_Var = 2.*" |
395507f6 XR |
74 | gdb_test "info breakpoint" $exp_bp "Check catch assertions with condition" |
75 | ||
76 | set bp_location [gdb_get_line_number "STOP" ${testdir}/bla.adb] | |
77 | ||
78 | set catchpoint_msg \ | |
79 | "Catchpoint $decimal, failed assertion at $hex in bla \\\(\\\).*at .*bla.adb:$bp_location" | |
80 | gdb_test "continue" \ | |
81 | "Continuing\.$eol$catchpoint_msg$eol.*STOP" \ | |
82 | "continuing to expected failed assertion" | |
83 | ||
84 | gdb_test "continue" \ | |
85 | "Continuing\..*$inferior_exited_re.*" \ | |
86 | "continuing to program completion" |