]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.reverse/sigall-reverse.exp
Update years in copyright notice for the GDB files.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.reverse / sigall-reverse.exp
CommitLineData
8acc9f48 1# Copyright 2009-2013 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
d3895d7d 21if ![supports_reverse] {
b43b923a
MS
22 return
23}
24
b43b923a
MS
25
26gdb_exit
27gdb_start
28gdb_reinitialize_dir $srcdir/$subdir
29
7686c074
TT
30standard_testfile
31
32if {[build_executable $testfile.exp $testfile $srcfile debug] == -1} {
33 return -1
b43b923a
MS
34}
35
b43b923a
MS
36proc test_one_sig {nextsig} {
37 global sig_supported
38 global gdb_prompt
39 global thissig
40
41 set this_sig_supported $sig_supported
42 gdb_test "handle SIG$thissig stop print" \
43 "SIG$thissig\[ \t\]*Yes\[ \t\]*Yes\[ \t\]*Yes.*"
44 gdb_test "b handle_$thissig" "Breakpoint \[0-9\]+ .*"
45 gdb_test "b gen_$nextsig" "Breakpoint \[0-9\]+ .*"
46
47 set need_another_continue 1
48 set missed_handler 0
49 if $this_sig_supported then {
50 if { $thissig == "IO" } {
51 setup_xfail "i*86-pc-linuxoldld-gnu" "i*86-pc-linuxaout-gnu"
52 }
53 set testmsg "get signal $thissig"
54 gdb_test_multiple "continue" $testmsg {
55 -re "Program received signal SIG$thissig.*handle_$thissig.*$gdb_prompt $" {
56 fail "$testmsg (wrong location)"
57 }
58 -re "Program received signal SIG$thissig.*$gdb_prompt $" {
59 pass $testmsg
60 }
61 -re "Breakpoint.* handle_$thissig.*$gdb_prompt $" {
62 xfail $testmsg
63 set need_another_continue 0
64 }
65 }
66 }
67 if [ istarget "alpha-dec-osf3*" ] then {
68 # OSF/1-3.x is unable to continue with a job control stop signal.
69 # The inferior remains stopped without an event of interest
70 # and GDB waits forever for the inferior to stop on an event
71 # of interest. Work around the kernel bug.
72 if { $thissig == "TSTP" || $thissig == "TTIN" || $thissig == "TTOU" } {
73 setup_xfail "alpha-dec-osf3*"
74 fail "cannot continue from signal $thissig"
75 set need_another_continue 0
76 }
77 }
78
79 if $need_another_continue then {
80 if { $thissig == "URG" } {
81 setup_xfail "i*86-pc-linuxoldld-gnu" "i*86-pc-linuxaout-gnu"
82 }
83 # Either Lynx or GDB screws up on SIGPRIO
84 if { $thissig == "PRIO" } {
85 setup_xfail "*-*-*lynx*"
86 }
87 set testmsg "send signal $thissig"
88 gdb_test_multiple "continue" $testmsg {
89 -re "Breakpoint.*handle_$thissig.*$gdb_prompt $" {
90 pass $testmsg
91 }
92 -re "Breakpoint.*gen_$nextsig.*kill.*$gdb_prompt $" {
93 fail "missed breakpoint at handle_$thissig"
94 set missed_handler 1
95 }
96 }
97 }
98
99 if { $missed_handler == "0" } then {
100 set testmsg "advance to $nextsig"
101 gdb_test_multiple "signal 0" $testmsg {
102 -re "Breakpoint.*gen_$nextsig.*kill.*$gdb_prompt $" {
103 pass $testmsg
104 set sig_supported 1
105 }
106 -re "Breakpoint.*gen_$nextsig.*handle.*$gdb_prompt $" {
107 pass $testmsg
108 set sig_supported 0
109 }
110 }
111 }
112 set thissig $nextsig
113}
114
115proc test_one_sig_reverse {prevsig} {
116 global gdb_prompt
117
118 gdb_test "reverse-continue" "Breakpoint .* handle_$prevsig.*" \
119 "reverse to handler of $prevsig"
120
121 set saw_signal 0
122 set testmsg "reverse to gen_$prevsig"
123 gdb_test_multiple "reverse-continue" $testmsg {
124 -re "Breakpoint.*handle_.*$gdb_prompt " {
125 pass "$testmsg (un-handled)"
126 }
127 -re "Program received signal SIG$prevsig.*$gdb_prompt " {
128 pass "reverse to signal event, $prevsig"
129
130 set nested_testmsg "reverse signal delivered"
131 gdb_test_multiple "frame" $nested_testmsg {
132 -re ".*handle_$prevsig.*$gdb_prompt " {
133 fail "$nested_testmsg (wrong location)"
134 }
135 -re ".*$gdb_prompt " {
136 pass $nested_testmsg
137 }
138 }
139
140 set saw_signal 1
141 send_gdb "reverse-continue\n"
142 exp_continue
143 }
144 -re "Breakpoint.*kill.*$gdb_prompt " {
145 if { $saw_signal } then {
146 pass "$testmsg (handled)"
147 } else {
148 xfail "$testmsg (handled)"
149 }
150 }
151 -re "No more reverse-execution history.*kill.*$gdb_prompt " {
152 if { $saw_signal } then {
153 pass "$testmsg (handled)"
154 } else {
155 xfail "$testmsg (handled)"
156 }
157 }
158 }
159}
160
161gdb_load $binfile
162
163runto gen_ABRT
164
d3895d7d 165if [supports_process_record] {
b43b923a 166 # Activate process record/replay
bcd2dc50 167 gdb_test_no_output "record" "Turn on process record"
b43b923a
MS
168}
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
246# Make the first signal SIGABRT because it is always supported.
247set sig_supported 1
248set thissig "ABRT"
249
250# test signal handling
13e4e967 251foreach sig [lrange $signals 1 end] {
b1e0c0fa
PA
252 test_one_sig $sig
253}
b43b923a
MS
254
255# The last signal (SIGTERM) gets handled slightly differently because
256# we are not setting up for another test.
257gdb_test "handle SIGTERM stop print" \
258 "SIGTERM\[ \t\]*Yes\[ \t\]*Yes\[ \t\]*Yes.*"
259gdb_test "b handle_TERM" "Breakpoint \[0-9\]+ .*"
260gdb_test "continue" \
261 "Continuing.*Program received signal SIGTERM.*" \
262 "get signal TERM"
263gdb_test "continue" "Breakpoint.*handle_TERM.*" "send signal TERM"
264
e6a386cd 265gdb_test "continue" "\[process \[0-9\]+ .*" "continue to sigal exit" \
4cf866a3
MS
266 "The next instruction is syscall exit_group.* program...y. or n. " \
267 "yes"
b43b923a 268
b1e0c0fa
PA
269foreach sig [lreverse $signals] {
270 test_one_sig_reverse $sig
271}
b43b923a
MS
272
273# Make the first signal SIGABRT because it is always supported.
274set sig_supported 1
275set thissig "ABRT"
276
13e4e967 277foreach sig [lrange $signals 1 end] {
b1e0c0fa
PA
278 test_one_sig $sig
279}