Allow making GDB not automatically connect to the native target.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / call-signal-resume.exp
CommitLineData
ecd75fc8 1# Copyright 2008-2014 Free Software Foundation, Inc.
b89667eb
DE
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 3 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, see <http://www.gnu.org/licenses/>.
15
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.
22
b89667eb
DE
23if [target_info exists gdb,noinferiorio] {
24 verbose "Skipping call-signal-resume.exp because of no fileio capabilities."
25 continue
26}
27
2390201f
DJ
28if [target_info exists gdb,nosignals] {
29 verbose "Skipping call-signal-resume.exp because of nosignals."
30 continue
31}
32
b89667eb 33
f76495c8 34standard_testfile call-signals.c
b89667eb
DE
35
36if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
37 untested call-signal-resume.exp
38 return -1
39}
40
41# Some targets can't do function calls, so don't even bother with this
42# test.
43if [target_info exists gdb,cannot_call_functions] {
44 setup_xfail "*-*-*" 2416
45 fail "This target can not call functions"
46 continue
47}
48
49proc get_dummy_frame_number { } {
ad3986f0 50 global gdb_prompt
b89667eb 51
ad3986f0
MS
52 gdb_test_multiple "bt" "backtrace" {
53 -re "#(\[0-9\]*) *<function called from gdb>.*$gdb_prompt $" {
54 return $expect_out(1,string)
55 }
56 }
57 return ""
b89667eb
DE
58}
59
60# Start with a fresh gdb.
61
f76495c8 62clean_restart ${binfile}
b89667eb
DE
63
64if { ![runto_main] } {
65 fail "Can't run to main"
66 return 0
67}
68
69gdb_test "break stop_one" "Breakpoint \[0-9\]* at .*"
70gdb_test "continue" "Continuing.*Breakpoint \[0-9\]*, stop_one.*" \
71 "continue to breakpoint at stop_one"
72
73# Call function (causing the program to get a signal), and see if gdb handles
74# it properly.
75gdb_test_multiple "call gen_signal ()" \
76 "inferior function call signaled" {
77 -re "\[\r\n\]*no signal\[\r\n\]+$gdb_prompt $" {
78 unsupported "inferior function call signaled"
79 return 0
80 }
81 -re "\[\r\n\]*The program being debugged was signaled.*\[\r\n\]+$gdb_prompt $" {
82 pass "inferior function call signaled"
83 }
84}
85
86set frame_number [get_dummy_frame_number]
87if { "$frame_number" == "" } {
88 fail "dummy stack frame number"
89 setup_xfail "*-*-*"
90} else {
91 pass "dummy stack frame number"
92}
93
94# Pop the dummy frame.
f6978de9 95gdb_test "frame $frame_number" ".*"
27d3a1a2 96gdb_test_no_output "set confirm off"
050a2e1d 97gdb_test "return" ""
b89667eb 98
e2e4d78b
JK
99# Verify there are no remains of the dummy frame.
100gdb_test_no_output "maintenance print dummy-frames"
101set test "maintenance info breakpoints"
102gdb_test_multiple $test $test {
103 -re " call dummy .*\r\n$gdb_prompt $" {
104 fail $test
105 }
106 -re "\r\n$gdb_prompt $" {
107 pass $test
108 }
109}
110
b89667eb
DE
111# Resume execution, the program should continue without any signal.
112
113gdb_test "break stop_two" "Breakpoint \[0-9\]* at .*"
114gdb_test "continue" "Breakpoint \[0-9\]*, stop_two.*" \
115 "continue to breakpoint at stop_two"
116
117# Continue again, we should get a signal.
118
119gdb_test "continue" "Program received signal .*" \
120 "continue to receipt of signal"
121
122# Hand call another function that prematurely stops,
123# then manually pop the dummy stack frame.
124
125gdb_test "break null_hand_call" "Breakpoint \[0-9\]* at .*"
126gdb_test "call null_hand_call ()" "Breakpoint \[0-9\]*, null_hand_call.*" \
127 "null_hand_call"
128
129set frame_number [get_dummy_frame_number]
130if { "$frame_number" == "" } {
131 fail "dummy stack frame number"
132 setup_xfail "*-*-*"
133 # Need something.
134 set frame_number 0
135} else {
136 pass "dummy stack frame number"
137}
138
139# Pop the dummy frame.
f6978de9 140gdb_test "frame $frame_number" ".*"
27d3a1a2 141gdb_test_no_output "set confirm off"
050a2e1d 142gdb_test "return" ""
b89667eb
DE
143
144# Continue again, this time we should get to the signal handler.
145
146gdb_test "break handle_signal" "Breakpoint \[0-9\]* at .*"
147gdb_test "continue" "Breakpoint \[0-9\]*, handle_signal.*" \
148 "continue to breakpoint at handle_signal"
149
150# Continue one last time, the program should exit normally.
151
eceb0c5f
TT
152gdb_test "continue" "$inferior_exited_re normally." \
153 "continue to program exit"
b89667eb
DE
154
155return 0
This page took 0.615296 seconds and 4 git commands to generate.