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 sigstep.c creates a very simple backtrace containing one
19 # signal handler and signal trampoline.
21 # This test runs the program up to the signal handler, and then
22 # attempts to step/next the inferior back to main.
24 if [target_info exists gdb,nosignals] {
25 verbose "Skipping sigstep.exp because of nosignals."
37 set srcfile ${testfile}.c
38 set binfile ${objdir}/${subdir}/${testfile}
39 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
40 untested "Couldn't compile ${module}.c"
47 gdb_reinitialize_dir $srcdir/$subdir
50 gdb_test "display/i \$pc"
53 if { ![runto_main] } then {
57 # Pass all the alarms straight through (but verbosely)
58 # gdb_test "handle SIGALRM print pass nostop"
59 # gdb_test "handle SIGVTALRM print pass nostop"
60 # gdb_test "handle SIGPROF print pass nostop"
62 # Run to the signal handler, validate the backtrace.
63 gdb_test "break handler"
64 gdb_test "continue" ".* handler .*" "continue to stepi handler"
66 gdb_expect_list "backtrace for nexti" ".*$gdb_prompt $" {
67 "\[\r\n\]+.0 \[^\r\n\]* handler "
68 "\[\r\n\]+.1 .signal handler called."
69 "\[\r\n\]+.2 \[^\r\n\]* main .*"
75 # Get us back into the handler
77 gdb_test "continue" ".* handler .*" "continue to handler for $i"
79 set test "$i out of handler"
80 gdb_test_multiple "$i" "${test}" {
81 -re "done = 1;.*${gdb_prompt} $" {
85 -re "\} .. handler .*${gdb_prompt} $" {
89 -re "Program exited normally.*${gdb_prompt} $" {
90 kfail gdb/1613 "$test (Program exited normally)"
92 -re "while ..done.*${gdb_prompt} $" {
93 # After stepping out of a function, GDB might find that
94 # the inferior is already at the first instruction of this
98 -re "return 0.*${gdb_prompt} $" {
99 # After stepping out of a function, GDB will advance the
100 # inferior to the start of the next line.
106 proc advancei { i } {
110 # Get us back into the handler
112 gdb_test "continue" ".* handler .*" "continue to handler for $i"
114 set test "$i into signal trampoline"
115 gdb_test_multiple "$i" "${test}" {
116 -re "done = 1;.*${gdb_prompt} $" {
120 -re "\} .. handler .*${gdb_prompt} $" {
124 -re "signal handler called.*${gdb_prompt} $" {
127 -re "Program exited normally.*${gdb_prompt} $" {
128 kfail gdb/1613 "$test (Program exited normally)"
131 -re "main .*${gdb_prompt} $" {
132 fail "$test (in main)"
134 -re "Make handler return now.*y or n. $" {
140 set test "$i out of signal trampoline"
141 gdb_test_multiple "$i" "${test}" {
142 -re "while .*${gdb_prompt} $" {
143 pass "$test (in main)"
145 -re "signal handler called.*${gdb_prompt} $" {
149 -re "return .*${gdb_prompt} $" {
150 fail "$test (stepped)"
152 -re "Make .*frame return now.*y or n. $" {
156 -re "The program is not being run.*${gdb_prompt} $" {
157 if { $program_exited } {
158 # Previously kfailed with an exit
159 pass "$test (The program is not being run)"