1 # This testcase is part of GDB, the GNU debugger.
3 # Copyright 1997-2014 Free Software Foundation, Inc.
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
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
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.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
22 # ending-run.exp -- Expect script to test ending a test run in gdb
24 if { [prepare_for_testing ending-run.exp ending-run] } {
27 remote_exec build "rm -f core"
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...)
35 gdb_test "b ending-run.c:1" ".*Breakpoint.*ending-run.c, line 1.*" \
36 "bpt at line before routine"
38 gdb_test "b ending-run.c:14" \
39 ".*Note.*also.*Breakpoint 2.*ending-run.c, line 14.*" \
40 "b ending-run.c:14, one"
42 # Set up to go to the next-to-last line of the program
44 gdb_test "b ending-run.c:31" ".*Breakpoint 3.*ending-run.c, line 31.*"
46 # Expect to hit the bp at line "1", but symbolize this
47 # as line "13". Then try to clear it--this should work.
50 gdb_test "" ".*Breakpoint.*1.*callee.*14.*" "run"
52 gdb_test "cle" ".*Deleted breakpoints 1 2.*" "clear worked"
53 gdb_test_multiple "i b" "cleared bp at line before routine" {
54 -re ".* breakpoint .* breakpoint .*$gdb_prompt $" {
55 fail "cleared bp at line before routine"
57 -re ".*3.*main.*31.*$gdb_prompt $" {
58 pass "cleared bp at line before routine"
62 # Test some other "clear" combinations
64 gdb_test "b ending-run.c:1" ".*Breakpoint.*4.*"
65 gdb_test "b ending-run.c:14" ".*Note.*also.*Breakpoint.*5.*" "b ending-run.c:14, two"
66 gdb_test "cle ending-run.c:14" \
67 ".*Deleted breakpoint 5.*" "Cleared 2 by line"
69 gdb_test_multiple "info line ending-run.c:14" "" {
70 -re ".*address (0x\[0-9a-fA-F]*).*$gdb_prompt $" {
71 set line_nine $expect_out(1,string)
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"
74 gdb_test "cle" ".*Deleted breakpoints 4 6 7.*" "Clear 2 by default"
76 -re ".*$gdb_prompt $" {
77 fail "need to fix test for new compile outcome"
81 gdb_test_multiple "i b" "all set to continue" {
82 -re ".* breakpoint .* breakpoint .*$gdb_prompt $" {
83 fail "all set to continue (didn't clear bps)"
85 -re ".*3.*main.*31.*$gdb_prompt $" {
86 pass "all set to continue"
88 -re ".*$gdb_prompt $" {
89 fail "all set to continue (missing bp at end)"
94 # See if we can step out with control. The "1 2 3" stuff
95 # is output from the program.
97 if ![gdb_skip_stdio_test "cont"] {
98 gdb_test "cont" ".*1 2 7 14 23 34 47 62 79.*Breakpoint.*31.*"
100 gdb_test "cont" ".*Breakpoint.*31.*"
103 if ![gdb_skip_stdio_test "Step to return"] {
104 gdb_test "next" ".*Goodbye!.*32.*" \
107 gdb_test "next" ".*" ""
110 set old_timeout $timeout
115 gdb_test_multiple "next" "step out of main" {
116 -re "33\[ \t\]+\}.*$gdb_prompt $" {
117 # sometimes we stop at the closing brace, if so, do another next
119 fail "step out of main"
126 -re ".*Unable to find return pc for this frame.*$gdb_prompt $" {
127 fail "step out of main"
130 -re ".*in.*start.*$gdb_prompt $" {
131 pass "step out of main"
133 -re ".*in.*bsp_trap.*$gdb_prompt $" {
134 pass "step out of main"
136 -re ".*in.*init.*$gdb_prompt $" {
137 # This is what happens on sparc64-elf ultra.
138 pass "step out of main"
140 -re ".*in.*dll_crt0_1.*$gdb_prompt $" {
141 # This is what happens on Cygwin.
142 pass "step out of main"
144 -re ".*WinMain.*$gdb_prompt $" {
145 # This is what happens on mingw32ce.
146 pass "step out of main"
148 -re ".*$inferior_exited_re normally.*$gdb_prompt $" {
149 # This is what happens on Linux i86 (and I would expect others)
151 pass "step out of main"
153 -re ".*in .nope ().*$gdb_prompt $" {
154 # This is what happens on Solaris currently -sts 1999-08-25
155 pass "step out of main"
157 -re ".*in _int_reset ().*$gdb_prompt $" {
158 # This is what happens on Sanyo XStormy16
159 pass "step out of main"
161 -re ".*init ().*$gdb_prompt $" {
162 # This is what happens on many Mips targets
163 pass "step out of main"
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"
169 -re ".*__rt_entry.* ().*$gdb_prompt $" {
170 # This is what happens on the ARM RVDS runtime
171 pass "step out of main"
173 -re ".*in.*\\\$START\\\$.*from.*dld.sl.*$gdb_prompt $" {
174 pass "step out of main"
176 -re ".*in __wrap__?main ().*$gdb_prompt $" {
177 pass "step out of main"
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"
184 -re "E32Main (.*).*$gdb_prompt $" {
185 # On SymbianOS there's a different function which calls main.
186 pass "step out of main"
188 -re ".*in.*currently asm.*$gdb_prompt $" {
189 pass "step out of main"
191 -re "_*start\[0-9\]* \\(\[^)\]*\\).*$gdb_prompt $" {
192 pass "step out of main"
194 -re ".*Program received signal SIGTRAP.*$gdb_prompt $" {
195 pass "step out of main"
197 -re ".*in.*__uClibc_main.*$gdb_prompt $" {
198 # This is what happens on system using uClibc.
199 pass "step out of main"
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.
207 set program_exited_normally 0
208 set program_not_exited 0
209 set program_in_exit 0
211 && (! [target_info exists use_cygmon] || ! [target_info use_cygmon])} {
212 global program_exited
213 if {[eval expr $program_exited == 0]} {
214 gdb_test_multiple "n" "step to end of run" {
215 -re "$inferior_exited_re normally.*$gdb_prompt $" {
216 # If we actually have debug info for the start function,
217 # then we won't get the "Single-stepping until function
219 pass "step to end of run"
220 set program_exited_normally 1
222 -re "Single.*EXIT code 0\r\n.*$inferior_exited_re normally.*$gdb_prompt $" {
223 pass "step to end of run (status wrapper)"
224 set program_exited_normally 1
226 -re "Single.*EXIT code 0\r\n.*$gdb_prompt $" {
227 pass "step to end of run (status wrapper)"
229 -re ".*Single.*$inferior_exited_re.*$gdb_prompt $" {
230 pass "step to end of run"
231 set program_exited_normally 1
233 -re ".*Single.*in exit.*from.*dld.sl.*$gdb_prompt $" {
234 pass "step to end of run"
235 set program_in_exit 1
237 -re ".*Single.*_int_reset.*$gdb_prompt $" {
238 pass "step to end of run"
239 if {![istarget "xstormy16-*-*"]} {
240 set program_exited_normally 1
246 if {$program_in_exit} {
247 if {[gdb_test "c" ".*" "continue after exit"] == 0} {
248 set program_exited_normally 1
251 unsupported "continue after exit"
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"
259 unsupported "don't step after run"
262 set exec_output [remote_exec host "ls core"]
264 if [ regexp "core not found" $exec_output] {
265 pass "No core dumped on quit"
267 if [ regexp "No such file or directory" $exec_output] {
268 pass "ls: core (No core dumped on quit)"
270 remote_exec build "rm -f core"
271 fail "ls: core (Core dumped on quit)"
276 set timeout $old_timeout
278 #remote_exec build "rm -f ${binfile}"