1 # Copyright 2008, 2010 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 3 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, see <http://www.gnu.org/licenses/>.
16 # Test inferior resumption after discarding a hand-called function.
17 # There are two things to test.
18 # 1) Inferior stops normally. Upon resumption it should continue normally,
19 # regardless of whatever signal the hand-called function got.
20 # 2) Inferior is stopped at a signal. Upon resumption it should continue
21 # with that signal, regardless of whatever the hand-called function did.
27 if [target_info exists gdb,noinferiorio] {
28 verbose "Skipping call-signal-resume.exp because of no fileio capabilities."
32 if [target_info exists gdb,nosignals] {
33 verbose "Skipping call-signal-resume.exp because of nosignals."
40 set testfile "call-signals"
41 set srcfile ${testfile}.c
42 set binfile ${objdir}/${subdir}/${testfile}
44 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
45 untested call-signal-resume.exp
49 # Some targets can't do function calls, so don't even bother with this
51 if [target_info exists gdb,cannot_call_functions] {
52 setup_xfail "*-*-*" 2416
53 fail "This target can not call functions"
57 proc get_dummy_frame_number { } {
62 -re "#(\[0-9\]*) *<function called from gdb>.*$gdb_prompt $"
64 return $expect_out(1,string)
78 # Start with a fresh gdb.
82 gdb_reinitialize_dir $srcdir/$subdir
85 if { ![runto_main] } {
86 fail "Can't run to main"
90 gdb_test "break stop_one" "Breakpoint \[0-9\]* at .*"
91 gdb_test "continue" "Continuing.*Breakpoint \[0-9\]*, stop_one.*" \
92 "continue to breakpoint at stop_one"
94 # Call function (causing the program to get a signal), and see if gdb handles
96 gdb_test_multiple "call gen_signal ()" \
97 "inferior function call signaled" {
98 -re "\[\r\n\]*no signal\[\r\n\]+$gdb_prompt $" {
99 unsupported "inferior function call signaled"
102 -re "\[\r\n\]*The program being debugged was signaled.*\[\r\n\]+$gdb_prompt $" {
103 pass "inferior function call signaled"
107 set frame_number [get_dummy_frame_number]
108 if { "$frame_number" == "" } {
109 fail "dummy stack frame number"
112 pass "dummy stack frame number"
115 # Pop the dummy frame.
116 gdb_test "frame $frame_number" ""
117 gdb_test "set confirm off" ""
120 # Resume execution, the program should continue without any signal.
122 gdb_test "break stop_two" "Breakpoint \[0-9\]* at .*"
123 gdb_test "continue" "Breakpoint \[0-9\]*, stop_two.*" \
124 "continue to breakpoint at stop_two"
126 # Continue again, we should get a signal.
128 gdb_test "continue" "Program received signal .*" \
129 "continue to receipt of signal"
131 # Hand call another function that prematurely stops,
132 # then manually pop the dummy stack frame.
134 gdb_test "break null_hand_call" "Breakpoint \[0-9\]* at .*"
135 gdb_test "call null_hand_call ()" "Breakpoint \[0-9\]*, null_hand_call.*" \
138 set frame_number [get_dummy_frame_number]
139 if { "$frame_number" == "" } {
140 fail "dummy stack frame number"
145 pass "dummy stack frame number"
148 # Pop the dummy frame.
149 gdb_test "frame $frame_number" ""
150 gdb_test "set confirm off" ""
153 # Continue again, this time we should get to the signal handler.
155 gdb_test "break handle_signal" "Breakpoint \[0-9\]* at .*"
156 gdb_test "continue" "Breakpoint \[0-9\]*, handle_signal.*" \
157 "continue to breakpoint at handle_signal"
159 # Continue one last time, the program should exit normally.
161 gdb_test "continue" "Program exited normally." \
162 "continue to program exit"