]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.base/ending-run.exp
* gdb.arch/altivec-abi.exp: Replace gdb_suppress_entire_file with
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / ending-run.exp
1 # This testcase is part of GDB, the GNU debugger.
2
3 # Copyright 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free
4 # Software Foundation, Inc.
5
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.
10 #
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.
15 #
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.
19
20 # use this to debug:
21 #
22 #log_user 1
23
24 # ending-run.exp -- Expect script to test ending a test run in gdb
25
26 if $tracelevel then {
27 strace $tracelevel
28 }
29
30 set testfile ending-run
31 set srcfile ${testfile}.c
32 set binfile ${objdir}/${subdir}/${testfile}
33
34 remote_exec build "rm -f ${binfile}"
35 remote_exec build "rm -f core"
36
37
38 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
39 untested ending-run.exp
40 return -1
41 }
42
43
44
45 gdb_exit
46 gdb_start
47 gdb_reinitialize_dir $srcdir/$subdir
48 gdb_load ${binfile}
49
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...)
54 #
55
56 gdb_test "b ending-run.c:1" ".*Breakpoint.*ending-run.c, line 1.*" \
57 "bpt at line before routine"
58
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"
62
63 # Set up to go to the next-to-last line of the program
64 #
65 gdb_test "b ending-run.c:31" ".*Breakpoint 3.*ending-run.c, line 31.*"
66
67 # Expect to hit the bp at line "1", but symbolize this
68 # as line "13". Then try to clear it--this should work.
69 #
70 if [target_info exists use_gdb_stub] {
71 gdb_test "continue" ".*Breakpoint.*1.*callee.*13.*"
72 } else {
73 gdb_test "r" ".*Breakpoint.*1.*callee.*13.*"
74 }
75 gdb_test "cle" ".*Deleted breakpoints 2 1.*" "clear worked"
76 send_gdb "i b\n"
77 gdb_expect {
78 -re ".* breakpoint .* breakpoint .*$gdb_prompt $" {
79 fail "cleared bp at line before routine"
80 }
81 -re ".*3.*main.*31.*$gdb_prompt $" {
82 pass "cleared bp at line before routine"
83 }
84 -re ".*$gdb_prompt $" {
85 fail "cleared bp at line before routine (info b)"
86 }
87 }
88
89 # Test some other "clear" combinations
90 #
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"
95
96 send_gdb "inf line ending-run.c:13\n"
97 gdb_expect {
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"
102 }
103 -re ".*$gdb_prompt $" {
104 fail "need to fix test for new compile outcome"
105 }
106 }
107
108 send_gdb "inf line ending-run.c:14\n"
109 gdb_expect {
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"
116 }
117 -re ".*$gdb_prompt $" {
118 fail "need to fix test for new compile outcome"
119 }
120 }
121
122 send_gdb "i b\n"
123 gdb_expect {
124 -re ".* breakpoint .* breakpoint .*$gdb_prompt $" {
125 fail "all set to continue (didn't clear bps)"
126 }
127 -re ".*3.*main.*31.*$gdb_prompt $" {
128 pass "all set to continue"
129 }
130 -re ".*$gdb_prompt $" {
131 fail "all set to continue (missing bp at end)"
132 }
133 }
134
135
136 # See if we can step out with control. The "1 2 3" stuff
137 # is output from the program.
138 #
139 if ![gdb_skip_stdio_test "cont"] {
140 gdb_test "cont" ".*1 2 7 14 23 34 47 62 79.*Breakpoint.*31.*"
141 } else {
142 gdb_test "cont" ".*Breakpoint.*31.*"
143 }
144
145 if ![gdb_skip_stdio_test "Step to return"] {
146 gdb_test "next" ".*Goodbye!.*32.*" \
147 "Step to return"
148 } else {
149 gdb_test "next" "" ""
150 }
151
152 set old_timeout $timeout
153 set timeout 50
154 set program_exited 0
155 send_gdb "next\n"
156 gdb_expect {
157 -re "33.*$gdb_prompt $" {
158 # sometimes we stop at the closing brace, if so, do another next
159 send_gdb "next\n"
160 gdb_expect {
161 -re ".*Unable to find return pc for this frame.*$gdb_prompt $" {
162 fail "step out of main (Old bug came back!)"
163 gdb_test "n" ".*" ""
164 }
165 -re ".*in.*start.*$gdb_prompt $" {
166 pass "step out of main"
167 }
168 -re ".*in.*bsp_trap.*$gdb_prompt $" {
169 pass "step out of main"
170 }
171 -re ".*in.*init.*$gdb_prompt $" {
172 # This is what happens on sparc64-elf ultra.
173 pass "step out of main"
174 }
175 -re ".*in.*dll_crt0_1.*$gdb_prompt $" {
176 # This is what happens on Cygwin.
177 pass "step out of main"
178 }
179 -re ".*Program exited normally.*$gdb_prompt $" {
180 # This is what happens on Linux i86 (and I would expect others)
181 set program_exited 1
182 pass "step out of main"
183 }
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)"
187 }
188 -re ".*in _int_reset ().*$gdb_prompt $" {
189 # This is what happens on Sanyo XStormy16
190 pass "step out of main"
191 }
192 -re ".*init ().*$gdb_prompt $" {
193 # This is what happens on many Mips targets
194 pass "step out of main"
195 }
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)"
199 }
200 -re ".*in.*\\\$START\\\$.*from.*dld.sl.*$gdb_prompt $" {
201 pass "step out of main"
202 }
203 -re ".*in __wrap__?main ().*$gdb_prompt $" {
204 pass "step out of main (status wrapper)"
205 }
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)"
210 }
211 -re ".*$gdb_prompt $" { fail "step out of main (at end 2)" }
212 timeout {
213 fail "step out of main (hang or timeout on step at end 2)"
214 }
215 }
216 }
217 -re ".*Unable to find return pc for this frame.*$gdb_prompt $" {
218 fail "Old bug came back!"
219 gdb_test "n" ".*" ""
220 }
221 -re ".*in.*start.*$gdb_prompt $" {
222 pass "step out of main"
223 }
224 -re ".*in.*\\\$START\\\$.*from.*dld.sl.*$gdb_prompt $" {
225 pass "step out of main (2)"
226 }
227 -re ".*Program exited normally.*$gdb_prompt $" {
228 # This is what happens on Linux i86 (and I would expect others)
229 set program_exited 1
230 pass "step out of main"
231 }
232 -re ".*in.*currently asm.*$gdb_prompt $" {
233 pass "step out of main (into assembler)"
234 }
235 -re ".*Program received signal SIGTRAP.*$gdb_prompt $" {
236 pass "Cygmon stopped in ending trap."
237 }
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)" }
240 }
241
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]} {
253 send_gdb "n\n"
254 gdb_expect {
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
258 # exit" message.
259 pass "step to end of run"
260 set program_exited_normally 1
261 }
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
265 }
266 -re "Single.*EXIT code 0\r\n.*$gdb_prompt $" {
267 pass "step to end of run (status wrapper)"
268 }
269 -re ".*Single.*Program exited.*$gdb_prompt $" {
270 pass "step to end of run"
271 set program_exited_normally 1
272 }
273 -re ".*Single.*in exit.*from.*dld.sl.*$gdb_prompt $" {
274 pass "step to end of run"
275 set program_in_exit 1
276 }
277 -re ".*Single.*_int_reset.*$gdb_prompt $" {
278 pass "step to end of run"
279 if {![istarget "xstormy16-*-*"]} {
280 set program_exited_normally 1
281 }
282 }
283 -re ".*$gdb_prompt $" {
284 fail "step to end of run"
285 set program_not_exited 1
286 }
287 timeout {
288 fail "(timeout) step to end of run"
289 set program_not_exited 1
290 }
291 }
292 }
293
294 if {$program_in_exit} {
295 if {[gdb_test "c" ".*" "continue after exit"] == 0} {
296 set program_exited_normally 1
297 }
298 } else {
299 unsupported "continue after exit"
300 }
301
302 set timeout $old_timeout
303
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"
308 } else {
309 unsupported "don't step after run"
310 }
311
312 set exec_output [remote_exec host "ls core"]
313
314 if [ regexp "core not found" $exec_output] {
315 pass "No core dumped on quit"
316 } else {
317 if [ regexp "No such file or directory" $exec_output] {
318 pass "ls: core (No core dumped on quit)"
319 } else {
320 remote_exec build "rm -f core"
321 fail "ls: core (Core dumped on quit)"
322 }
323 }
324 }
325
326 #remote_exec build "rm -f ${binfile}"
327 return 0
328
329
330
331