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