1 # This testcase is part of GDB, the GNU debugger.
3 # Copyright 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free
4 # Software Foundation, Inc.
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
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
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.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 # ending-run.exp -- Expect script to test ending a test run in gdb
30 set testfile ending-run
31 set srcfile ${testfile}.c
32 set binfile ${objdir}/${subdir}/${testfile}
34 remote_exec build "rm -f ${binfile}"
35 remote_exec build "rm -f core"
38 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
39 untested ending-run.exp
47 gdb_reinitialize_dir $srcdir/$subdir
50 # CHFts23469: Test that you can "clear" a bp set at
51 # a line _before_ the routine (which will default to the
52 # first line in the routine, which turns out to correspond
53 # to the prolog--that's another bug...)
56 gdb_test "b ending-run.c:1" ".*Breakpoint.*ending-run.c, line 1.*" \
57 "bpt at line before routine"
59 gdb_test "b ending-run.c:13" \
60 ".*Note.*also.*Breakpoint 2.*ending-run.c, line 13.*" \
61 "b ending-run.c:13, one"
63 # Set up to go to the next-to-last line of the program
65 gdb_test "b ending-run.c:31" ".*Breakpoint 3.*ending-run.c, line 31.*"
67 # Expect to hit the bp at line "1", but symbolize this
68 # as line "13". Then try to clear it--this should work.
70 if [target_info exists use_gdb_stub] {
71 gdb_test "continue" ".*Breakpoint.*1.*callee.*13.*"
73 gdb_test "r" ".*Breakpoint.*1.*callee.*13.*"
75 gdb_test "cle" ".*Deleted breakpoints 2 1.*" "clear worked"
78 -re ".* breakpoint .* breakpoint .*$gdb_prompt $" {
79 fail "cleared bp at line before routine"
81 -re ".*3.*main.*31.*$gdb_prompt $" {
82 pass "cleared bp at line before routine"
84 -re ".*$gdb_prompt $" {
85 fail "cleared bp at line before routine (info b)"
89 # Test some other "clear" combinations
91 gdb_test "b ending-run.c:1" ".*Breakpoint.*4.*"
92 gdb_test "b ending-run.c:13" ".*Note.*also.*Breakpoint.*5.*" "b ending-run.c:13, two"
93 gdb_test "cle ending-run.c:13" \
94 ".*Deleted breakpoint 5.*" "Only cleared 1 by line"
96 send_gdb "inf line ending-run.c:13\n"
98 -re ".*address (0x\[0-9a-fA-F]*).*$gdb_prompt $" {
99 set line_eight $expect_out(1,string)
100 gdb_test "b 13" ".*Breakpoint.*6.*"
101 gdb_test "cle *$line_eight" ".*Deleted breakpoints 6 4.*" "Clear 2 by address"
103 -re ".*$gdb_prompt $" {
104 fail "need to fix test for new compile outcome"
108 send_gdb "inf line ending-run.c:14\n"
110 -re ".*address (0x\[0-9a-fA-F]*).*$gdb_prompt $" {
111 set line_nine $expect_out(1,string)
112 gdb_test "b ending-run.c:14" ".*Breakpoint 7.*ending-run.c, line 14.*"
113 gdb_test "b *$line_nine" ".*Note.*also.*Breakpoint 8.*" "Breakpoint 7 at *ending-run.c:14"
114 gdb_test "c" ".*Breakpoint.*7.*callee.*14.*"
115 gdb_test "cle" ".*Deleted breakpoints 8 7.*" "Clear 2 by default"
117 -re ".*$gdb_prompt $" {
118 fail "need to fix test for new compile outcome"
124 -re ".* breakpoint .* breakpoint .*$gdb_prompt $" {
125 fail "all set to continue (didn't clear bps)"
127 -re ".*3.*main.*31.*$gdb_prompt $" {
128 pass "all set to continue"
130 -re ".*$gdb_prompt $" {
131 fail "all set to continue (missing bp at end)"
136 # See if we can step out with control. The "1 2 3" stuff
137 # is output from the program.
139 if ![gdb_skip_stdio_test "cont"] {
140 gdb_test "cont" ".*1 2 7 14 23 34 47 62 79.*Breakpoint.*31.*"
142 gdb_test "cont" ".*Breakpoint.*31.*"
145 if ![gdb_skip_stdio_test "Step to return"] {
146 gdb_test "next" ".*Goodbye!.*32.*" \
149 gdb_test "next" "" ""
152 set old_timeout $timeout
157 -re "33.*$gdb_prompt $" {
158 # sometimes we stop at the closing brace, if so, do another next
161 -re ".*Unable to find return pc for this frame.*$gdb_prompt $" {
162 fail "step out of main (Old bug came back!)"
165 -re ".*in.*start.*$gdb_prompt $" {
166 pass "step out of main"
168 -re ".*in.*bsp_trap.*$gdb_prompt $" {
169 pass "step out of main"
171 -re ".*in.*init.*$gdb_prompt $" {
172 # This is what happens on sparc64-elf ultra.
173 pass "step out of main"
175 -re ".*in.*dll_crt0_1.*$gdb_prompt $" {
176 # This is what happens on Cygwin.
177 pass "step out of main"
179 -re ".*Program exited normally.*$gdb_prompt $" {
180 # This is what happens on Linux i86 (and I would expect others)
182 pass "step out of main"
184 -re ".*in .nope ().*$gdb_prompt $" {
185 # This is what happens on Solaris currently -sts 1999-08-25
186 pass "step out of main (on Solaris)"
188 -re ".*in _int_reset ().*$gdb_prompt $" {
189 # This is what happens on Sanyo XStormy16
190 pass "step out of main"
192 -re ".*init ().*$gdb_prompt $" {
193 # This is what happens on many Mips targets
194 pass "step out of main"
196 -re ".*in ..change.mode ().*$gdb_prompt $" {
197 # This is what happens on ARM in thumb mode -fn 2000-02-01
198 pass "step out of main (on ARM thumb)"
200 -re ".*in.*\\\$START\\\$.*from.*dld.sl.*$gdb_prompt $" {
201 pass "step out of main"
203 -re ".*in __wrap__?main ().*$gdb_prompt $" {
204 pass "step out of main (status wrapper)"
206 -re "__setup_argv_for_main (.*).*$gdb_prompt $" {
207 # On sh, another wrapper function (start_l) exists, so
208 # another `next' is necessary.
209 gdb_test "next" ".*in start_l ().*" "step out of main (on sh)"
211 -re ".*$gdb_prompt $" { fail "step out of main (at end 2)" }
213 fail "step out of main (hang or timeout on step at end 2)"
217 -re ".*Unable to find return pc for this frame.*$gdb_prompt $" {
218 fail "Old bug came back!"
221 -re ".*in.*start.*$gdb_prompt $" {
222 pass "step out of main"
224 -re ".*in.*\\\$START\\\$.*from.*dld.sl.*$gdb_prompt $" {
225 pass "step out of main (2)"
227 -re ".*Program exited normally.*$gdb_prompt $" {
228 # This is what happens on Linux i86 (and I would expect others)
230 pass "step out of main"
232 -re ".*in.*currently asm.*$gdb_prompt $" {
233 pass "step out of main (into assembler)"
235 -re ".*Program received signal SIGTRAP.*$gdb_prompt $" {
236 pass "Cygmon stopped in ending trap."
238 -re ".*$gdb_prompt $" { fail "step out of main (at end 1)" }
239 timeout { fail "step out of main (hang or timeout on step at end 1)" }
242 # When we're talking to a program running on a real stand-alone board,
243 # every BSP's exit function behaves differently, so there's no single
244 # way to tell whether we've exited gracefully or not. So don't run
245 # these tests when use_gdb_stub is set, or when we're running under Cygmon.
246 set program_exited_normally 0
247 set program_not_exited 0
248 set program_in_exit 0
249 if {! [target_info exists use_gdb_stub]
250 && (! [target_info exists use_cygmon] || ! [target_info use_cygmon])} {
251 global program_exited;
252 if {[eval expr $program_exited == 0]} {
255 -re "Program exited normally.*$gdb_prompt $" {
256 # If we actually have debug info for the start function,
257 # then we won't get the "Single-stepping until function
259 pass "step to end of run"
260 set program_exited_normally 1
262 -re "Single.*EXIT code 0\r\n.*Program exited normally.*$gdb_prompt $" {
263 pass "step to end of run (status wrapper)"
264 set program_exited_normally 1
266 -re "Single.*EXIT code 0\r\n.*$gdb_prompt $" {
267 pass "step to end of run (status wrapper)"
269 -re ".*Single.*Program exited.*$gdb_prompt $" {
270 pass "step to end of run"
271 set program_exited_normally 1
273 -re ".*Single.*in exit.*from.*dld.sl.*$gdb_prompt $" {
274 pass "step to end of run"
275 set program_in_exit 1
277 -re ".*Single.*_int_reset.*$gdb_prompt $" {
278 pass "step to end of run"
279 if {![istarget "xstormy16-*-*"]} {
280 set program_exited_normally 1
283 -re ".*$gdb_prompt $" {
284 fail "step to end of run"
285 set program_not_exited 1
288 fail "(timeout) step to end of run"
289 set program_not_exited 1
294 if {$program_in_exit} {
295 if {[gdb_test "c" ".*" "continue after exit"] == 0} {
296 set program_exited_normally 1
299 unsupported "continue after exit"
302 set timeout $old_timeout
304 if {$program_exited_normally} {
305 gdb_test "n" ".*The program is not being run.*" "don't step after run"
306 } elseif {$program_not_exited} {
307 unresolved "don't step after run"
309 unsupported "don't step after run"
312 set exec_output [remote_exec host "ls core"]
314 if [ regexp "core not found" $exec_output] {
315 pass "No core dumped on quit"
317 if [ regexp "No such file or directory" $exec_output] {
318 pass "ls: core (No core dumped on quit)"
320 remote_exec build "rm -f core"
321 fail "ls: core (Core dumped on quit)"
326 #remote_exec build "rm -f ${binfile}"