]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.reverse/sigall-precsave.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.reverse / sigall-precsave.exp
1 # Copyright 2009-2024 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 require {!target_info exists gdb,nosignals}
17
18 require supports_reverse
19
20 standard_testfile sigall-reverse.c
21 set precsave [standard_output_file sigall.precsave]
22
23 if {[build_executable $testfile.exp $testfile $srcfile debug] == -1} {
24 return -1
25 }
26
27 proc test_one_sig {nextsig} {
28 global sig_supported
29 global gdb_prompt
30 global thissig
31
32 set this_sig_supported $sig_supported
33 gdb_test "handle SIG$thissig stop print" \
34 "SIG$thissig\[ \t\]*Yes\[ \t\]*Yes\[ \t\]*Yes.*"
35 gdb_test "b handle_$thissig" "Breakpoint \[0-9\]+ .*"
36 gdb_test "b gen_$nextsig" "Breakpoint \[0-9\]+ .*"
37
38 set need_another_continue 1
39 set missed_handler 0
40 if {$this_sig_supported} {
41 if { $thissig == "IO" } {
42 setup_xfail "i*86-pc-linuxoldld-gnu" "i*86-pc-linuxaout-gnu"
43 }
44 set testmsg "get signal $thissig"
45 gdb_test_multiple "continue" $testmsg {
46 -re "Program received signal SIG$thissig.*handle_$thissig.*$gdb_prompt $" {
47 fail "$testmsg (wrong location)"
48 }
49 -re "Program received signal SIG$thissig.*$gdb_prompt $" {
50 pass $testmsg
51 }
52 -re "Breakpoint.* handle_$thissig.*$gdb_prompt $" {
53 xfail $testmsg
54 set need_another_continue 0
55 }
56 }
57 }
58
59 if {$need_another_continue} {
60 if { $thissig == "URG" } {
61 setup_xfail "i*86-pc-linuxoldld-gnu" "i*86-pc-linuxaout-gnu"
62 }
63 # Either Lynx or GDB screws up on SIGPRIO
64 if { $thissig == "PRIO" } {
65 setup_xfail "*-*-*lynx*"
66 }
67 set testmsg "send signal $thissig"
68 gdb_test_multiple "continue" $testmsg {
69 -re "Breakpoint.*handle_$thissig.*$gdb_prompt $" {
70 pass $testmsg
71 }
72 -re "Breakpoint.*gen_$nextsig.*kill.*$gdb_prompt $" {
73 fail "missed breakpoint at handle_$thissig"
74 set missed_handler 1
75 }
76 }
77 }
78
79 if {$missed_handler == "0"} {
80 set testmsg "advance to $nextsig"
81 gdb_test_multiple "signal 0" $testmsg {
82 -re "Breakpoint.*gen_$nextsig.*kill.*$gdb_prompt $" {
83 pass $testmsg
84 set sig_supported 1
85 }
86 -re "Breakpoint.*gen_$nextsig.*handle.*$gdb_prompt $" {
87 pass $testmsg
88 set sig_supported 0
89 }
90 }
91 }
92 set thissig $nextsig
93 }
94
95 proc test_one_sig_reverse {prevsig} {
96 global gdb_prompt
97
98 gdb_test "reverse-continue" "Breakpoint .* handle_$prevsig.*" \
99 "reverse to handler of $prevsig"
100
101 set saw_signal 0
102 set testmsg "reverse to gen_$prevsig"
103 gdb_test_multiple "reverse-continue" $testmsg {
104 -re "Breakpoint.*handle_.*$gdb_prompt " {
105 pass "$testmsg (un-handled)"
106 }
107 -re "Program received signal SIG$prevsig.*$gdb_prompt " {
108 pass "reverse to signal event, $prevsig"
109
110 set nested_testmsg "reverse signal $prevsig delivered"
111 gdb_test_multiple "frame" $nested_testmsg {
112 -re ".*handle_$prevsig.*$gdb_prompt " {
113 fail "$nested_testmsg (wrong location)"
114 }
115 -re ".*$gdb_prompt " {
116 pass $nested_testmsg
117 }
118 }
119
120 set saw_signal 1
121 send_gdb "reverse-continue\n"
122 exp_continue
123 }
124 -re "Breakpoint.*kill.*$gdb_prompt " {
125 if {$saw_signal} {
126 pass "$testmsg (handled)"
127 } else {
128 xfail "$testmsg (handled)"
129 }
130 }
131 -re "No more reverse-execution history.*kill.*$gdb_prompt " {
132 if {$saw_signal} {
133 pass "$testmsg (handled)"
134 } else {
135 xfail "$testmsg (handled)"
136 }
137 }
138 }
139 }
140
141 clean_restart $binfile
142
143 runto gen_ABRT
144
145 if [supports_process_record] {
146 # Activate process record/replay
147 gdb_test_no_output "record" "turn on process record"
148 }
149
150 # Run until end, then save execution log.
151
152 set breakloc [gdb_get_line_number "end of main" "$srcfile"]
153 gdb_test "break $breakloc" \
154 "Breakpoint $decimal at .*$srcfile, line $breakloc\." \
155 "breakpoint at end of main"
156
157 # Signal handlers must be disabled
158 gdb_test "handle all nostop noprint"
159
160 # The list of signals that the program generates, in the order they
161 # are generated.
162 set signals {
163 ABRT
164 HUP
165 QUIT
166 ILL
167 EMT
168 FPE
169 BUS
170 SEGV
171 SYS
172 PIPE
173 ALRM
174 URG
175 TSTP
176 CONT
177 CHLD
178 TTIN
179 TTOU
180 IO
181 XCPU
182 XFSZ
183 VTALRM
184 PROF
185 WINCH
186 LOST
187 USR1
188 USR2
189 PWR
190 POLL
191 WIND
192 PHONE
193 WAITING
194 LWP
195 DANGER
196 GRANT
197 RETRACT
198 MSG
199 SOUND
200 SAK
201 PRIO
202 33
203 34
204 35
205 36
206 37
207 38
208 39
209 40
210 41
211 42
212 43
213 44
214 45
215 46
216 47
217 48
218 49
219 50
220 51
221 52
222 53
223 54
224 55
225 56
226 57
227 58
228 59
229 60
230 61
231 62
232 63
233 TERM
234 }
235
236 # Software single-step targets can't step into signal handlers. Since
237 # later, when replaying the execution log, the test wants to set
238 # breakpoints on handlers, we need to make sure that while recording,
239 # GDB steps through the handlers too, so that the execution log covers
240 # them. Setting breakpoints in all handlers takes care of it. This
241 # is harmless for hardware-step targets.
242 foreach sig $signals {
243 set test "break *handle_$sig"
244 gdb_test_multiple $test $test {
245 -re "Breakpoint .*$gdb_prompt $" {
246 # No need to record a pass for each breakpoint.
247 }
248 }
249 }
250
251 gdb_test_multiple "continue" "run to end of main" {
252 -wrap -re "Breakpoint .* end of main .*" {
253 pass $gdb_test_name
254 }
255 -wrap -re "Breakpoint .* handle_.*" {
256 send_gdb "continue\n"
257 exp_continue
258 }
259 -wrap -re "Process record does not support instruction 0xfae64 at.*" {
260 kfail "gdb/25038" $gdb_test_name
261 return -1
262 }
263 }
264
265 delete_breakpoints
266
267 gdb_test "record save $precsave" \
268 "Saved core file $precsave with execution log\." \
269 "save process recfile"
270
271 gdb_test "kill" "" "kill process, prepare to debug log file" \
272 "Kill the program being debugged\\? \\(y or n\\) " "y"
273
274 gdb_test "record restore $precsave" \
275 "Restored records from core file .*" \
276 "reload precord save file"
277
278 # Signal handlers must be re-enabled
279 gdb_test "handle all stop print"
280
281 # Make the first signal SIGABRT because it is always supported.
282 set sig_supported 1
283 set thissig "ABRT"
284
285 # test signal handling
286 with_test_prefix "sig-test-1" {
287 foreach sig [lrange $signals 1 end] {
288 test_one_sig $sig
289 }
290 }
291
292 # The last signal (SIGTERM) gets handled slightly differently because
293 # we are not setting up for another test.
294 gdb_test "handle SIGTERM stop print" \
295 "SIGTERM\[ \t\]*Yes\[ \t\]*Yes\[ \t\]*Yes.*"
296 gdb_test "b handle_TERM" "Breakpoint \[0-9\]+ .*"
297 gdb_test "continue" \
298 "Continuing.*Program received signal SIGTERM.*" \
299 "get signal TERM"
300 gdb_test "continue" "Breakpoint.*handle_TERM.*" "send signal TERM"
301
302 gdb_test "continue" " end of main .*" "continue to sigall exit"
303
304 foreach sig [lreverse $signals] {
305 test_one_sig_reverse $sig
306 }
307
308 # Make the first signal SIGABRT because it is always supported.
309 set sig_supported 1
310 set thissig "ABRT"
311
312 with_test_prefix "sig-test-2" {
313 foreach sig [lrange $signals 1 end] {
314 test_one_sig $sig
315 }
316 }