1 # Copyright
2004 Free Software Foundation
, Inc.
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.
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.
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.
18 # The
program siginfo.c creates a backtrace containing a
signal
19 # handler registered using sigaction
's sa_sigaction / SA_SIGINFO.
20 # Some OS's
(e.g.
, GNU
/Linux
) use different
signal trampolines
for
21 # sa_sigaction and sa_handler.
23 # This test first confirms that GDB can backtrace through the
24 # alternative sa_sigaction
signal handler
, and second that GDB can
25 # nexti
/stepi out of such a handler.
27 if [target_info
exists gdb
,nosignals
] {
28 verbose
"Skipping signals.exp because of nosignals."
40 set srcfile $
{testfile
}.c
41 set binfile $
{objdir
}/$
{subdir
}/$
{testfile
}
42 if { [gdb_compile
"${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
43 untested
"Couldn't compile ${module}.c"
50 gdb_reinitialize_dir $srcdir
/$subdir
53 gdb_test
"display/i \$pc"
56 if { ![runto_main
] } then {
60 # Pass all the alarms straight through
(but verbosely
)
61 # gdb_test
"handle SIGALRM print pass nostop"
62 # gdb_test
"handle SIGVTALRM print pass nostop"
63 # gdb_test
"handle SIGPROF print pass nostop"
65 # Run to the
signal handler
, validate the backtrace.
66 gdb_test
"break handler"
67 gdb_test
"continue" ".* handler .*" "continue to stepi handler"
69 gdb_expect_list
"backtrace for nexti" ".*$gdb_prompt $" {
70 "\[\r\n\]+.0 \[^\r\n\]* handler "
71 "\[\r\n\]+.1 .signal handler called."
72 "\[\r\n\]+.2 \[^\r\n\]* main .*"
75 # Check that GDB can step the inferior
back to main
76 set test
"step out of handler"
77 gdb_test_multiple
"step" "${test}" {
78 -re
"Could not insert single-step breakpoint.*$gdb_prompt $" {
79 setup_kfail sparc
*-*-openbsd
* gdb
/1736
80 fail
"$test (could not insert single-step breakpoint)"
82 -re
"done = 1;.*${gdb_prompt} $" {
86 -re
"\} .. handler .*${gdb_prompt} $" {
90 -re
"Program exited normally.*${gdb_prompt} $" {
91 kfail gdb
/1613 "$test (program exited)"
93 -re
"(while ..done|return 0).*${gdb_prompt} $" {
94 # After stepping out of a function
/r
signal-handler
, GDB will
95 # advance the inferior until it is at the first instruction of
96 # a code
-line.
While typically things
return to the middle of
97 # the
"while..." (and hence GDB advances the inferior to the
98 #
"return..." line) it is also possible for the return to land
99 #
on the first instruction of
"while...". Accept both cases.