1 # Copyright 1997, 1998, 1999, 2000, 2001 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 $" { fail "clear bp" }
78 -re ".*3.*main.*31.*$gdb_prompt $" { pass "cleared bp at line before routine" }
79 -re ".*$gdb_prompt $" { fail "info b" }
82 # Test some other "clear" combinations
84 gdb_test "b ending-run.c:1" ".*Breakpoint.*4.*"
85 gdb_test "b ending-run.c:13" ".*Note.*also.*Breakpoint.*5.*" "b ending-run.c:13, two"
86 gdb_test "cle ending-run.c:13" \
87 ".*Deleted breakpoint 5.*" "Only cleared 1 by line"
89 send_gdb "inf line ending-run.c:13\n"
91 -re ".*address (0x\[0-9a-fA-F]*).*$gdb_prompt $" {
92 set line_eight $expect_out(1,string)
93 gdb_test "b 13" ".*Breakpoint.*6.*"
94 gdb_test "cle *$line_eight" ".*Deleted breakpoints 6 4.*" "Clear 2 by address"
96 -re ".*$gdb_prompt $" {
97 fail "need to fix test for new compile outcome"
101 send_gdb "inf line ending-run.c:14\n"
103 -re ".*address (0x\[0-9a-fA-F]*).*$gdb_prompt $" {
104 set line_nine $expect_out(1,string)
105 gdb_test "b ending-run.c:14" ".*Breakpoint 7.*ending-run.c, line 14.*"
106 gdb_test "b *$line_nine" ".*Note.*also.*Breakpoint 8.*"
107 gdb_test "c" ".*Breakpoint.*7.*callee.*14.*"
108 gdb_test "cle" ".*Deleted breakpoints 8 7.*" "Clear 2 by default"
110 -re ".*$gdb_prompt $" {
111 fail "need to fix test for new compile outcome"
117 -re ".*breakpoint.*breakpoint.*$gdb_prompt $" {
118 fail "didn't clear bps"
120 -re ".*3.*main.*31.*$gdb_prompt $" {
121 pass "all set to continue"
123 -re ".*$gdb_prompt $" {
124 fail "missing bp at end"
129 # See if we can step out with control. The "1 2 3" stuff
130 # is output from the program.
132 gdb_test "cont" ".*Breakpoint.*31.*"
134 if ![gdb_skip_stdio_test "Step to return"] {
135 gdb_test "next" ".*1 2 7 14 23 34 47 62 79 Goodbye!.*32.*" \
138 gdb_test "next" "" ""
141 set old_timeout $timeout
145 -re "33.*$gdb_prompt $" {
146 # sometimes we stop at the closing brace, if so, do another next
149 -re ".*Unable to find return pc for this frame.*$gdb_prompt $" {
150 fail "Old bug came back!"
153 -re ".*in.*start.*$gdb_prompt $" {
154 pass "step out of main"
156 -re ".*in.*bsp_trap.*$gdb_prompt $" {
157 pass "step out of main"
159 -re ".*in.*init.*$gdb_prompt $" {
160 # This is what happens on sparc64-elf ultra.
161 pass "step out of main"
163 -re ".*in .nope ().*$gdb_prompt $" {
164 # This is what happens on Solaris currently -sts 1999-08-25
165 pass "step out of main on Solaris"
167 -re ".*in ..change.mode ().*$gdb_prompt $" {
168 # This is what happens on ARM in thumb mode -fn 2000-02-01
169 pass "step out of main on ARM thumb"
171 -re ".*in.*\\\$START\\\$.*from.*dld.sl.*$gdb_prompt $" {
172 pass "step out of main"
174 -re ".*$gdb_prompt $" { fail "step at end 2" }
175 timeout { fail "hang or timeout on step at end 2" }
178 -re ".*Unable to find return pc for this frame.*$gdb_prompt $" {
179 fail "Old bug came back!"
182 -re ".*in.*start.*$gdb_prompt $" {
183 pass "step out of main"
185 -re ".*in.*\\\$START\\\$.*from.*dld.sl.*$gdb_prompt $" {
186 pass "step out of main 2"
188 -re ".*in.*currently asm.*$gdb_prompt $" {
189 pass "step out of main into assembler"
191 -re ".*Program received signal SIGTRAP.*$gdb_prompt $" {
192 pass "Cygmon stopped in ending trap."
194 -re ".*$gdb_prompt $" { fail "step at end 1" }
195 timeout { fail "hang or timeout on step at end 1" }
198 if {![target_info exists use_cygmon] || ![target_info use_cygmon]} {
201 -re "Program exited normally.*$gdb_prompt $" {
202 # If we actually have debug info for the start function,
203 # then we won't get the "Single-stepping until function
205 pass "step to end of run 1"
207 -re ".*Single.*Program exited.*$gdb_prompt $" {
208 pass "step to end of run 1"
210 -re ".*Single.*in exit.*from.*dld.sl.*$gdb_prompt $" {
211 pass "step to end of run 2"
212 gdb_test "c" ".*" "continue after exit"
214 timeout { fail "(timeout) step to end of run" }
217 set timeout $old_timeout
219 gdb_test "n" ".*The program is not being run.*" "don't step after run"
221 set exec_output [remote_exec host "ls core"]
224 if [ regexp "core not found" $exec_output] {
225 pass "No core dumped on quit"
227 if [ regexp "No such file or directory" $exec_output] {
228 pass "ls: core: No core dumped on quit"
230 remote_exec build "rm -f core"
231 fail "Core dumped on quit"
236 #remote_exec build "rm -f ${binfile}"