]>
Commit | Line | Data |
---|---|---|
c906108c SS |
1 | # Copyright (C) 1997, 1998 Free Software Foundation, Inc. |
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 2 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, write to the Free Software | |
15 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
16 | ||
17 | # Please email any bugs, comments, and/or additions to this file to: | |
18 | # [email protected] | |
19 | ||
20 | if [target_info exists gdb,nosignals] { | |
21 | verbose "Skipping signals.exp because of nosignals." | |
22 | continue | |
23 | } | |
24 | ||
25 | if $tracelevel then { | |
26 | strace $tracelevel | |
27 | } | |
28 | ||
29 | set prms_id 0 | |
30 | set bug_id 0 | |
31 | ||
32 | set testfile signals | |
33 | set srcfile ${testfile}.c | |
34 | set binfile ${objdir}/${subdir}/${testfile} | |
35 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { | |
36 | gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." | |
37 | } | |
38 | ||
39 | # Create and source the file that provides information about the compiler | |
40 | # used to compile the test case. | |
41 | if [get_compiler_info ${binfile}] { | |
42 | return -1; | |
43 | } | |
44 | ||
45 | proc signal_tests_1 {} { | |
46 | global gdb_prompt | |
47 | if [runto_main] then { | |
48 | gdb_test "next" "signal \\(SIGUSR1.*" \ | |
49 | "next over signal (SIGALRM, handler)" | |
50 | gdb_test "next" "alarm \\(.*" \ | |
51 | "next over signal (SIGUSR1, handler)" | |
52 | gdb_test "next" "\\+\\+count; /\\* first \\*/" \ | |
53 | "next over alarm (1)" | |
54 | # An alarm has been signaled, give the signal time to get delivered. | |
55 | sleep 2 | |
56 | ||
57 | # i386 BSD currently fails the next test with a SIGTRAP. | |
58 | setup_xfail "i*86-*-bsd*" | |
59 | # But Dynix has a DECR_PC_AFTER_BREAK of zero, so the failure | |
60 | # is shadowed by hitting the through_sigtramp_breakpoint. | |
61 | clear_xfail "i*86-sequent-bsd*" | |
62 | # Univel SVR4 i386 continues instead of stepping. | |
63 | setup_xfail "i*86-univel-sysv4*" | |
64 | # lynx fails with "next" acting like "continue" | |
65 | setup_xfail "*-*-*lynx*" | |
66 | # linux (aout versions) also fails with "next" acting like "continue" | |
67 | # this is probably more dependant on the kernel version than on the | |
68 | # object file format or utils. (sigh) | |
69 | setup_xfail "i*86-pc-linuxaout-gnu" "i*86-pc-linuxoldld-gnu" | |
70 | send_gdb "next\n" | |
71 | gdb_expect { | |
72 | -re "alarm .*$gdb_prompt $" { pass "next to 2nd alarm (1)" } | |
73 | -re "Program received signal SIGTRAP.*first.*$gdb_prompt $" { | |
74 | ||
75 | # This can happen on machines that have a trace flag | |
76 | # in their PS register. | |
77 | # The trace flag in the PS register will be set due to | |
78 | # the `next' command. | |
79 | # Before calling the signal handler, the PS register | |
80 | # is pushed along with the context on the user stack. | |
81 | # When the signal handler has finished, it reenters the | |
82 | # the kernel via a sigreturn syscall, which restores the | |
83 | # PS register along with the context. | |
84 | # If the kernel erroneously does not clear the trace flag | |
85 | # in the pushed context, gdb will receive a SIGTRAP from | |
86 | # the set trace flag in the restored context after the | |
87 | # signal handler has finished. | |
88 | ||
89 | # I do not yet understand why the SIGTRAP does not occur | |
90 | # after stepping the instruction at the restored PC on | |
91 | # i386 BSDI 1.0 systems. | |
92 | ||
93 | # Note that the vax under Ultrix also exhibits | |
94 | # this behaviour (it is uncovered by the `continue from | |
95 | # a break in a signal handler' test below). | |
96 | # With this test the failure is shadowed by hitting the | |
97 | # through_sigtramp_breakpoint upon return from the signal | |
98 | # handler. | |
99 | ||
100 | # SVR4 and Linux based i*86 systems exhibit this behaviour | |
101 | # as well (it is uncovered by the `continue from a break | |
102 | # in a signal handler' test below). | |
103 | # As these systems use procfs, where we tell the kernel not | |
104 | # to tell gdb about `pass' signals, and the trace flag is | |
105 | # cleared by the kernel before entering the sigtramp | |
106 | # routine, GDB will not notice the execution of the signal | |
107 | # handler. | |
108 | # Upon return from the signal handler, GDB will receive | |
109 | # a SIGTRAP from the set trace flag in the restored context. | |
110 | # The SIGTRAP marks the end of a (albeit long winded) | |
111 | # single step for GDB, causing this test to pass. | |
112 | ||
113 | fail "next to 2nd alarm (1) (probably kernel bug)" | |
114 | gdb_test "next" "alarm.*" "next to 2nd alarm (1)" | |
115 | } | |
116 | -re "Program exited with code.*$gdb_prompt $" { | |
117 | ||
118 | # This is apparently a bug in the UnixWare kernel (but | |
119 | # has not been investigated beyond the | |
120 | # resume/target_wait level, and has not been reported | |
121 | # to Univel). If it steps when a signal is pending, | |
122 | # it does a continue instead. I don't know whether | |
123 | # there is a workaround. | |
124 | ||
125 | # Perhaps this problem exists on other SVR4 systems; | |
126 | # but (a) we have no reason to think so, and (b) if we | |
127 | # put a wrong xfail here, we never get an XPASS to let | |
128 | # us know that it was incorrect (and then if such a | |
129 | # configuration regresses we have no way of knowing). | |
130 | # Solaris is not a relevant data point either way | |
131 | # because it lacks single stepping. | |
132 | ||
133 | # fnf: I don't agree with the above philosophy. We | |
134 | # can never be sure that any particular XFAIL is | |
135 | # specified 100% correctly in that no systems with | |
136 | # the bug are missed and all systems without the bug | |
137 | # are excluded. If we include an XFAIL that isn't | |
138 | # appropriate for a particular system, then when that | |
139 | # system gets tested it will XPASS, and someone should | |
140 | # investigate and fix the setup_xfail as appropriate, | |
141 | # or more preferably, the actual bug. Each such case | |
142 | # adds more data to narrowing down the scope of the | |
143 | # problem and ultimately fixing it. | |
144 | ||
145 | setup_xfail "i*86-*-sysv4*" | |
146 | fail "'next' behaved as 'continue (known SVR4 bug)'" | |
147 | return 0 | |
148 | } | |
149 | -re ".*$gdb_prompt $" { fail "next to 2nd alarm (1)" } | |
150 | timeout { fail "next to 2nd alarm (1); (timeout)" } | |
151 | eof { fail "next to 2nd alarm (1); (eof)" } | |
152 | } | |
153 | ||
154 | gdb_test "break handler" "Breakpoint \[0-9\]+ .*" | |
155 | gdb_test "next" "\\+\\+count; /\\* second \\*/" \ | |
156 | "next to 2nd ++count in signals_tests_1" | |
157 | # An alarm has been signaled, give the signal time to get delivered. | |
158 | sleep 2 | |
159 | ||
160 | set bash_bug 0 | |
161 | send_gdb "next\n" | |
162 | gdb_expect { | |
163 | -re "Breakpoint.*handler.*$gdb_prompt $" { | |
164 | pass "next to handler in signals_tests_1" | |
165 | } | |
166 | -re "Program received signal SIGEMT.*$gdb_prompt $" { | |
167 | # Bash versions before 1.13.5 cause this behaviour | |
168 | # by blocking SIGTRAP. | |
169 | fail "next to handler in signals_tests_1 (known problem with bash versions before 1.13.5)" | |
170 | set bash_bug 1 | |
171 | gdb_test "signal 0" "Breakpoint.*handler.*" | |
172 | } | |
173 | -re ".*$gdb_prompt $" { fail "next to handler in signals_tests_1" } | |
174 | timeout { fail "next to handler in signals_tests_1 (timeout)" } | |
175 | eof { fail "next to handler in signals_tests_1 (eof)" } | |
176 | } | |
177 | ||
178 | # This doesn't test that main is frame #2, just that main is frame | |
179 | # #2, #3, or higher. At some point this should be fixed (but | |
180 | # it quite possibly would introduce new FAILs on some systems). | |
181 | setup_xfail "i*86-pc-linux-gnu*" "i*86-*-bsdi2.0" | |
182 | gdb_test "backtrace 10" "#0.*handler.*#1.*#2.*main.*" \ | |
183 | "backtrace in signals_tests_1" | |
184 | ||
185 | gdb_test "break func1" "Breakpoint \[0-9\]+ .*" | |
186 | gdb_test "break func2" "Breakpoint \[0-9\]+ .*" | |
187 | ||
188 | # Vax Ultrix and i386 BSD currently fail the next test with | |
189 | # a SIGTRAP, but with different symptoms. | |
190 | setup_xfail "vax-*-ultrix*" | |
191 | setup_xfail "i*86-*-bsd*" | |
192 | setup_xfail "i*86-pc-linux-gnu*" | |
193 | setup_xfail "i*86-*-solaris2*" | |
194 | send_gdb "continue\n" | |
195 | gdb_expect { | |
196 | -re "Breakpoint.*func1.*$gdb_prompt $" { pass "continue to func1" } | |
197 | -re "Program received signal SIGTRAP.*second.*$gdb_prompt $" { | |
198 | ||
199 | # See explanation for `next to 2nd alarm (1)' fail above. | |
200 | # We did step into the signal handler, hit a breakpoint | |
201 | # in the handler and continued from the breakpoint. | |
202 | # The set trace flag in the restored context is causing | |
203 | # the SIGTRAP, without stepping an instruction. | |
204 | ||
205 | fail "continue to func1 (probably kernel bug)" | |
206 | gdb_test "continue" "Breakpoint.*func1.*" \ | |
207 | "extra continue to func1" | |
208 | } | |
209 | -re "Program received signal SIGTRAP.*func1 ..;.*$gdb_prompt $" { | |
210 | ||
211 | # On the vax under Ultrix the set trace flag in the restored | |
212 | # context is causing the SIGTRAP, but after stepping one | |
213 | # instruction, as expected. | |
214 | ||
215 | fail "continue to func1 (probably kernel bug)" | |
216 | gdb_test "continue" "Breakpoint.*func1.*" \ | |
217 | "extra continue to func1" | |
218 | } | |
219 | -re ".*$gdb_prompt $" { fail "continue to func1" } | |
220 | default { fail "continue to func1" } | |
221 | } | |
222 | ||
223 | setup_xfail "*-*-irix*" | |
224 | send_gdb "signal SIGUSR1\n" | |
225 | gdb_expect { | |
226 | -re "Breakpoint.*handler.*$gdb_prompt $" { pass "signal SIGUSR1" } | |
227 | -re "Program received signal SIGUSR1.*$gdb_prompt $" { | |
228 | # This is what irix4 and irix5 do. | |
229 | # It would appear to be a kernel bug. | |
230 | fail "signal SIGUSR1" | |
231 | gdb_test "continue" "Breakpoint.*handler.*" "pass it SIGUSR1" | |
232 | } | |
233 | -re ".*$gdb_prompt $" { fail "signal SIGUSR1" } | |
234 | default { fail "signal SIGUSR1" } | |
235 | } | |
236 | ||
237 | # Will tend to wrongly require an extra continue. | |
238 | ||
239 | # The problem here is that the breakpoint at func1 will be | |
240 | # inserted, and when the system finishes with the signal | |
241 | # handler it will try to execute there. For GDB to try to | |
242 | # remember that it was going to step over a breakpoint when a | |
243 | # signal happened, distinguish this case from the case where | |
244 | # func1 is called from the signal handler, etc., seems | |
245 | # exceedingly difficult. So don't expect this to get fixed | |
246 | # anytime soon. | |
247 | ||
248 | setup_xfail "*-*-*" | |
249 | send_gdb "continue\n" | |
250 | gdb_expect { | |
251 | -re "Breakpoint.*func2.*$gdb_prompt $" { pass "continue to func2" } | |
252 | -re "Breakpoint.*func1.*$gdb_prompt $" { | |
253 | fail "continue to func2" | |
254 | gdb_test "continue" "Breakpoint.*func2.*" \ | |
255 | "extra continue to func2" | |
256 | } | |
257 | -re ".*$gdb_prompt $" { fail "continue to func2" } | |
258 | default { fail "continue to func2" } | |
259 | } | |
260 | ||
261 | sleep 2 | |
262 | ||
263 | # GDB yanks out the breakpoints to step over the breakpoint it | |
264 | # stopped at, which means the breakpoint at handler is yanked. | |
265 | # But if SOFTWARE_SINGLE_STEP_P, we won't get another chance to | |
266 | # reinsert them (at least not with procfs, where we tell the kernel | |
267 | # not to tell gdb about `pass' signals). So the fix would appear to | |
268 | # be to just yank that one breakpoint when we step over it. | |
269 | ||
270 | setup_xfail "sparc*-*-*" | |
271 | setup_xfail "rs6000-*-*" | |
272 | setup_xfail "powerpc-*-*" | |
273 | ||
274 | # A faulty bash will not step the inferior into sigtramp on sun3. | |
275 | if {$bash_bug} then { | |
276 | setup_xfail "m68*-*-sunos4*" | |
277 | } | |
278 | ||
279 | setup_xfail "i*86-pc-linux-gnu*" | |
280 | setup_xfail "i*86-*-solaris2*" | |
281 | gdb_test "continue" "Breakpoint.*handler.*" "continue to handler" | |
282 | ||
283 | # If the SOFTWARE_SINGLE_STEP_P failure happened, we have already | |
284 | # exited. | |
285 | # If we succeeded a continue will return from the handler to func2. | |
286 | # GDB now has `forgotten' that it intended to step over the | |
287 | # breakpoint at func2 and will stop at func2. | |
288 | setup_xfail "*-*-*" | |
289 | # The sun3 with a faulty bash will also be `forgetful' but it | |
290 | # already got the spurious stop at func2 and this continue will work. | |
291 | if {$bash_bug} then { | |
292 | clear_xfail "m68*-*-sunos4*" | |
293 | } | |
294 | gdb_test "continue" "Program exited with code 010\\." \ | |
295 | "continue to exit in signals_tests_1 " | |
296 | } | |
297 | } | |
298 | ||
299 | # On a few losing systems, ptrace (PT_CONTINUE) or ptrace (PT_STEP) | |
300 | # causes pending signals to be cleared, which causes these tests to | |
301 | # get nowhere fast. This is totally losing behavior (perhaps there | |
302 | # are cases in which is it useful but the user needs more control, | |
303 | # which they mostly have in GDB), but some people apparently think it | |
304 | # is a feature. It is documented in the ptrace manpage on Motorola | |
305 | # Delta Series sysV68 R3V7.1 and on HPUX 9.0. Even the non-HPUX PA | |
306 | # OSes (BSD and OSF/1) seem to have figured they had to copy this | |
307 | # braindamage. | |
308 | ||
309 | if {[ istarget "m68*-motorola-*" ] || [ istarget "hppa*-*-bsd*" ] || | |
310 | [ istarget "hppa*-*-osf*" ]} then { | |
311 | setup_xfail "*-*-*" | |
312 | fail "ptrace loses on signals on this target" | |
313 | return 0 | |
314 | } | |
315 | ||
316 | # lynx2.2.2 doesn't lose signals, instead it screws up the stack pointer | |
317 | # in some of these tests leading to massive problems. I've | |
318 | # reported this to lynx, hopefully it'll be fixed in lynx2.3. | |
319 | # Severe braindamage. | |
320 | if [ istarget "*-*-*lynx*" ] then { | |
321 | setup_xfail "*-*-*" | |
322 | fail "kernel scroggs stack pointer in signal tests on this target" | |
323 | return 0 | |
324 | } | |
325 | ||
326 | gdb_exit | |
327 | gdb_start | |
328 | ||
329 | # This will need to be updated as the exact list of signals changes, | |
330 | # but I want to test that TARGET_SIGNAL_0, TARGET_SIGNAL_DEFAULT, and | |
331 | # TARGET_SIGNAL_UNKNOWN are skipped. | |
332 | proc test_handle_all_print {} { | |
333 | global timeout | |
334 | # Increase timeout and expect input buffer for large output from gdb. | |
335 | # Allow blank or TAB as whitespace characters. | |
336 | set oldtimeout $timeout | |
337 | set timeout [expr "$timeout + 360"] | |
338 | verbose "Timeout is now $timeout seconds" 2 | |
7a292a7a SS |
339 | if { ![istarget "*-*-linux*"] |
340 | && ( [istarget "*-*-gnu*"] | |
341 | || [istarget "*-*-mach*"] ) } { | |
c906108c SS |
342 | gdb_test "handle all print" "Signal\[ \]+Stop\[ \]+Print\[ \]+Pass to program\[ \]+Description\r\nSIGHUP\[ \]+Yes\[ \]+Yes\[ \]+Yes\[ \]+Hangup.*SIG63\[ \]+Yes\[ \]+Yes\[ \]+Yes\[ \]+Real-time event 63.*EXC_BREAKPOINT\[ \]+Yes\[ \]+Yes\[ \]+Yes\[ \]+Breakpoint" |
343 | } else { | |
344 | gdb_test "handle all print" "Signal\[ \]+Stop\[ \]+Print\[ \]+Pass to program\[ \]+Description\r\nSIGHUP\[ \]+Yes\[ \]+Yes\[ \]+Yes\[ \]+Hangup.*SIG63\[ \]+Yes\[ \]+Yes\[ \]+Yes\[ \]+Real-time event 63" | |
345 | } | |
346 | set timeout $oldtimeout | |
347 | verbose "Timeout restored to $timeout seconds" 2 | |
348 | } | |
349 | test_handle_all_print | |
350 | ||
351 | gdb_exit | |
352 | gdb_start | |
353 | gdb_reinitialize_dir $srcdir/$subdir | |
354 | gdb_load $binfile | |
355 | signal_tests_1 | |
356 | ||
357 | # Force a resync, so we're looking at the right prompt. On SCO we | |
358 | # were getting out of sync (I don't understand why). | |
359 | send_gdb "p 1+1\n" | |
360 | gdb_expect { | |
361 | -re "= 2.*$gdb_prompt $" {} | |
362 | -re ".*$gdb_prompt $" { perror "sync trouble in signals.exp" } | |
363 | default { perror "sync trouble in signals.exp" } | |
364 | } | |
365 | ||
366 | if [runto_main] then { | |
367 | gdb_test "break handler if 0" "Breakpoint \[0-9\]+ .*" | |
368 | gdb_test "set \$handler_breakpoint_number = \$bpnum" "" | |
369 | ||
370 | # Get to the point where a signal is waiting to be delivered | |
371 | gdb_test "next" "signal \\(SIGUSR1.*" "next to signal in signals.exp" | |
372 | gdb_test "next" "alarm \\(.*" "next to alarm #1 in signals.exp" | |
373 | gdb_test "next" "\\+\\+count; /\\* first \\*/" \ | |
374 | "next to ++count #1 in signals.exp" | |
375 | # Give the signal time to get delivered | |
376 | sleep 2 | |
377 | ||
378 | # Now call a function. When GDB tries to run the stack dummy, | |
379 | # it will hit the breakpoint at handler. Provided it doesn't | |
380 | # lose its cool, this is not a problem, it just has to note | |
381 | # that the breakpoint condition is false and keep going. | |
382 | ||
383 | gdb_test "p func1 ()" "^p func1 \\(\\)\r\n.\[0-9\]* = void" \ | |
384 | "p func1 () #1 in signals.exp" | |
385 | ||
386 | # Make sure the count got incremented. | |
387 | ||
388 | # Haven't investigated this xfail | |
389 | setup_xfail "rs6000-*-*" | |
390 | setup_xfail "powerpc-*-*" | |
391 | gdb_test "p count" "= 2" "p count #1 in signals.exp" | |
392 | if { [istarget "rs6000-*-*"] || [istarget "powerpc-*-*"] } { return 0 } | |
393 | ||
394 | gdb_test "condition \$handler_breakpoint_number" "now unconditional\\." | |
395 | gdb_test "next" "alarm \\(.*" "next to alarm #2 in signals.exp" | |
396 | gdb_test "next" "\\+\\+count; /\\* second \\*/" \ | |
397 | "next to ++count #2 in signals.exp" | |
398 | sleep 2 | |
399 | ||
400 | # This time we stop when GDB tries to run the stack dummy. | |
401 | # So it is OK that we do not print the return value from the function. | |
402 | gdb_test "p func1 ()" \ | |
403 | "Breakpoint \[0-9\]*, handler.* | |
404 | The program being debugged stopped while in a function called from GDB.*" \ | |
405 | "p func1 () #2 in signals.exp" | |
406 | # But we should be able to backtrace... | |
407 | # On alpha-*-osf2.0 this test works when run manually but sometime fails when | |
408 | # run under dejagnu, making it very hard to debug the problem. Weird... | |
409 | gdb_test "bt 10" "#0.*handler.*#1.*#2.*main.*" "bt in signals.exp" | |
410 | # ...and continue... | |
411 | gdb_test "continue" "Continuing\\." "continue in signals.exp" | |
412 | # ...and then count should have been incremented | |
413 | gdb_test "p count" "= 5" "p count #2 in signals.exp" | |
414 | ||
415 | ||
416 | # Verify that "info signals" produces reasonable output. | |
417 | # | |
418 | send_gdb "info signals\n" | |
419 | gdb_expect { | |
420 | -re "SIGHUP.*SIGINT.*SIGQUIT.*SIGILL.*SIGTRAP.*SIGABRT.*SIGEMT.*SIGFPE.*SIGKILL.*SIGBUS.*SIGSEGV.*SIGSYS.*SIGPIPE.*SIGALRM.*SIGTERM.*SIGURG.*SIGSTOP.*SIGTSTP.*SIGCONT.*SIGCHLD.*SIGTTIN.*SIGTTOU.*SIGIO.*SIGXCPU.*SIGXFSZ.*SIGVTALRM.*SIGPROF.*SIGWINCH.*SIGLOST.*SIGUSR1.*SIGUSR2.*SIGPWR.*SIGPOLL.*SIGWIND.*SIGPHONE.*SIGWAITING.*SIGLWP.*SIGDANGER.*SIGGRANT.*SIGRETRACT.*SIGMSG.*SIGSOUND.*SIGSAK.*SIGPRIO.*SIG33.*SIG34.*SIG35.*SIG36.*SIG37.*SIG38.*SIG39.*SIG40.*SIG41.*SIG42.*SIG43.*SIG44.*SIG45.*SIG46.*SIG47.*SIG48.*SIG49.*SIG50.*SIG51.*SIG52.*SIG53.*SIG54.*SIG55.*SIG56.*SIG57.*SIG58.*SIG59.*SIG60.*SIG61.*SIG62.*SIG63.*Use the \"handle\" command to change these tables.*$gdb_prompt $"\ | |
421 | {pass "info signals"} | |
422 | -re "$gdb_prompt $"\ | |
423 | {fail "info signals"} | |
424 | timeout {fail "(timeout) info signals"} | |
425 | } | |
426 | ||
427 | # Verify that "info signal" correctly handles an argument, be it a | |
428 | # symbolic signal name, or an integer ID. | |
429 | # | |
430 | send_gdb "info signal SIGTRAP\n" | |
431 | gdb_expect { | |
432 | -re ".*SIGTRAP\[ \t\]*Yes\[ \t\]*Yes\[ \t\]*No\[ \t\]*Trace/breakpoint trap.*$gdb_prompt $"\ | |
433 | {pass "info signal SIGTRAP"} | |
434 | -re "$gdb_prompt $"\ | |
435 | {fail "info signal SIGTRAP"} | |
436 | timeout {fail "(timeout) info signal SIGTRAP"} | |
437 | } | |
438 | ||
439 | send_gdb "info signal 5\n" | |
440 | gdb_expect { | |
441 | -re ".*SIGTRAP\[ \t\]*Yes\[ \t\]*Yes\[ \t\]*No\[ \t\]*Trace/breakpoint trap.*$gdb_prompt $"\ | |
442 | {pass "info signal 5"} | |
443 | -re "$gdb_prompt $"\ | |
444 | {fail "info signal 5"} | |
445 | timeout {fail "(timeout) info signal 5"} | |
446 | } | |
447 | ||
448 | # Verify that "handle" with illegal arguments is gracefully, um, handled. | |
449 | # | |
450 | send_gdb "handle\n" | |
451 | gdb_expect { | |
452 | -re "Argument required .signal to handle.*$gdb_prompt $"\ | |
453 | {pass "handle without arguments"} | |
454 | -re "$gdb_prompt $"\ | |
455 | {fail "handle without arguments"} | |
456 | timeout {fail "(timeout) handle without arguments"} | |
457 | } | |
458 | ||
459 | send_gdb "handle SIGFOO\n" | |
460 | gdb_expect { | |
461 | -re "Unrecognized or ambiguous flag word: \"SIGFOO\".*$gdb_prompt $"\ | |
462 | {pass "handle with bogus SIG"} | |
463 | -re "$gdb_prompt $"\ | |
464 | {fail "handle with bogus SIG"} | |
465 | timeout {fail "(timeout) handle with bogus SIG"} | |
466 | } | |
467 | ||
468 | send_gdb "handle SIGHUP frump\n" | |
469 | gdb_expect { | |
470 | -re "Unrecognized or ambiguous flag word: \"frump\".*$gdb_prompt $"\ | |
471 | {pass "handle SIG with bogus action"} | |
472 | -re "$gdb_prompt $"\ | |
473 | {fail "handle SIG with bogus action"} | |
474 | timeout {fail "(timeout) handle SIG with bogus action"} | |
475 | } | |
476 | ||
477 | # Verify that "handle" can take multiple actions per SIG, and that in | |
478 | # the case of conflicting actions, that the rightmost action "wins". | |
479 | # | |
480 | send_gdb "handle SIGHUP print noprint\n" | |
481 | gdb_expect { | |
482 | -re ".*SIGHUP\[ \t\]*No\[ \t\]*No\[ \t\]*Yes\[ \t\]*Hangup.*$gdb_prompt $"\ | |
483 | {pass "handle SIG with multiple conflicting actions"} | |
484 | -re "$gdb_prompt $"\ | |
485 | {fail "handle SIG with multiple conflicting actions"} | |
486 | timeout {fail "(timeout) handle SIG with multiple conflicting actions"} | |
487 | } | |
488 | ||
489 | # Exercise all the various actions. (We don't care what the outcome | |
490 | # is, this is just to ensure that they all can be parsed.) | |
491 | # | |
492 | send_gdb "handle SIGHUP print noprint stop nostop ignore noignore pass nopass\n" | |
493 | gdb_expect { | |
494 | -re ".*Signal.*$gdb_prompt $"\ | |
495 | {pass "handle SIG parses all legal actions"} | |
496 | -re "$gdb_prompt $"\ | |
497 | {fail "handle SIG parses all legal actions"} | |
498 | timeout {fail "(timeout) handle SIG parses all legal actions"} | |
499 | } | |
500 | ||
501 | # Verify that we can "handle" multiple signals at once, interspersed | |
502 | # with actions. | |
503 | # | |
504 | send_gdb "handle SIG63 print SIGILL\n" | |
505 | gdb_expect { | |
506 | -re ".*SIGILL\[ \t\]*Yes\[ \t\]*Yes\[ \t\]*Yes\[ \t\]*Illegal instruction.*SIG63\[ \t\]*Yes\[ \t\]*Yes\[ \t\]*Yes\[ \t\]*Real-time event 63.*$gdb_prompt $"\ | |
507 | {pass "handle multiple SIGs"} | |
508 | -re "$gdb_prompt $"\ | |
509 | {fail "handle multiple SIGs"} | |
510 | timeout {fail "(timeout) handle multiple SIGs"} | |
511 | } | |
512 | ||
513 | # Verify that "handle" can take a numeric argument for the signal ID, | |
514 | # rather than a symbolic name. (This may not be portable; works for | |
515 | # HP-UX.) | |
516 | # | |
517 | # Also note that this testpoint overrides SIGTRAP, which on HP-UX at | |
518 | # least, is used to implement single-steps and breakpoints. Don't | |
519 | # expect to run the inferior after this! | |
520 | # | |
521 | send_gdb "handle 5 nopass\n" | |
522 | gdb_expect { | |
523 | -re ".*SIGTRAP is used by the debugger.*Are you sure you want to change it.*y or n.*"\ | |
524 | {send_gdb "y\n" | |
525 | gdb_expect { | |
526 | -re ".*SIGTRAP\[ \t\]*Yes\[ \t\]*Yes\[ \t\]*No\[ \t\]*Trace/breakpoint trap.*$gdb_prompt $"\ | |
527 | {pass "override SIGTRAP (#5)"} | |
528 | -re "$gdb_prompt $"\ | |
529 | {fail "override SIGTRAP (#5)"} | |
530 | timeout {fail "(timeout) override SIGTRAP (#5)"} | |
531 | } | |
532 | } | |
533 | -re "$gdb_prompt $"\ | |
534 | {fail "override SIGTRAP (#5)"} | |
535 | timeout {fail "(timeout) override SIGTRAP (#5)"} | |
536 | } | |
537 | ||
538 | # GDB doesn't seem to allow numeric signal IDs larger than 15. Verify | |
539 | # that restriction. ??rehrauer: Not sure if this is a feature or a | |
540 | # bug, actually. Why is the range 1-15? | |
541 | # | |
542 | send_gdb "handle 58\n" | |
543 | gdb_expect { | |
544 | -re "Only signals 1-15 are valid as numeric signals.*Use \"info signals\" for a list of symbolic signals.*$gdb_prompt $"\ | |
545 | {pass "invalid signal number rejected"} | |
546 | -re "$gdb_prompt $"\ | |
547 | {fail "invalid signal number rejected"} | |
548 | timeout {fail "(timeout) invalid signal number rejected"} | |
549 | } | |
550 | ||
551 | # Verify that we can accept a signal ID range (number-number). | |
552 | # ??rehrauer: This feature isn't documented on the quick-reference | |
553 | # card. | |
554 | # | |
555 | send_gdb "handle 13-15\n" | |
556 | gdb_expect { | |
557 | -re ".*SIGPIPE.*SIGALRM.*SIGTERM.*$gdb_prompt $"\ | |
558 | {pass "handle multiple SIGs via integer range"} | |
559 | -re "$gdb_prompt $"\ | |
560 | {fail "handle multiple SIGs via integer range"} | |
561 | timeout {fail "(timeout) handle multiple SIGs via integer range"} | |
562 | ||
563 | } | |
564 | ||
565 | # Bizarrely enough, GDB also allows you to reverse the range | |
566 | # stat, stop IDs. E.g., "3-1" and "1-3" mean the same thing. | |
567 | # Probably this isn't documented, but the code anticipates it, | |
568 | # so we'd best test it... | |
569 | # | |
570 | send_gdb "handle 15-13\n" | |
571 | gdb_expect { | |
572 | -re ".*SIGPIPE.*SIGALRM.*SIGTERM.*$gdb_prompt $"\ | |
573 | {pass "handle multiple SIGs via integer range"} | |
574 | -re "$gdb_prompt $"\ | |
575 | {fail "handle multiple SIGs via integer range"} | |
576 | timeout {fail "(timeout) handle multiple SIGs via integer range"} | |
577 | ||
578 | } | |
579 | ||
580 | # SIGINT is used by the debugger as well. Verify that we can change | |
581 | # our minds about changing it. | |
582 | # | |
583 | send_gdb "handle SIGINT nopass\n" | |
584 | gdb_expect { | |
585 | -re ".*SIGINT is used by the debugger.*Are you sure you want to change it.*y or n.*"\ | |
586 | {send_gdb "n\n" | |
587 | # ??rehrauer: When you answer "n", the header for the signal info is | |
588 | # printed, but not the actual handler settings. Probably a bug. | |
589 | # | |
590 | gdb_expect { | |
591 | -re "Not confirmed, unchanged.*Signal.*$gdb_prompt $"\ | |
592 | {pass "override SIGINT"} | |
593 | -re "$gdb_prompt $"\ | |
594 | {fail "override SIGINT"} | |
595 | timeout {fail "(timeout) override SIGINT"} | |
596 | } | |
597 | } | |
598 | -re "$gdb_prompt $"\ | |
599 | {fail "override SIGINT"} | |
600 | timeout {fail "(timeout) override SIGINT"} | |
601 | } | |
602 | ||
603 | # Verify that GDB responds gracefully to the "signal" command with | |
604 | # a missing argument. | |
605 | # | |
606 | send_gdb "signal\n" | |
607 | gdb_expect { | |
608 | -re "Argument required .signal number..*$gdb_prompt $"\ | |
609 | {pass "signal without arguments disallowed"} | |
610 | -re "$gdb_prompt $"\ | |
611 | {fail "signal without arguments disallowed"} | |
612 | timeout {fail "(timeout) signal without arguments disallowed"} | |
613 | } | |
614 | ||
615 | # Verify that we can successfully send a signal other than 0 to | |
616 | # the inferior. (This probably causes the inferior to run away. | |
617 | # Be prepared to rerun to main for further testing.) | |
618 | # | |
619 | send_gdb "signal 5\n" | |
620 | gdb_expect { | |
621 | -re "Continuing with signal SIGTRAP.*$gdb_prompt $"\ | |
622 | {pass "sent signal 5"} | |
623 | -re "$gdb_prompt $"\ | |
624 | {fail "sent signal 5"} | |
625 | timeout {fail "(timeout) sent signal 5"} | |
626 | } | |
627 | ||
628 | } | |
629 | ||
630 | return 0 |