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