]>
Commit | Line | Data |
---|---|---|
1d506c26 | 1 | # Copyright 2007-2024 Free Software Foundation, Inc. |
fd678c65 JB |
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 | |
e22f8b7c | 5 | # the Free Software Foundation; either version 3 of the License, or |
fd678c65 JB |
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 | |
e22f8b7c | 14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
fd678c65 | 15 | |
fd678c65 JB |
16 | load_lib "ada.exp" |
17 | ||
dd473473 | 18 | require allow_ada_tests gnat_runtime_has_debug_info |
7a82e903 | 19 | |
8223e12c | 20 | standard_ada_testfile foo |
fd678c65 | 21 | |
fd678c65 JB |
22 | if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug additional_flags=-gnata ]] != "" } { |
23 | return -1 | |
24 | } | |
25 | ||
09050809 | 26 | clean_restart ${testfile} |
fd678c65 JB |
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 any_addr "0x\[0-9a-zA-Z\]+" | |
cff71358 | 32 | set eol "\r\n" |
fd678c65 JB |
33 | set sp "\[ \t\]*" |
34 | ||
35 | set info_break_header "Num${sp}Type${sp}Disp${sp}Enb${sp}Address${sp}What" | |
36 | set catch_exception_info \ | |
f06f1252 | 37 | "$any_nb${sp}catchpoint${sp}keep${sp}y${sp}all Ada exceptions" |
fd678c65 JB |
38 | |
39 | #################################### | |
40 | # 1. Try catching all exceptions. # | |
41 | #################################### | |
42 | ||
ed7fbdd0 | 43 | if {![runto_main]} { |
fd678c65 JB |
44 | return 0 |
45 | } | |
46 | ||
dd473473 TT |
47 | gdb_test "catch exception" \ |
48 | "Catchpoint $any_nb: all Ada exceptions" \ | |
49 | "insert catchpoint on all Ada exceptions" | |
fd678c65 JB |
50 | |
51 | gdb_test "info break" \ | |
52 | "$info_break_header$eol.*$catch_exception_info" \ | |
53 | "info break, catch all Ada exceptions" | |
54 | ||
55 | set catchpoint_msg \ | |
15f3b077 | 56 | "Catchpoint $any_nb, CONSTRAINT_ERROR (\\\(ignore C_E\\\) )?at $any_addr in foo \\\(\\\).*at .*foo.adb:$any_nb" |
fd678c65 | 57 | gdb_test "continue" \ |
7e383deb | 58 | "Continuing\.$eol$eol$catchpoint_msg$eol.*SPOT1" \ |
fd678c65 JB |
59 | "continuing to first exception" |
60 | ||
61 | set catchpoint_msg \ | |
e547c119 | 62 | "Catchpoint $any_nb, PROGRAM_ERROR (\\\(foo\\.adb:$decimal explicit raise\\\) )?at $any_addr in foo \\\(\\\).*at .*foo.adb:$any_nb" |
fd678c65 | 63 | gdb_test "continue" \ |
7e383deb | 64 | "Continuing\.$eol$eol$catchpoint_msg$eol.*SPOT2" \ |
fd678c65 JB |
65 | "continuing to second exception" |
66 | ||
67 | ################################################ | |
68 | # 2. Try catching only some of the exceptions. # | |
69 | ################################################ | |
70 | ||
71 | # Here is the scenario: | |
72 | # - Restart the debugger from scratch, runto_main | |
73 | # - We'll catch only "Program_Error" | |
74 | # We'll catch assertions | |
75 | # We'll catch unhandled exceptions | |
76 | # - continue, we should see the first Program_Error exception | |
77 | # - continue, we should see the failed assertion | |
78 | # - continue, we should see the unhandled Constrait_Error exception | |
79 | # - continue, the program exits. | |
80 | ||
ed7fbdd0 | 81 | if {![runto_main]} { |
fd678c65 JB |
82 | return 0 |
83 | } | |
84 | ||
85 | gdb_test "catch exception Program_Error" \ | |
86 | "Catchpoint $any_nb: \`Program_Error' Ada exception" \ | |
87 | "insert catchpoint on Program_Error" | |
88 | ||
89 | gdb_test "catch assert" \ | |
90 | "Catchpoint $any_nb: failed Ada assertions" \ | |
91 | "insert catchpoint on failed assertions" | |
92 | ||
93 | gdb_test "catch exception unhandled" \ | |
94 | "Catchpoint $any_nb: unhandled Ada exceptions" \ | |
95 | "insert catchpoint on unhandled exceptions" | |
96 | ||
97 | set catch_exception_entry \ | |
f06f1252 | 98 | "$any_nb${sp}catchpoint${sp}keep${sp}y${sp}\`Program_Error' Ada exception" |
fd678c65 | 99 | set catch_assert_entry \ |
f06f1252 | 100 | "$any_nb${sp}catchpoint${sp}keep${sp}y${sp}failed Ada assertions" |
fd678c65 | 101 | set catch_unhandled_entry \ |
f06f1252 | 102 | "$any_nb${sp}catchpoint${sp}keep${sp}y${sp}unhandled Ada exceptions" |
fd678c65 JB |
103 | |
104 | gdb_test "info break" \ | |
105 | "$info_break_header$eol.*$catch_exception_entry$eol$catch_assert_entry$eol$catch_unhandled_entry" \ | |
106 | "info break, second run" | |
107 | ||
108 | set catchpoint_msg \ | |
e547c119 | 109 | "Catchpoint $any_nb, PROGRAM_ERROR (\\\(foo.adb:$decimal explicit raise\\\) )?at $any_addr in foo \\\(\\\).*at .*foo.adb:$any_nb" |
fd678c65 | 110 | gdb_test "continue" \ |
7e383deb | 111 | "Continuing\.$eol$eol$catchpoint_msg$eol.*SPOT2" \ |
fd678c65 JB |
112 | "continuing to Program_Error exception" |
113 | ||
114 | set catchpoint_msg \ | |
115 | "Catchpoint $any_nb, failed assertion at $any_addr in foo \\\(\\\).*at .*foo.adb:$any_nb" | |
116 | gdb_test "continue" \ | |
7e383deb | 117 | "Continuing\.$eol$eol$catchpoint_msg$eol.*SPOT3" \ |
9836f81b | 118 | "continuing to failed assertion" |
fd678c65 JB |
119 | |
120 | set catchpoint_msg \ | |
121 | "Catchpoint $any_nb, unhandled CONSTRAINT_ERROR at $any_addr in foo \\\(\\\).*at .*foo.adb:$any_nb" | |
122 | gdb_test "continue" \ | |
7e383deb | 123 | "Continuing\.$eol$eol$catchpoint_msg$eol.*SPOT4" \ |
9836f81b | 124 | "continuing to unhandled exception" |
fd678c65 | 125 | |
5dbdd470 TT |
126 | gdb_test "continue" \ |
127 | "Continuing\..*$inferior_exited_re.*" \ | |
128 | "continuing to program completion" | |
fd678c65 | 129 | |
00eb2c4a JB |
130 | ################################# |
131 | # 3. Try temporary catchpoints. # | |
132 | ################################# | |
133 | ||
134 | # Scenario: | |
135 | # - Insert a temporary catchpoint on all exceptions. | |
136 | # - Run to that catchpoint | |
137 | # - Continue; we should reach the program's exit, not stopping | |
138 | # at any of the other exceptions that are being raised inside | |
139 | # the program. | |
140 | ||
ed7fbdd0 | 141 | if {![runto_main]} { |
00eb2c4a JB |
142 | return 0 |
143 | } | |
144 | ||
145 | gdb_test "tcatch exception" \ | |
146 | "Temporary catchpoint $any_nb: all Ada exceptions" | |
147 | ||
148 | set temp_catchpoint_msg \ | |
e547c119 | 149 | "Temporary catchpoint $any_nb, CONSTRAINT_ERROR (\\\(.*\\\) )?at $any_addr in foo \\\(\\\).*at .*foo.adb:$any_nb" |
00eb2c4a | 150 | gdb_test "continue" \ |
7e383deb | 151 | "Continuing\.$eol$eol$temp_catchpoint_msg$eol.*SPOT1" \ |
00eb2c4a JB |
152 | "continuing to temporary catchpoint" |
153 | ||
dbb0ab10 TV |
154 | with_test_prefix "temporary catchpoint" { |
155 | gdb_test "continue" \ | |
156 | "Continuing\..*$inferior_exited_re.*" \ | |
157 | "continuing to program completion" | |
158 | } | |
00eb2c4a | 159 | |
fd678c65 | 160 |