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