Commit | Line | Data |
---|---|---|
1bf404ef AC |
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. | |
c906108c SS |
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 | |
1bf404ef | 18 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
c906108c SS |
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}] != "" } { | |
b60f0898 JB |
39 | untested ending-run.exp |
40 | return -1 | |
c906108c SS |
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 | # | |
b84b7669 MS |
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" \ | |
7dbd117d MC |
60 | ".*Note.*also.*Breakpoint 2.*ending-run.c, line 13.*" \ |
61 | "b ending-run.c:13, one" | |
c906108c SS |
62 | |
63 | # Set up to go to the next-to-last line of the program | |
64 | # | |
b84b7669 | 65 | gdb_test "b ending-run.c:31" ".*Breakpoint 3.*ending-run.c, line 31.*" |
c906108c SS |
66 | |
67 | # Expect to hit the bp at line "1", but symbolize this | |
085dd6e6 | 68 | # as line "13". Then try to clear it--this should work. |
c906108c | 69 | # |
7a292a7a | 70 | if [target_info exists use_gdb_stub] { |
a0b3c4fd | 71 | gdb_test "continue" ".*Breakpoint.*1.*callee.*13.*" |
7a292a7a | 72 | } else { |
a0b3c4fd | 73 | gdb_test "r" ".*Breakpoint.*1.*callee.*13.*" |
7a292a7a | 74 | } |
c906108c SS |
75 | gdb_test "cle" ".*Deleted breakpoints 2 1.*" "clear worked" |
76 | send_gdb "i b\n" | |
77 | gdb_expect { | |
ed4c619a | 78 | -re ".* breakpoint .* breakpoint .*$gdb_prompt $" { |
cb9a9d3e MS |
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 | } | |
c906108c SS |
87 | } |
88 | ||
89 | # Test some other "clear" combinations | |
90 | # | |
b84b7669 | 91 | gdb_test "b ending-run.c:1" ".*Breakpoint.*4.*" |
7dbd117d | 92 | gdb_test "b ending-run.c:13" ".*Note.*also.*Breakpoint.*5.*" "b ending-run.c:13, two" |
b84b7669 MS |
93 | gdb_test "cle ending-run.c:13" \ |
94 | ".*Deleted breakpoint 5.*" "Only cleared 1 by line" | |
c906108c | 95 | |
b84b7669 | 96 | send_gdb "inf line ending-run.c:13\n" |
c906108c SS |
97 | gdb_expect { |
98 | -re ".*address (0x\[0-9a-fA-F]*).*$gdb_prompt $" { | |
99 | set line_eight $expect_out(1,string) | |
a0b3c4fd | 100 | gdb_test "b 13" ".*Breakpoint.*6.*" |
c906108c SS |
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 | ||
b84b7669 | 108 | send_gdb "inf line ending-run.c:14\n" |
c906108c SS |
109 | gdb_expect { |
110 | -re ".*address (0x\[0-9a-fA-F]*).*$gdb_prompt $" { | |
111 | set line_nine $expect_out(1,string) | |
b84b7669 | 112 | gdb_test "b ending-run.c:14" ".*Breakpoint 7.*ending-run.c, line 14.*" |
1bf404ef | 113 | gdb_test "b *$line_nine" ".*Note.*also.*Breakpoint 8.*" "Breakpoint 7 at *ending-run.c:14" |
a0b3c4fd | 114 | gdb_test "c" ".*Breakpoint.*7.*callee.*14.*" |
c906108c SS |
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 { | |
ed4c619a | 124 | -re ".* breakpoint .* breakpoint .*$gdb_prompt $" { |
cb9a9d3e | 125 | fail "all set to continue (didn't clear bps)" |
c906108c | 126 | } |
085dd6e6 | 127 | -re ".*3.*main.*31.*$gdb_prompt $" { |
c906108c SS |
128 | pass "all set to continue" |
129 | } | |
130 | -re ".*$gdb_prompt $" { | |
cb9a9d3e | 131 | fail "all set to continue (missing bp at end)" |
c906108c SS |
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 | # | |
004af6c7 DJ |
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 | } | |
13a5e3b8 MS |
144 | |
145 | if ![gdb_skip_stdio_test "Step to return"] { | |
808a31f5 | 146 | gdb_test "next" ".*Goodbye!.*32.*" \ |
13a5e3b8 MS |
147 | "Step to return" |
148 | } else { | |
149 | gdb_test "next" "" "" | |
150 | } | |
c906108c SS |
151 | |
152 | set old_timeout $timeout | |
153 | set timeout 50 | |
2b1a1355 | 154 | set program_exited 0 |
c906108c SS |
155 | send_gdb "next\n" |
156 | gdb_expect { | |
085dd6e6 | 157 | -re "33.*$gdb_prompt $" { |
c906108c SS |
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 $" { | |
cb9a9d3e | 162 | fail "step out of main (Old bug came back!)" |
c906108c SS |
163 | gdb_test "n" ".*" "" |
164 | } | |
165 | -re ".*in.*start.*$gdb_prompt $" { | |
166 | pass "step out of main" | |
167 | } | |
9b0c4aeb FN |
168 | -re ".*in.*bsp_trap.*$gdb_prompt $" { |
169 | pass "step out of main" | |
170 | } | |
b84b7669 MS |
171 | -re ".*in.*init.*$gdb_prompt $" { |
172 | # This is what happens on sparc64-elf ultra. | |
173 | pass "step out of main" | |
174 | } | |
bf028682 CV |
175 | -re ".*in.*dll_crt0_1.*$gdb_prompt $" { |
176 | # This is what happens on Cygwin. | |
177 | pass "step out of main" | |
178 | } | |
2b1a1355 MS |
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 | } | |
104c1213 JM |
184 | -re ".*in .nope ().*$gdb_prompt $" { |
185 | # This is what happens on Solaris currently -sts 1999-08-25 | |
cb9a9d3e | 186 | pass "step out of main (on Solaris)" |
104c1213 | 187 | } |
a10c9419 | 188 | -re ".*in _int_reset ().*$gdb_prompt $" { |
84826df1 | 189 | # This is what happens on Sanyo XStormy16 |
a10c9419 CV |
190 | pass "step out of main" |
191 | } | |
6b8426a6 MH |
192 | -re ".*init ().*$gdb_prompt $" { |
193 | # This is what happens on many Mips targets | |
194 | pass "step out of main" | |
195 | } | |
8b93c638 JM |
196 | -re ".*in ..change.mode ().*$gdb_prompt $" { |
197 | # This is what happens on ARM in thumb mode -fn 2000-02-01 | |
cb9a9d3e | 198 | pass "step out of main (on ARM thumb)" |
8b93c638 | 199 | } |
085dd6e6 JM |
200 | -re ".*in.*\\\$START\\\$.*from.*dld.sl.*$gdb_prompt $" { |
201 | pass "step out of main" | |
202 | } | |
a283c5a1 | 203 | -re ".*in __wrap__?main ().*$gdb_prompt $" { |
cb9a9d3e MS |
204 | pass "step out of main (status wrapper)" |
205 | } | |
aec24853 CV |
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 | } | |
cb9a9d3e MS |
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 | } | |
c906108c SS |
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 | } | |
085dd6e6 | 224 | -re ".*in.*\\\$START\\\$.*from.*dld.sl.*$gdb_prompt $" { |
cb9a9d3e | 225 | pass "step out of main (2)" |
085dd6e6 | 226 | } |
2b1a1355 MS |
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 | } | |
cce74817 | 232 | -re ".*in.*currently asm.*$gdb_prompt $" { |
cb9a9d3e | 233 | pass "step out of main (into assembler)" |
cce74817 JM |
234 | } |
235 | -re ".*Program received signal SIGTRAP.*$gdb_prompt $" { | |
7a292a7a | 236 | pass "Cygmon stopped in ending trap." |
cce74817 | 237 | } |
cb9a9d3e MS |
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)" } | |
c906108c SS |
240 | } |
241 | ||
0f815cdf JB |
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. | |
31e45dee FN |
246 | set program_exited_normally 0 |
247 | set program_not_exited 0 | |
248 | set program_in_exit 0 | |
0f815cdf JB |
249 | if {! [target_info exists use_gdb_stub] |
250 | && (! [target_info exists use_cygmon] || ! [target_info use_cygmon])} { | |
2b1a1355 MS |
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. | |
36a22261 | 259 | pass "step to end of run" |
31e45dee | 260 | set program_exited_normally 1 |
2b1a1355 | 261 | } |
a283c5a1 | 262 | -re "Single.*EXIT code 0\r\n.*Program exited normally.*$gdb_prompt $" { |
cb9a9d3e | 263 | pass "step to end of run (status wrapper)" |
31e45dee | 264 | set program_exited_normally 1 |
cb9a9d3e | 265 | } |
afb5c968 CV |
266 | -re "Single.*EXIT code 0\r\n.*$gdb_prompt $" { |
267 | pass "step to end of run (status wrapper)" | |
268 | } | |
2b1a1355 | 269 | -re ".*Single.*Program exited.*$gdb_prompt $" { |
36a22261 | 270 | pass "step to end of run" |
31e45dee | 271 | set program_exited_normally 1 |
2b1a1355 MS |
272 | } |
273 | -re ".*Single.*in exit.*from.*dld.sl.*$gdb_prompt $" { | |
36a22261 | 274 | pass "step to end of run" |
31e45dee | 275 | set program_in_exit 1 |
2b1a1355 | 276 | } |
36a22261 CV |
277 | -re ".*Single.*_int_reset.*$gdb_prompt $" { |
278 | pass "step to end of run" | |
31e45dee FN |
279 | if {![istarget "xstormy16-*-*"]} { |
280 | set program_exited_normally 1 | |
281 | } | |
36a22261 | 282 | } |
2b1a1355 MS |
283 | -re ".*$gdb_prompt $" { |
284 | fail "step to end of run" | |
31e45dee | 285 | set program_not_exited 1 |
2b1a1355 MS |
286 | } |
287 | timeout { | |
288 | fail "(timeout) step to end of run" | |
31e45dee | 289 | set program_not_exited 1 |
2b1a1355 MS |
290 | } |
291 | } | |
292 | } | |
293 | ||
31e45dee FN |
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 | ||
2b1a1355 MS |
302 | set timeout $old_timeout |
303 | ||
31e45dee FN |
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 | } | |
2b1a1355 MS |
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" | |
7a292a7a | 316 | } else { |
2b1a1355 | 317 | if [ regexp "No such file or directory" $exec_output] { |
cb9a9d3e | 318 | pass "ls: core (No core dumped on quit)" |
2b1a1355 MS |
319 | } else { |
320 | remote_exec build "rm -f core" | |
cb9a9d3e | 321 | fail "ls: core (Core dumped on quit)" |
2b1a1355 | 322 | } |
7a292a7a | 323 | } |
c906108c SS |
324 | } |
325 | ||
326 | #remote_exec build "rm -f ${binfile}" | |
327 | return 0 | |
328 | ||
329 | ||
330 | ||
331 |