This commit was generated by cvs2svn to track changes on a CVS vendor
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / signals.exp
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 # bug-gdb@prep.ai.mit.edu
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
339 if { [istarget "*-*-gnu*"] || [istarget "*-*-mach*"] } {
340 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"
341 } else {
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"
343 }
344 set timeout $oldtimeout
345 verbose "Timeout restored to $timeout seconds" 2
346 }
347 test_handle_all_print
348
349 gdb_exit
350 gdb_start
351 gdb_reinitialize_dir $srcdir/$subdir
352 gdb_load $binfile
353 signal_tests_1
354
355 # Force a resync, so we're looking at the right prompt. On SCO we
356 # were getting out of sync (I don't understand why).
357 send_gdb "p 1+1\n"
358 gdb_expect {
359 -re "= 2.*$gdb_prompt $" {}
360 -re ".*$gdb_prompt $" { perror "sync trouble in signals.exp" }
361 default { perror "sync trouble in signals.exp" }
362 }
363
364 if [runto_main] then {
365 gdb_test "break handler if 0" "Breakpoint \[0-9\]+ .*"
366 gdb_test "set \$handler_breakpoint_number = \$bpnum" ""
367
368 # Get to the point where a signal is waiting to be delivered
369 gdb_test "next" "signal \\(SIGUSR1.*" "next to signal in signals.exp"
370 gdb_test "next" "alarm \\(.*" "next to alarm #1 in signals.exp"
371 gdb_test "next" "\\+\\+count; /\\* first \\*/" \
372 "next to ++count #1 in signals.exp"
373 # Give the signal time to get delivered
374 sleep 2
375
376 # Now call a function. When GDB tries to run the stack dummy,
377 # it will hit the breakpoint at handler. Provided it doesn't
378 # lose its cool, this is not a problem, it just has to note
379 # that the breakpoint condition is false and keep going.
380
381 gdb_test "p func1 ()" "^p func1 \\(\\)\r\n.\[0-9\]* = void" \
382 "p func1 () #1 in signals.exp"
383
384 # Make sure the count got incremented.
385
386 # Haven't investigated this xfail
387 setup_xfail "rs6000-*-*"
388 setup_xfail "powerpc-*-*"
389 gdb_test "p count" "= 2" "p count #1 in signals.exp"
390 if { [istarget "rs6000-*-*"] || [istarget "powerpc-*-*"] } { return 0 }
391
392 gdb_test "condition \$handler_breakpoint_number" "now unconditional\\."
393 gdb_test "next" "alarm \\(.*" "next to alarm #2 in signals.exp"
394 gdb_test "next" "\\+\\+count; /\\* second \\*/" \
395 "next to ++count #2 in signals.exp"
396 sleep 2
397
398 # This time we stop when GDB tries to run the stack dummy.
399 # So it is OK that we do not print the return value from the function.
400 gdb_test "p func1 ()" \
401 "Breakpoint \[0-9\]*, handler.*
402 The program being debugged stopped while in a function called from GDB.*" \
403 "p func1 () #2 in signals.exp"
404 # But we should be able to backtrace...
405 # On alpha-*-osf2.0 this test works when run manually but sometime fails when
406 # run under dejagnu, making it very hard to debug the problem. Weird...
407 gdb_test "bt 10" "#0.*handler.*#1.*#2.*main.*" "bt in signals.exp"
408 # ...and continue...
409 gdb_test "continue" "Continuing\\." "continue in signals.exp"
410 # ...and then count should have been incremented
411 gdb_test "p count" "= 5" "p count #2 in signals.exp"
412
413
414 # Verify that "info signals" produces reasonable output.
415 #
416 send_gdb "info signals\n"
417 gdb_expect {
418 -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 $"\
419 {pass "info signals"}
420 -re "$gdb_prompt $"\
421 {fail "info signals"}
422 timeout {fail "(timeout) info signals"}
423 }
424
425 # Verify that "info signal" correctly handles an argument, be it a
426 # symbolic signal name, or an integer ID.
427 #
428 send_gdb "info signal SIGTRAP\n"
429 gdb_expect {
430 -re ".*SIGTRAP\[ \t\]*Yes\[ \t\]*Yes\[ \t\]*No\[ \t\]*Trace/breakpoint trap.*$gdb_prompt $"\
431 {pass "info signal SIGTRAP"}
432 -re "$gdb_prompt $"\
433 {fail "info signal SIGTRAP"}
434 timeout {fail "(timeout) info signal SIGTRAP"}
435 }
436
437 send_gdb "info signal 5\n"
438 gdb_expect {
439 -re ".*SIGTRAP\[ \t\]*Yes\[ \t\]*Yes\[ \t\]*No\[ \t\]*Trace/breakpoint trap.*$gdb_prompt $"\
440 {pass "info signal 5"}
441 -re "$gdb_prompt $"\
442 {fail "info signal 5"}
443 timeout {fail "(timeout) info signal 5"}
444 }
445
446 # Verify that "handle" with illegal arguments is gracefully, um, handled.
447 #
448 send_gdb "handle\n"
449 gdb_expect {
450 -re "Argument required .signal to handle.*$gdb_prompt $"\
451 {pass "handle without arguments"}
452 -re "$gdb_prompt $"\
453 {fail "handle without arguments"}
454 timeout {fail "(timeout) handle without arguments"}
455 }
456
457 send_gdb "handle SIGFOO\n"
458 gdb_expect {
459 -re "Unrecognized or ambiguous flag word: \"SIGFOO\".*$gdb_prompt $"\
460 {pass "handle with bogus SIG"}
461 -re "$gdb_prompt $"\
462 {fail "handle with bogus SIG"}
463 timeout {fail "(timeout) handle with bogus SIG"}
464 }
465
466 send_gdb "handle SIGHUP frump\n"
467 gdb_expect {
468 -re "Unrecognized or ambiguous flag word: \"frump\".*$gdb_prompt $"\
469 {pass "handle SIG with bogus action"}
470 -re "$gdb_prompt $"\
471 {fail "handle SIG with bogus action"}
472 timeout {fail "(timeout) handle SIG with bogus action"}
473 }
474
475 # Verify that "handle" can take multiple actions per SIG, and that in
476 # the case of conflicting actions, that the rightmost action "wins".
477 #
478 send_gdb "handle SIGHUP print noprint\n"
479 gdb_expect {
480 -re ".*SIGHUP\[ \t\]*No\[ \t\]*No\[ \t\]*Yes\[ \t\]*Hangup.*$gdb_prompt $"\
481 {pass "handle SIG with multiple conflicting actions"}
482 -re "$gdb_prompt $"\
483 {fail "handle SIG with multiple conflicting actions"}
484 timeout {fail "(timeout) handle SIG with multiple conflicting actions"}
485 }
486
487 # Exercise all the various actions. (We don't care what the outcome
488 # is, this is just to ensure that they all can be parsed.)
489 #
490 send_gdb "handle SIGHUP print noprint stop nostop ignore noignore pass nopass\n"
491 gdb_expect {
492 -re ".*Signal.*$gdb_prompt $"\
493 {pass "handle SIG parses all legal actions"}
494 -re "$gdb_prompt $"\
495 {fail "handle SIG parses all legal actions"}
496 timeout {fail "(timeout) handle SIG parses all legal actions"}
497 }
498
499 # Verify that we can "handle" multiple signals at once, interspersed
500 # with actions.
501 #
502 send_gdb "handle SIG63 print SIGILL\n"
503 gdb_expect {
504 -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 $"\
505 {pass "handle multiple SIGs"}
506 -re "$gdb_prompt $"\
507 {fail "handle multiple SIGs"}
508 timeout {fail "(timeout) handle multiple SIGs"}
509 }
510
511 # Verify that "handle" can take a numeric argument for the signal ID,
512 # rather than a symbolic name. (This may not be portable; works for
513 # HP-UX.)
514 #
515 # Also note that this testpoint overrides SIGTRAP, which on HP-UX at
516 # least, is used to implement single-steps and breakpoints. Don't
517 # expect to run the inferior after this!
518 #
519 send_gdb "handle 5 nopass\n"
520 gdb_expect {
521 -re ".*SIGTRAP is used by the debugger.*Are you sure you want to change it.*y or n.*"\
522 {send_gdb "y\n"
523 gdb_expect {
524 -re ".*SIGTRAP\[ \t\]*Yes\[ \t\]*Yes\[ \t\]*No\[ \t\]*Trace/breakpoint trap.*$gdb_prompt $"\
525 {pass "override SIGTRAP (#5)"}
526 -re "$gdb_prompt $"\
527 {fail "override SIGTRAP (#5)"}
528 timeout {fail "(timeout) override SIGTRAP (#5)"}
529 }
530 }
531 -re "$gdb_prompt $"\
532 {fail "override SIGTRAP (#5)"}
533 timeout {fail "(timeout) override SIGTRAP (#5)"}
534 }
535
536 # GDB doesn't seem to allow numeric signal IDs larger than 15. Verify
537 # that restriction. ??rehrauer: Not sure if this is a feature or a
538 # bug, actually. Why is the range 1-15?
539 #
540 send_gdb "handle 58\n"
541 gdb_expect {
542 -re "Only signals 1-15 are valid as numeric signals.*Use \"info signals\" for a list of symbolic signals.*$gdb_prompt $"\
543 {pass "invalid signal number rejected"}
544 -re "$gdb_prompt $"\
545 {fail "invalid signal number rejected"}
546 timeout {fail "(timeout) invalid signal number rejected"}
547 }
548
549 # Verify that we can accept a signal ID range (number-number).
550 # ??rehrauer: This feature isn't documented on the quick-reference
551 # card.
552 #
553 send_gdb "handle 13-15\n"
554 gdb_expect {
555 -re ".*SIGPIPE.*SIGALRM.*SIGTERM.*$gdb_prompt $"\
556 {pass "handle multiple SIGs via integer range"}
557 -re "$gdb_prompt $"\
558 {fail "handle multiple SIGs via integer range"}
559 timeout {fail "(timeout) handle multiple SIGs via integer range"}
560
561 }
562
563 # Bizarrely enough, GDB also allows you to reverse the range
564 # stat, stop IDs. E.g., "3-1" and "1-3" mean the same thing.
565 # Probably this isn't documented, but the code anticipates it,
566 # so we'd best test it...
567 #
568 send_gdb "handle 15-13\n"
569 gdb_expect {
570 -re ".*SIGPIPE.*SIGALRM.*SIGTERM.*$gdb_prompt $"\
571 {pass "handle multiple SIGs via integer range"}
572 -re "$gdb_prompt $"\
573 {fail "handle multiple SIGs via integer range"}
574 timeout {fail "(timeout) handle multiple SIGs via integer range"}
575
576 }
577
578 # SIGINT is used by the debugger as well. Verify that we can change
579 # our minds about changing it.
580 #
581 send_gdb "handle SIGINT nopass\n"
582 gdb_expect {
583 -re ".*SIGINT is used by the debugger.*Are you sure you want to change it.*y or n.*"\
584 {send_gdb "n\n"
585 # ??rehrauer: When you answer "n", the header for the signal info is
586 # printed, but not the actual handler settings. Probably a bug.
587 #
588 gdb_expect {
589 -re "Not confirmed, unchanged.*Signal.*$gdb_prompt $"\
590 {pass "override SIGINT"}
591 -re "$gdb_prompt $"\
592 {fail "override SIGINT"}
593 timeout {fail "(timeout) override SIGINT"}
594 }
595 }
596 -re "$gdb_prompt $"\
597 {fail "override SIGINT"}
598 timeout {fail "(timeout) override SIGINT"}
599 }
600
601 # Verify that GDB responds gracefully to the "signal" command with
602 # a missing argument.
603 #
604 send_gdb "signal\n"
605 gdb_expect {
606 -re "Argument required .signal number..*$gdb_prompt $"\
607 {pass "signal without arguments disallowed"}
608 -re "$gdb_prompt $"\
609 {fail "signal without arguments disallowed"}
610 timeout {fail "(timeout) signal without arguments disallowed"}
611 }
612
613 # Verify that we can successfully send a signal other than 0 to
614 # the inferior. (This probably causes the inferior to run away.
615 # Be prepared to rerun to main for further testing.)
616 #
617 send_gdb "signal 5\n"
618 gdb_expect {
619 -re "Continuing with signal SIGTRAP.*$gdb_prompt $"\
620 {pass "sent signal 5"}
621 -re "$gdb_prompt $"\
622 {fail "sent signal 5"}
623 timeout {fail "(timeout) sent signal 5"}
624 }
625
626 }
627
628 return 0
This page took 0.042624 seconds and 5 git commands to generate.