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