1 # Copyright 1997, 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
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 2 of the License, or
6 # (at your option) any later version.
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.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
17 # Please email any bugs, comments, and/or additions to this file to:
18 # bug-gdb@prep.ai.mit.edu
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 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
46 gdb_reinitialize_dir $srcdir/$subdir
49 # CHFts23469: Test that you can "clear" a bp set at
50 # a line _before_ the routine (which will default to the
51 # first line in the routine, which turns out to correspond
52 # to the prolog--that's another bug...)
55 gdb_test "b ending-run.c:1" ".*Breakpoint.*ending-run.c, line 1.*" \
56 "bpt at line before routine"
58 gdb_test "b ending-run.c:13" \
59 ".*Note.*also.*Breakpoint 2.*ending-run.c, line 13.*" \
60 "b ending-run.c:13, one"
62 # Set up to go to the next-to-last line of the program
64 gdb_test "b ending-run.c:31" ".*Breakpoint 3.*ending-run.c, line 31.*"
66 # Expect to hit the bp at line "1", but symbolize this
67 # as line "13". Then try to clear it--this should work.
69 if [target_info exists use_gdb_stub] {
70 gdb_test "continue" ".*Breakpoint.*1.*callee.*13.*"
72 gdb_test "r" ".*Breakpoint.*1.*callee.*13.*"
74 gdb_test "cle" ".*Deleted breakpoints 2 1.*" "clear worked"
77 -re ".*breakpoint.*breakpoint.*$gdb_prompt $" {
78 fail "cleared bp at line before routine"
80 -re ".*3.*main.*31.*$gdb_prompt $" {
81 pass "cleared bp at line before routine"
83 -re ".*$gdb_prompt $" {
84 fail "cleared bp at line before routine (info b)"
88 # Test some other "clear" combinations
90 gdb_test "b ending-run.c:1" ".*Breakpoint.*4.*"
91 gdb_test "b ending-run.c:13" ".*Note.*also.*Breakpoint.*5.*" "b ending-run.c:13, two"
92 gdb_test "cle ending-run.c:13" \
93 ".*Deleted breakpoint 5.*" "Only cleared 1 by line"
95 send_gdb "inf line ending-run.c:13\n"
97 -re ".*address (0x\[0-9a-fA-F]*).*$gdb_prompt $" {
98 set line_eight $expect_out(1,string)
99 gdb_test "b 13" ".*Breakpoint.*6.*"
100 gdb_test "cle *$line_eight" ".*Deleted breakpoints 6 4.*" "Clear 2 by address"
102 -re ".*$gdb_prompt $" {
103 fail "need to fix test for new compile outcome"
107 send_gdb "inf line ending-run.c:14\n"
109 -re ".*address (0x\[0-9a-fA-F]*).*$gdb_prompt $" {
110 set line_nine $expect_out(1,string)
111 gdb_test "b ending-run.c:14" ".*Breakpoint 7.*ending-run.c, line 14.*"
112 gdb_test "b *$line_nine" ".*Note.*also.*Breakpoint 8.*"
113 gdb_test "c" ".*Breakpoint.*7.*callee.*14.*"
114 gdb_test "cle" ".*Deleted breakpoints 8 7.*" "Clear 2 by default"
116 -re ".*$gdb_prompt $" {
117 fail "need to fix test for new compile outcome"
123 -re ".*breakpoint.*breakpoint.*$gdb_prompt $" {
124 fail "all set to continue (didn't clear bps)"
126 -re ".*3.*main.*31.*$gdb_prompt $" {
127 pass "all set to continue"
129 -re ".*$gdb_prompt $" {
130 fail "all set to continue (missing bp at end)"
135 # See if we can step out with control. The "1 2 3" stuff
136 # is output from the program.
138 if ![gdb_skip_stdio_test "cont"] {
139 gdb_test "cont" ".*1 2 7 14 23 34 47 62 79.*Breakpoint.*31.*"
141 gdb_test "cont" ".*Breakpoint.*31.*"
144 if ![gdb_skip_stdio_test "Step to return"] {
145 gdb_test "next" ".*Goodbye!.*32.*" \
148 gdb_test "next" "" ""
151 set old_timeout $timeout
156 -re "33.*$gdb_prompt $" {
157 # sometimes we stop at the closing brace, if so, do another next
160 -re ".*Unable to find return pc for this frame.*$gdb_prompt $" {
161 fail "step out of main (Old bug came back!)"
164 -re ".*in.*start.*$gdb_prompt $" {
165 pass "step out of main"
167 -re ".*in.*bsp_trap.*$gdb_prompt $" {
168 pass "step out of main"
170 -re ".*in.*init.*$gdb_prompt $" {
171 # This is what happens on sparc64-elf ultra.
172 pass "step out of main"
174 -re ".*Program exited normally.*$gdb_prompt $" {
175 # This is what happens on Linux i86 (and I would expect others)
177 pass "step out of main"
179 -re ".*in .nope ().*$gdb_prompt $" {
180 # This is what happens on Solaris currently -sts 1999-08-25
181 pass "step out of main (on Solaris)"
183 -re ".*in _int_reset ().*$gdb_prompt $" {
184 # This is what happens on Sanyo XStormy16
185 pass "step out of main"
187 -re ".*init ().*$gdb_prompt $" {
188 # This is what happens on many Mips targets
189 pass "step out of main"
191 -re ".*in ..change.mode ().*$gdb_prompt $" {
192 # This is what happens on ARM in thumb mode -fn 2000-02-01
193 pass "step out of main (on ARM thumb)"
195 -re ".*in.*\\\$START\\\$.*from.*dld.sl.*$gdb_prompt $" {
196 pass "step out of main"
198 -re ".*in __wrap_main ().*$gdb_prompt $" {
199 pass "step out of main (status wrapper)"
201 -re ".*$gdb_prompt $" { fail "step out of main (at end 2)" }
203 fail "step out of main (hang or timeout on step at end 2)"
207 -re ".*Unable to find return pc for this frame.*$gdb_prompt $" {
208 fail "Old bug came back!"
211 -re ".*in.*start.*$gdb_prompt $" {
212 pass "step out of main"
214 -re ".*in.*\\\$START\\\$.*from.*dld.sl.*$gdb_prompt $" {
215 pass "step out of main (2)"
217 -re ".*Program exited normally.*$gdb_prompt $" {
218 # This is what happens on Linux i86 (and I would expect others)
220 pass "step out of main"
222 -re ".*in.*currently asm.*$gdb_prompt $" {
223 pass "step out of main (into assembler)"
225 -re ".*Program received signal SIGTRAP.*$gdb_prompt $" {
226 pass "Cygmon stopped in ending trap."
228 -re ".*$gdb_prompt $" { fail "step out of main (at end 1)" }
229 timeout { fail "step out of main (hang or timeout on step at end 1)" }
232 # When we're talking to a program running on a real stand-alone board,
233 # every BSP's exit function behaves differently, so there's no single
234 # way to tell whether we've exited gracefully or not. So don't run
235 # these tests when use_gdb_stub is set, or when we're running under Cygmon.
236 if {! [target_info exists use_gdb_stub]
237 && (! [target_info exists use_cygmon] || ! [target_info use_cygmon])} {
238 global program_exited;
239 if {[eval expr $program_exited == 0]} {
242 -re "Program exited normally.*$gdb_prompt $" {
243 # If we actually have debug info for the start function,
244 # then we won't get the "Single-stepping until function
246 pass "step to end of run"
248 -re "Single.*EXIT code 0.*Program exited normally.*$gdb_prompt $" {
249 pass "step to end of run (status wrapper)"
251 -re ".*Single.*Program exited.*$gdb_prompt $" {
252 pass "step to end of run"
254 -re ".*Single.*in exit.*from.*dld.sl.*$gdb_prompt $" {
255 pass "step to end of run"
256 gdb_test "c" ".*" "continue after exit"
258 -re ".*Single.*_int_reset.*$gdb_prompt $" {
259 pass "step to end of run"
260 setup_xfail "xstormy16-*-*"
262 -re ".*$gdb_prompt $" {
263 fail "step to end of run"
266 fail "(timeout) step to end of run"
271 set timeout $old_timeout
273 gdb_test "n" ".*The program is not being run.*" "don't step after run"
275 set exec_output [remote_exec host "ls core"]
277 if [ regexp "core not found" $exec_output] {
278 pass "No core dumped on quit"
280 if [ regexp "No such file or directory" $exec_output] {
281 pass "ls: core (No core dumped on quit)"
283 remote_exec build "rm -f core"
284 fail "ls: core (Core dumped on quit)"
289 #remote_exec build "rm -f ${binfile}"