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