1 # This testcase is part of GDB, the GNU debugger.
3 # Copyright 1997-2015 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
26 if { [prepare_for_testing ${testfile}.exp $testfile] } {
29 remote_exec build "rm -f core"
31 # CHFts23469: Test that you can "clear" a bp set at
32 # a line _before_ the routine (which will default to the
33 # first line in the routine, which turns out to correspond
34 # to the prolog--that's another bug...)
37 gdb_test "b ending-run.c:1" ".*Breakpoint.*ending-run.c, line 1.*" \
38 "bpt at line before routine"
40 set break1_line [gdb_get_line_number "-break1-"]
41 gdb_test "b ending-run.c:$break1_line" \
42 ".*Note.*also.*Breakpoint 2.*ending-run.c, line $break1_line.*" \
43 "b ending-run.c:$break1_line, one"
45 # Set up to go to the next-to-last line of the program
47 set break2_line [gdb_get_line_number "-break2-"]
48 gdb_test "b ending-run.c:$break2_line" ".*Breakpoint 3.*ending-run.c, line $break2_line.*"
50 # Expect to hit the bp at line "1", but symbolize this
51 # as line "13". Then try to clear it--this should work.
54 gdb_test "" ".*Breakpoint.*1.*callee.*$break1_line.*" "run"
56 gdb_test "cle" ".*Deleted breakpoints 1 2.*" "clear worked"
57 gdb_test_multiple "i b" "cleared bp at line before routine" {
58 -re ".* breakpoint .* breakpoint .*$gdb_prompt $" {
59 fail "cleared bp at line before routine"
61 -re ".*3.*main.*$break2_line.*$gdb_prompt $" {
62 pass "cleared bp at line before routine"
66 # Test some other "clear" combinations
68 gdb_test "b ending-run.c:1" ".*Breakpoint.*4.*"
69 gdb_test "b ending-run.c:$break1_line" ".*Note.*also.*Breakpoint.*5.*" "b ending-run.c:$break1_line, two"
70 gdb_test "cle ending-run.c:$break1_line" \
71 ".*Deleted breakpoint 5.*" "Cleared 2 by line"
73 gdb_test_multiple "info line ending-run.c:$break1_line" "" {
74 -re ".*address (0x\[0-9a-fA-F]*).*$gdb_prompt $" {
75 set line_nine $expect_out(1,string)
76 gdb_test "b ending-run.c:$break1_line" ".*Breakpoint 6.*ending-run.c, line $break1_line.*"
77 gdb_test "b *$line_nine" ".*Note.*also.*Breakpoint 7.*" "Breakpoint 7 at *ending-run.c:$break1_line"
78 gdb_test "cle" ".*Deleted breakpoints 4 6 7.*" "Clear 2 by default"
80 -re ".*$gdb_prompt $" {
81 fail "need to fix test for new compile outcome"
85 gdb_test_multiple "i b" "all set to continue" {
86 -re ".* breakpoint .* breakpoint .*$gdb_prompt $" {
87 fail "all set to continue (didn't clear bps)"
89 -re ".*3.*main.*$break2_line.*$gdb_prompt $" {
90 pass "all set to continue"
92 -re ".*$gdb_prompt $" {
93 fail "all set to continue (missing bp at end)"
98 # See if we can step out with control. The "1 2 3" stuff
99 # is output from the program.
101 if ![gdb_skip_stdio_test "cont"] {
102 gdb_test "cont" ".*1 2 7 14 23 34 47 62 79.*Breakpoint.*$break2_line.*"
104 gdb_test "cont" ".*Breakpoint.*$break2_line.*"
107 if ![gdb_skip_stdio_test "Step to return"] {
108 gdb_test "next" ".*Goodbye!.*[expr {$break2_line + 1}].*" \
111 gdb_test "next" ".*" ""
114 set old_timeout $timeout
119 gdb_test_multiple "next" "step out of main" {
120 -re "[expr {$break2_line + 2}]\[ \t\]+\}.*$gdb_prompt $" {
121 # sometimes we stop at the closing brace, if so, do another next
123 fail "step out of main"
130 -re ".*Unable to find return pc for this frame.*$gdb_prompt $" {
131 fail "step out of main"
134 -re ".*in.*start.*$gdb_prompt $" {
135 pass "step out of main"
137 -re ".*in.*bsp_trap.*$gdb_prompt $" {
138 pass "step out of main"
140 -re ".*in.*init.*$gdb_prompt $" {
141 # This is what happens on sparc64-elf ultra.
142 pass "step out of main"
144 -re ".*in.*dll_crt0_1.*$gdb_prompt $" {
145 # This is what happens on Cygwin.
146 pass "step out of main"
148 -re ".*WinMain.*$gdb_prompt $" {
149 # This is what happens on mingw32ce.
150 pass "step out of main"
152 -re ".*$inferior_exited_re normally.*$gdb_prompt $" {
153 # This is what happens on Linux i86 (and I would expect others)
155 pass "step out of main"
157 -re ".*in .nope ().*$gdb_prompt $" {
158 # This is what happens on Solaris currently -sts 1999-08-25
159 pass "step out of main"
161 -re ".*in _int_reset ().*$gdb_prompt $" {
162 # This is what happens on Sanyo XStormy16
163 pass "step out of main"
165 -re ".*init ().*$gdb_prompt $" {
166 # This is what happens on many Mips targets
167 pass "step out of main"
169 -re ".*in ..change.mode ().*$gdb_prompt $" {
170 # This is what happens on ARM in thumb mode -fn 2000-02-01
171 pass "step out of main"
173 -re ".*__rt_entry.* ().*$gdb_prompt $" {
174 # This is what happens on the ARM RVDS runtime
175 pass "step out of main"
177 -re ".*in.*\\\$START\\\$.*from.*dld.sl.*$gdb_prompt $" {
178 pass "step out of main"
180 -re ".*in __wrap__?main ().*$gdb_prompt $" {
181 pass "step out of main"
183 -re "__setup_argv_for_main (.*).*$gdb_prompt $" {
184 # On sh, another wrapper function (start_l) exists, so
185 # another `next' is necessary.
186 gdb_test "next" ".*in start_l ().*" "step out of main"
188 -re "E32Main (.*).*$gdb_prompt $" {
189 # On SymbianOS there's a different function which calls main.
190 pass "step out of main"
192 -re ".*in.*currently asm.*$gdb_prompt $" {
193 pass "step out of main"
195 -re "_*start\[0-9\]* \\(\[^)\]*\\).*$gdb_prompt $" {
196 pass "step out of main"
198 -re ".*Program received signal SIGTRAP.*$gdb_prompt $" {
199 pass "step out of main"
201 -re ".*in.*__uClibc_main.*$gdb_prompt $" {
202 # This is what happens on system using uClibc.
203 pass "step out of main"
207 # When we're talking to a program running on a real stand-alone board,
208 # every BSP's exit function behaves differently, so there's no single
209 # way to tell whether we've exited gracefully or not. So don't run
210 # these tests when use_gdb_stub is set, or when we're running under Cygmon.
211 set program_exited_normally 0
212 set program_not_exited 0
213 set program_in_exit 0
215 && (! [target_info exists use_cygmon] || ! [target_info use_cygmon])} {
216 global program_exited
217 if {[eval expr $program_exited == 0]} {
218 gdb_test_multiple "n" "step to end of run" {
219 -re "$inferior_exited_re normally.*$gdb_prompt $" {
220 # If we actually have debug info for the start function,
221 # then we won't get the "Single-stepping until function
223 pass "step to end of run"
224 set program_exited_normally 1
226 -re "Single.*EXIT code 0\r\n.*$inferior_exited_re normally.*$gdb_prompt $" {
227 pass "step to end of run (status wrapper)"
228 set program_exited_normally 1
230 -re "Single.*EXIT code 0\r\n.*$gdb_prompt $" {
231 pass "step to end of run (status wrapper)"
233 -re ".*Single.*$inferior_exited_re.*$gdb_prompt $" {
234 pass "step to end of run"
235 set program_exited_normally 1
237 -re ".*Single.*in exit.*from.*dld.sl.*$gdb_prompt $" {
238 pass "step to end of run"
239 set program_in_exit 1
241 -re ".*Single.*_int_reset.*$gdb_prompt $" {
242 pass "step to end of run"
243 if {![istarget "xstormy16-*-*"]} {
244 set program_exited_normally 1
250 if {$program_in_exit} {
251 if {[gdb_test "c" ".*" "continue after exit"] == 0} {
252 set program_exited_normally 1
255 unsupported "continue after exit"
258 if {$program_exited_normally} {
259 gdb_test "n" ".*The program is not being run.*" "don't step after run"
260 } elseif {$program_not_exited} {
261 unresolved "don't step after run"
263 unsupported "don't step after run"
266 set exec_output [remote_exec host "ls core"]
268 if [ regexp "core not found" $exec_output] {
269 pass "No core dumped on quit"
271 if [ regexp "No such file or directory" $exec_output] {
272 pass "ls: core (No core dumped on quit)"
274 remote_exec build "rm -f core"
275 fail "ls: core (Core dumped on quit)"
280 set timeout $old_timeout
282 #remote_exec build "rm -f ${binfile}"