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