]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.reverse/sigall-reverse.exp
Use require supports_reverse
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.reverse / sigall-reverse.exp
CommitLineData
213516ef 1# Copyright 2009-2023 Free Software Foundation, Inc.
b43b923a
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] {
17 verbose "Skipping sigall-reverse.exp because of nosignals."
18 return
19}
20
5954db83 21require supports_reverse
b43b923a
MS
22
23gdb_exit
24gdb_start
25gdb_reinitialize_dir $srcdir/$subdir
26
7686c074
TT
27standard_testfile
28
29if {[build_executable $testfile.exp $testfile $srcfile debug] == -1} {
30 return -1
b43b923a
MS
31}
32
b43b923a
MS
33proc test_one_sig {nextsig} {
34 global sig_supported
35 global gdb_prompt
36 global thissig
d6e76313 37 global record_instruction_kfail
b43b923a
MS
38
39 set this_sig_supported $sig_supported
40 gdb_test "handle SIG$thissig stop print" \
41 "SIG$thissig\[ \t\]*Yes\[ \t\]*Yes\[ \t\]*Yes.*"
42 gdb_test "b handle_$thissig" "Breakpoint \[0-9\]+ .*"
43 gdb_test "b gen_$nextsig" "Breakpoint \[0-9\]+ .*"
44
45 set need_another_continue 1
46 set missed_handler 0
bde43e8d 47 if {$this_sig_supported} {
b43b923a
MS
48 if { $thissig == "IO" } {
49 setup_xfail "i*86-pc-linuxoldld-gnu" "i*86-pc-linuxaout-gnu"
50 }
158da0d1
TV
51 gdb_test_multiple "continue" "get signal $thissig" {
52 -wrap -re \
53 "Program received signal SIG$thissig.*handle_$thissig.*" {
54 fail "$gdb_test_name (wrong location)"
b43b923a 55 }
158da0d1
TV
56 -wrap -re "Program received signal SIG$thissig.*" {
57 pass $gdb_test_name
b43b923a 58 }
158da0d1
TV
59 -wrap -re "Breakpoint.* handle_$thissig.*" {
60 xfail $gdb_test_name
b43b923a
MS
61 set need_another_continue 0
62 }
158da0d1
TV
63 -wrap -re \
64 "Process record does not support instruction 0xfae64 at.*" {
65 kfail "gdb/25038" $gdb_test_name
d6e76313
TV
66 set record_instruction_kfail 1
67 return
68 }
b43b923a
MS
69 }
70 }
b43b923a 71
bde43e8d 72 if {$need_another_continue} {
b43b923a
MS
73 if { $thissig == "URG" } {
74 setup_xfail "i*86-pc-linuxoldld-gnu" "i*86-pc-linuxaout-gnu"
75 }
76 # Either Lynx or GDB screws up on SIGPRIO
77 if { $thissig == "PRIO" } {
78 setup_xfail "*-*-*lynx*"
79 }
80 set testmsg "send signal $thissig"
81 gdb_test_multiple "continue" $testmsg {
82 -re "Breakpoint.*handle_$thissig.*$gdb_prompt $" {
83 pass $testmsg
84 }
85 -re "Breakpoint.*gen_$nextsig.*kill.*$gdb_prompt $" {
86 fail "missed breakpoint at handle_$thissig"
87 set missed_handler 1
88 }
89 }
90 }
91
bde43e8d 92 if {$missed_handler == "0"} {
b43b923a
MS
93 set testmsg "advance to $nextsig"
94 gdb_test_multiple "signal 0" $testmsg {
95 -re "Breakpoint.*gen_$nextsig.*kill.*$gdb_prompt $" {
96 pass $testmsg
97 set sig_supported 1
98 }
99 -re "Breakpoint.*gen_$nextsig.*handle.*$gdb_prompt $" {
100 pass $testmsg
101 set sig_supported 0
102 }
103 }
104 }
105 set thissig $nextsig
106}
107
108proc test_one_sig_reverse {prevsig} {
109 global gdb_prompt
110
111 gdb_test "reverse-continue" "Breakpoint .* handle_$prevsig.*" \
112 "reverse to handler of $prevsig"
113
114 set saw_signal 0
115 set testmsg "reverse to gen_$prevsig"
116 gdb_test_multiple "reverse-continue" $testmsg {
117 -re "Breakpoint.*handle_.*$gdb_prompt " {
118 pass "$testmsg (un-handled)"
119 }
120 -re "Program received signal SIG$prevsig.*$gdb_prompt " {
121 pass "reverse to signal event, $prevsig"
122
4d421147 123 set nested_testmsg "reverse signal $prevsig delivered"
b43b923a
MS
124 gdb_test_multiple "frame" $nested_testmsg {
125 -re ".*handle_$prevsig.*$gdb_prompt " {
126 fail "$nested_testmsg (wrong location)"
127 }
128 -re ".*$gdb_prompt " {
129 pass $nested_testmsg
130 }
131 }
132
133 set saw_signal 1
134 send_gdb "reverse-continue\n"
135 exp_continue
136 }
137 -re "Breakpoint.*kill.*$gdb_prompt " {
bde43e8d 138 if {$saw_signal} {
b43b923a
MS
139 pass "$testmsg (handled)"
140 } else {
141 xfail "$testmsg (handled)"
142 }
143 }
144 -re "No more reverse-execution history.*kill.*$gdb_prompt " {
bde43e8d 145 if {$saw_signal} {
b43b923a
MS
146 pass "$testmsg (handled)"
147 } else {
148 xfail "$testmsg (handled)"
149 }
150 }
151 }
152}
153
154gdb_load $binfile
155
156runto gen_ABRT
157
d3895d7d 158if [supports_process_record] {
b43b923a 159 # Activate process record/replay
9f058c10 160 gdb_test_no_output "record" "turn on process record"
b43b923a
MS
161}
162
b1e0c0fa
PA
163# The list of signals that the program generates, in the order they
164# are generated.
165set signals {
166 ABRT
167 HUP
168 QUIT
169 ILL
170 EMT
171 FPE
172 BUS
173 SEGV
174 SYS
175 PIPE
176 ALRM
177 URG
178 TSTP
179 CONT
180 CHLD
181 TTIN
182 TTOU
183 IO
184 XCPU
185 XFSZ
186 VTALRM
187 PROF
188 WINCH
189 LOST
190 USR1
191 USR2
192 PWR
193 POLL
194 WIND
195 PHONE
196 WAITING
197 LWP
198 DANGER
199 GRANT
200 RETRACT
201 MSG
202 SOUND
203 SAK
204 PRIO
205 33
206 34
207 35
208 36
209 37
210 38
211 39
212 40
213 41
214 42
215 43
216 44
217 45
218 46
219 47
220 48
221 49
222 50
223 51
224 52
225 53
226 54
227 55
228 56
229 57
230 58
231 59
232 60
233 61
234 62
235 63
236 TERM
237}
238
239# Make the first signal SIGABRT because it is always supported.
240set sig_supported 1
241set thissig "ABRT"
242
243# test signal handling
4d421147 244with_test_prefix "sig-test-1" {
d6e76313 245 set record_instruction_kfail 0
4d421147
AB
246 foreach sig [lrange $signals 1 end] {
247 test_one_sig $sig
d6e76313
TV
248 if { $record_instruction_kfail } {
249 return -1
250 }
4d421147 251 }
b1e0c0fa 252}
b43b923a
MS
253
254# The last signal (SIGTERM) gets handled slightly differently because
255# we are not setting up for another test.
256gdb_test "handle SIGTERM stop print" \
257 "SIGTERM\[ \t\]*Yes\[ \t\]*Yes\[ \t\]*Yes.*"
258gdb_test "b handle_TERM" "Breakpoint \[0-9\]+ .*"
259gdb_test "continue" \
260 "Continuing.*Program received signal SIGTERM.*" \
261 "get signal TERM"
262gdb_test "continue" "Breakpoint.*handle_TERM.*" "send signal TERM"
263
45fd756c
YQ
264with_timeout_factor 2 {
265 gdb_test "continue" "\[process \[0-9\]+ .*" "continue to signal exit" \
266 "The next instruction is syscall exit_group.* program...y. or n. " \
267 "yes"
7b415901 268}
b43b923a 269
b1e0c0fa
PA
270foreach sig [lreverse $signals] {
271 test_one_sig_reverse $sig
272}
b43b923a
MS
273
274# Make the first signal SIGABRT because it is always supported.
275set sig_supported 1
276set thissig "ABRT"
277
4d421147
AB
278with_test_prefix "sig-test-2" {
279 foreach sig [lrange $signals 1 end] {
280 test_one_sig $sig
281 }
b1e0c0fa 282}