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