[Committing the `catch syscall' patch for ARM, from Samuel Bronson.]
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / ending-run.exp
CommitLineData
1bf404ef
AC
1# This testcase is part of GDB, the GNU debugger.
2
28e7fd62 3# Copyright 1997-2013 Free Software Foundation, Inc.
c906108c
SS
4
5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
e22f8b7c 7# the Free Software Foundation; either version 3 of the License, or
c906108c 8# (at your option) any later version.
e22f8b7c 9#
c906108c
SS
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU General Public License for more details.
e22f8b7c 14#
c906108c 15# You should have received a copy of the GNU General Public License
e22f8b7c 16# along with this program. If not, see <http://www.gnu.org/licenses/>.
c906108c
SS
17
18# use this to debug:
19#
20#log_user 1
21
22# ending-run.exp -- Expect script to test ending a test run in gdb
23
dbc52822
VP
24if { [prepare_for_testing ending-run.exp ending-run] } {
25 return -1
c906108c 26}
c906108c
SS
27remote_exec build "rm -f core"
28
c906108c
SS
29# CHFts23469: Test that you can "clear" a bp set at
30# a line _before_ the routine (which will default to the
31# first line in the routine, which turns out to correspond
32# to the prolog--that's another bug...)
33#
b84b7669
MS
34
35gdb_test "b ending-run.c:1" ".*Breakpoint.*ending-run.c, line 1.*" \
36 "bpt at line before routine"
37
b40e7bf3
JB
38gdb_test "b ending-run.c:14" \
39 ".*Note.*also.*Breakpoint 2.*ending-run.c, line 14.*" \
40 "b ending-run.c:14, one"
c906108c
SS
41
42# Set up to go to the next-to-last line of the program
43#
b84b7669 44gdb_test "b ending-run.c:31" ".*Breakpoint 3.*ending-run.c, line 31.*"
c906108c
SS
45
46# Expect to hit the bp at line "1", but symbolize this
085dd6e6 47# as line "13". Then try to clear it--this should work.
c906108c 48#
b741e217 49gdb_run_cmd
b40e7bf3 50gdb_test "" ".*Breakpoint.*1.*callee.*14.*" "run"
b741e217 51
d6e956e5 52gdb_test "cle" ".*Deleted breakpoints 1 2.*" "clear worked"
a76e022a 53gdb_test_multiple "i b" "cleared bp at line before routine" {
ed4c619a 54 -re ".* breakpoint .* breakpoint .*$gdb_prompt $" {
cb9a9d3e
MS
55 fail "cleared bp at line before routine"
56 }
57 -re ".*3.*main.*31.*$gdb_prompt $" {
58 pass "cleared bp at line before routine"
59 }
c906108c
SS
60}
61
62# Test some other "clear" combinations
63#
b84b7669 64gdb_test "b ending-run.c:1" ".*Breakpoint.*4.*"
b40e7bf3
JB
65gdb_test "b ending-run.c:14" ".*Note.*also.*Breakpoint.*5.*" "b ending-run.c:14, two"
66gdb_test "cle ending-run.c:14" \
56ef84b1 67 ".*Deleted breakpoint 5.*" "Cleared 2 by line"
c906108c 68
a76e022a 69gdb_test_multiple "info line ending-run.c:14" "" {
c906108c
SS
70 -re ".*address (0x\[0-9a-fA-F]*).*$gdb_prompt $" {
71 set line_nine $expect_out(1,string)
b40e7bf3
JB
72 gdb_test "b ending-run.c:14" ".*Breakpoint 6.*ending-run.c, line 14.*"
73 gdb_test "b *$line_nine" ".*Note.*also.*Breakpoint 7.*" "Breakpoint 7 at *ending-run.c:14"
56ef84b1 74 gdb_test "cle" ".*Deleted breakpoints 4 6 7.*" "Clear 2 by default"
c906108c
SS
75 }
76 -re ".*$gdb_prompt $" {
77 fail "need to fix test for new compile outcome"
78 }
79}
80
a76e022a 81gdb_test_multiple "i b" "all set to continue" {
ed4c619a 82 -re ".* breakpoint .* breakpoint .*$gdb_prompt $" {
cb9a9d3e 83 fail "all set to continue (didn't clear bps)"
c906108c 84 }
085dd6e6 85 -re ".*3.*main.*31.*$gdb_prompt $" {
c906108c
SS
86 pass "all set to continue"
87 }
88 -re ".*$gdb_prompt $" {
cb9a9d3e 89 fail "all set to continue (missing bp at end)"
c906108c
SS
90 }
91}
92
93
94# See if we can step out with control. The "1 2 3" stuff
95# is output from the program.
96#
004af6c7
DJ
97if ![gdb_skip_stdio_test "cont"] {
98 gdb_test "cont" ".*1 2 7 14 23 34 47 62 79.*Breakpoint.*31.*"
99} else {
100 gdb_test "cont" ".*Breakpoint.*31.*"
101}
13a5e3b8
MS
102
103if ![gdb_skip_stdio_test "Step to return"] {
808a31f5 104 gdb_test "next" ".*Goodbye!.*32.*" \
13a5e3b8
MS
105 "Step to return"
106} else {
de7ff789 107 gdb_test "next" ".*" ""
13a5e3b8 108}
c906108c
SS
109
110set old_timeout $timeout
111set timeout 50
2b1a1355 112set program_exited 0
697bc68d 113set nexted 0
a76e022a
MS
114
115gdb_test_multiple "next" "step out of main" {
9a68ae16 116 -re "33\[ \t\]+\}.*$gdb_prompt $" {
c906108c 117 # sometimes we stop at the closing brace, if so, do another next
697bc68d
NS
118 if { $nexted } {
119 fail "step out of main"
120 } else {
121 set nexted 1
122 send_gdb "next\n"
123 exp_continue
c906108c
SS
124 }
125 }
126 -re ".*Unable to find return pc for this frame.*$gdb_prompt $" {
697bc68d
NS
127 fail "step out of main"
128 gdb_test "n" ".*" ""
c906108c
SS
129 }
130 -re ".*in.*start.*$gdb_prompt $" {
697bc68d
NS
131 pass "step out of main"
132 }
133 -re ".*in.*bsp_trap.*$gdb_prompt $" {
134 pass "step out of main"
c906108c 135 }
697bc68d
NS
136 -re ".*in.*init.*$gdb_prompt $" {
137 # This is what happens on sparc64-elf ultra.
138 pass "step out of main"
139 }
140 -re ".*in.*dll_crt0_1.*$gdb_prompt $" {
141 # This is what happens on Cygwin.
142 pass "step out of main"
085dd6e6 143 }
8b5a0f4f
PA
144 -re ".*WinMain.*$gdb_prompt $" {
145 # This is what happens on mingw32ce.
146 pass "step out of main"
147 }
fda326dd 148 -re ".*$inferior_exited_re normally.*$gdb_prompt $" {
2b1a1355
MS
149 # This is what happens on Linux i86 (and I would expect others)
150 set program_exited 1
151 pass "step out of main"
152 }
697bc68d
NS
153 -re ".*in .nope ().*$gdb_prompt $" {
154 # This is what happens on Solaris currently -sts 1999-08-25
155 pass "step out of main"
156 }
157 -re ".*in _int_reset ().*$gdb_prompt $" {
158 # This is what happens on Sanyo XStormy16
159 pass "step out of main"
160 }
161 -re ".*init ().*$gdb_prompt $" {
162 # This is what happens on many Mips targets
163 pass "step out of main"
164 }
165 -re ".*in ..change.mode ().*$gdb_prompt $" {
166 # This is what happens on ARM in thumb mode -fn 2000-02-01
167 pass "step out of main"
168 }
293e2f9e 169 -re ".*__rt_entry.* ().*$gdb_prompt $" {
697bc68d
NS
170 # This is what happens on the ARM RVDS runtime
171 pass "step out of main"
172 }
173 -re ".*in.*\\\$START\\\$.*from.*dld.sl.*$gdb_prompt $" {
174 pass "step out of main"
175 }
176 -re ".*in __wrap__?main ().*$gdb_prompt $" {
177 pass "step out of main"
178 }
179 -re "__setup_argv_for_main (.*).*$gdb_prompt $" {
180 # On sh, another wrapper function (start_l) exists, so
181 # another `next' is necessary.
182 gdb_test "next" ".*in start_l ().*" "step out of main"
183 }
759f0f0b
PA
184 -re "E32Main (.*).*$gdb_prompt $" {
185 # On SymbianOS there's a different function which calls main.
186 pass "step out of main"
187 }
cce74817 188 -re ".*in.*currently asm.*$gdb_prompt $" {
697bc68d
NS
189 pass "step out of main"
190 }
191 -re "_*start\[0-9\]* \\(\[^)\]*\\).*$gdb_prompt $" {
192 pass "step out of main"
cce74817
JM
193 }
194 -re ".*Program received signal SIGTRAP.*$gdb_prompt $" {
697bc68d 195 pass "step out of main"
cce74817 196 }
dbc0f131
YQ
197 -re ".*in.*__uClibc_main.*$gdb_prompt $" {
198 # This is what happens on system using uClibc.
199 pass "step out of main"
200 }
c906108c
SS
201}
202
0f815cdf
JB
203# When we're talking to a program running on a real stand-alone board,
204# every BSP's exit function behaves differently, so there's no single
205# way to tell whether we've exited gracefully or not. So don't run
206# these tests when use_gdb_stub is set, or when we're running under Cygmon.
31e45dee
FN
207set program_exited_normally 0
208set program_not_exited 0
209set program_in_exit 0
e11ac3a3 210if {!$use_gdb_stub
0f815cdf 211 && (! [target_info exists use_cygmon] || ! [target_info use_cygmon])} {
4ec70201 212 global program_exited
2b1a1355 213 if {[eval expr $program_exited == 0]} {
a76e022a 214 gdb_test_multiple "n" "step to end of run" {
fda326dd 215 -re "$inferior_exited_re normally.*$gdb_prompt $" {
2b1a1355
MS
216 # If we actually have debug info for the start function,
217 # then we won't get the "Single-stepping until function
218 # exit" message.
36a22261 219 pass "step to end of run"
31e45dee 220 set program_exited_normally 1
2b1a1355 221 }
fda326dd 222 -re "Single.*EXIT code 0\r\n.*$inferior_exited_re normally.*$gdb_prompt $" {
cb9a9d3e 223 pass "step to end of run (status wrapper)"
31e45dee 224 set program_exited_normally 1
cb9a9d3e 225 }
afb5c968
CV
226 -re "Single.*EXIT code 0\r\n.*$gdb_prompt $" {
227 pass "step to end of run (status wrapper)"
228 }
fda326dd 229 -re ".*Single.*$inferior_exited_re.*$gdb_prompt $" {
36a22261 230 pass "step to end of run"
31e45dee 231 set program_exited_normally 1
2b1a1355
MS
232 }
233 -re ".*Single.*in exit.*from.*dld.sl.*$gdb_prompt $" {
36a22261 234 pass "step to end of run"
31e45dee 235 set program_in_exit 1
2b1a1355 236 }
36a22261
CV
237 -re ".*Single.*_int_reset.*$gdb_prompt $" {
238 pass "step to end of run"
31e45dee
FN
239 if {![istarget "xstormy16-*-*"]} {
240 set program_exited_normally 1
241 }
36a22261 242 }
2b1a1355
MS
243 }
244 }
245
31e45dee
FN
246 if {$program_in_exit} {
247 if {[gdb_test "c" ".*" "continue after exit"] == 0} {
248 set program_exited_normally 1
249 }
250 } else {
251 unsupported "continue after exit"
252 }
253
31e45dee
FN
254 if {$program_exited_normally} {
255 gdb_test "n" ".*The program is not being run.*" "don't step after run"
256 } elseif {$program_not_exited} {
257 unresolved "don't step after run"
258 } else {
259 unsupported "don't step after run"
260 }
2b1a1355
MS
261
262 set exec_output [remote_exec host "ls core"]
263
264 if [ regexp "core not found" $exec_output] {
265 pass "No core dumped on quit"
7a292a7a 266 } else {
2b1a1355 267 if [ regexp "No such file or directory" $exec_output] {
cb9a9d3e 268 pass "ls: core (No core dumped on quit)"
2b1a1355
MS
269 } else {
270 remote_exec build "rm -f core"
cb9a9d3e 271 fail "ls: core (Core dumped on quit)"
2b1a1355 272 }
7a292a7a 273 }
c906108c
SS
274}
275
97f2ed50
DJ
276set timeout $old_timeout
277
c906108c
SS
278#remote_exec build "rm -f ${binfile}"
279return 0
280
281
282
283
This page took 1.416083 seconds and 4 git commands to generate.