Commit | Line | Data |
---|---|---|
23f572c2 | 1 | # Copyright 1997, 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. |
c906108c SS |
2 | |
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. | |
7 | # | |
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. | |
12 | # | |
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. */ | |
16 | ||
17 | # Please email any bugs, comments, and/or additions to this file to: | |
18 | # bug-gdb@prep.ai.mit.edu | |
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 | gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." | |
40 | } | |
41 | ||
42 | ||
43 | ||
44 | gdb_exit | |
45 | gdb_start | |
46 | gdb_reinitialize_dir $srcdir/$subdir | |
47 | gdb_load ${binfile} | |
48 | ||
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...) | |
53 | # | |
b84b7669 MS |
54 | |
55 | gdb_test "b ending-run.c:1" ".*Breakpoint.*ending-run.c, line 1.*" \ | |
56 | "bpt at line before routine" | |
57 | ||
58 | gdb_test "b ending-run.c:13" \ | |
7dbd117d MC |
59 | ".*Note.*also.*Breakpoint 2.*ending-run.c, line 13.*" \ |
60 | "b ending-run.c:13, one" | |
c906108c SS |
61 | |
62 | # Set up to go to the next-to-last line of the program | |
63 | # | |
b84b7669 | 64 | gdb_test "b ending-run.c:31" ".*Breakpoint 3.*ending-run.c, line 31.*" |
c906108c SS |
65 | |
66 | # Expect to hit the bp at line "1", but symbolize this | |
085dd6e6 | 67 | # as line "13". Then try to clear it--this should work. |
c906108c | 68 | # |
7a292a7a | 69 | if [target_info exists use_gdb_stub] { |
a0b3c4fd | 70 | gdb_test "continue" ".*Breakpoint.*1.*callee.*13.*" |
7a292a7a | 71 | } else { |
a0b3c4fd | 72 | gdb_test "r" ".*Breakpoint.*1.*callee.*13.*" |
7a292a7a | 73 | } |
c906108c SS |
74 | gdb_test "cle" ".*Deleted breakpoints 2 1.*" "clear worked" |
75 | send_gdb "i b\n" | |
76 | gdb_expect { | |
ed4c619a | 77 | -re ".* breakpoint .* breakpoint .*$gdb_prompt $" { |
cb9a9d3e MS |
78 | fail "cleared bp at line before routine" |
79 | } | |
80 | -re ".*3.*main.*31.*$gdb_prompt $" { | |
81 | pass "cleared bp at line before routine" | |
82 | } | |
83 | -re ".*$gdb_prompt $" { | |
84 | fail "cleared bp at line before routine (info b)" | |
85 | } | |
c906108c SS |
86 | } |
87 | ||
88 | # Test some other "clear" combinations | |
89 | # | |
b84b7669 | 90 | gdb_test "b ending-run.c:1" ".*Breakpoint.*4.*" |
7dbd117d | 91 | gdb_test "b ending-run.c:13" ".*Note.*also.*Breakpoint.*5.*" "b ending-run.c:13, two" |
b84b7669 MS |
92 | gdb_test "cle ending-run.c:13" \ |
93 | ".*Deleted breakpoint 5.*" "Only cleared 1 by line" | |
c906108c | 94 | |
b84b7669 | 95 | send_gdb "inf line ending-run.c:13\n" |
c906108c SS |
96 | gdb_expect { |
97 | -re ".*address (0x\[0-9a-fA-F]*).*$gdb_prompt $" { | |
98 | set line_eight $expect_out(1,string) | |
a0b3c4fd | 99 | gdb_test "b 13" ".*Breakpoint.*6.*" |
c906108c SS |
100 | gdb_test "cle *$line_eight" ".*Deleted breakpoints 6 4.*" "Clear 2 by address" |
101 | } | |
102 | -re ".*$gdb_prompt $" { | |
103 | fail "need to fix test for new compile outcome" | |
104 | } | |
105 | } | |
106 | ||
b84b7669 | 107 | send_gdb "inf line ending-run.c:14\n" |
c906108c SS |
108 | gdb_expect { |
109 | -re ".*address (0x\[0-9a-fA-F]*).*$gdb_prompt $" { | |
110 | set line_nine $expect_out(1,string) | |
b84b7669 MS |
111 | gdb_test "b ending-run.c:14" ".*Breakpoint 7.*ending-run.c, line 14.*" |
112 | gdb_test "b *$line_nine" ".*Note.*also.*Breakpoint 8.*" | |
a0b3c4fd | 113 | gdb_test "c" ".*Breakpoint.*7.*callee.*14.*" |
c906108c SS |
114 | gdb_test "cle" ".*Deleted breakpoints 8 7.*" "Clear 2 by default" |
115 | } | |
116 | -re ".*$gdb_prompt $" { | |
117 | fail "need to fix test for new compile outcome" | |
118 | } | |
119 | } | |
120 | ||
121 | send_gdb "i b\n" | |
122 | gdb_expect { | |
ed4c619a | 123 | -re ".* breakpoint .* breakpoint .*$gdb_prompt $" { |
cb9a9d3e | 124 | fail "all set to continue (didn't clear bps)" |
c906108c | 125 | } |
085dd6e6 | 126 | -re ".*3.*main.*31.*$gdb_prompt $" { |
c906108c SS |
127 | pass "all set to continue" |
128 | } | |
129 | -re ".*$gdb_prompt $" { | |
cb9a9d3e | 130 | fail "all set to continue (missing bp at end)" |
c906108c SS |
131 | } |
132 | } | |
133 | ||
134 | ||
135 | # See if we can step out with control. The "1 2 3" stuff | |
136 | # is output from the program. | |
137 | # | |
004af6c7 DJ |
138 | if ![gdb_skip_stdio_test "cont"] { |
139 | gdb_test "cont" ".*1 2 7 14 23 34 47 62 79.*Breakpoint.*31.*" | |
140 | } else { | |
141 | gdb_test "cont" ".*Breakpoint.*31.*" | |
142 | } | |
13a5e3b8 MS |
143 | |
144 | if ![gdb_skip_stdio_test "Step to return"] { | |
808a31f5 | 145 | gdb_test "next" ".*Goodbye!.*32.*" \ |
13a5e3b8 MS |
146 | "Step to return" |
147 | } else { | |
148 | gdb_test "next" "" "" | |
149 | } | |
c906108c SS |
150 | |
151 | set old_timeout $timeout | |
152 | set timeout 50 | |
2b1a1355 | 153 | set program_exited 0 |
c906108c SS |
154 | send_gdb "next\n" |
155 | gdb_expect { | |
085dd6e6 | 156 | -re "33.*$gdb_prompt $" { |
c906108c SS |
157 | # sometimes we stop at the closing brace, if so, do another next |
158 | send_gdb "next\n" | |
159 | gdb_expect { | |
160 | -re ".*Unable to find return pc for this frame.*$gdb_prompt $" { | |
cb9a9d3e | 161 | fail "step out of main (Old bug came back!)" |
c906108c SS |
162 | gdb_test "n" ".*" "" |
163 | } | |
164 | -re ".*in.*start.*$gdb_prompt $" { | |
165 | pass "step out of main" | |
166 | } | |
9b0c4aeb FN |
167 | -re ".*in.*bsp_trap.*$gdb_prompt $" { |
168 | pass "step out of main" | |
169 | } | |
b84b7669 MS |
170 | -re ".*in.*init.*$gdb_prompt $" { |
171 | # This is what happens on sparc64-elf ultra. | |
172 | pass "step out of main" | |
173 | } | |
bf028682 CV |
174 | -re ".*in.*dll_crt0_1.*$gdb_prompt $" { |
175 | # This is what happens on Cygwin. | |
176 | pass "step out of main" | |
177 | } | |
2b1a1355 MS |
178 | -re ".*Program exited normally.*$gdb_prompt $" { |
179 | # This is what happens on Linux i86 (and I would expect others) | |
180 | set program_exited 1 | |
181 | pass "step out of main" | |
182 | } | |
104c1213 JM |
183 | -re ".*in .nope ().*$gdb_prompt $" { |
184 | # This is what happens on Solaris currently -sts 1999-08-25 | |
cb9a9d3e | 185 | pass "step out of main (on Solaris)" |
104c1213 | 186 | } |
a10c9419 | 187 | -re ".*in _int_reset ().*$gdb_prompt $" { |
84826df1 | 188 | # This is what happens on Sanyo XStormy16 |
a10c9419 CV |
189 | pass "step out of main" |
190 | } | |
6b8426a6 MH |
191 | -re ".*init ().*$gdb_prompt $" { |
192 | # This is what happens on many Mips targets | |
193 | pass "step out of main" | |
194 | } | |
8b93c638 JM |
195 | -re ".*in ..change.mode ().*$gdb_prompt $" { |
196 | # This is what happens on ARM in thumb mode -fn 2000-02-01 | |
cb9a9d3e | 197 | pass "step out of main (on ARM thumb)" |
8b93c638 | 198 | } |
085dd6e6 JM |
199 | -re ".*in.*\\\$START\\\$.*from.*dld.sl.*$gdb_prompt $" { |
200 | pass "step out of main" | |
201 | } | |
a283c5a1 | 202 | -re ".*in __wrap__?main ().*$gdb_prompt $" { |
cb9a9d3e MS |
203 | pass "step out of main (status wrapper)" |
204 | } | |
aec24853 CV |
205 | -re "__setup_argv_for_main (.*).*$gdb_prompt $" { |
206 | # On sh, another wrapper function (start_l) exists, so | |
207 | # another `next' is necessary. | |
208 | gdb_test "next" ".*in start_l ().*" "step out of main (on sh)" | |
209 | } | |
cb9a9d3e MS |
210 | -re ".*$gdb_prompt $" { fail "step out of main (at end 2)" } |
211 | timeout { | |
212 | fail "step out of main (hang or timeout on step at end 2)" | |
213 | } | |
c906108c SS |
214 | } |
215 | } | |
216 | -re ".*Unable to find return pc for this frame.*$gdb_prompt $" { | |
217 | fail "Old bug came back!" | |
218 | gdb_test "n" ".*" "" | |
219 | } | |
220 | -re ".*in.*start.*$gdb_prompt $" { | |
221 | pass "step out of main" | |
222 | } | |
085dd6e6 | 223 | -re ".*in.*\\\$START\\\$.*from.*dld.sl.*$gdb_prompt $" { |
cb9a9d3e | 224 | pass "step out of main (2)" |
085dd6e6 | 225 | } |
2b1a1355 MS |
226 | -re ".*Program exited normally.*$gdb_prompt $" { |
227 | # This is what happens on Linux i86 (and I would expect others) | |
228 | set program_exited 1 | |
229 | pass "step out of main" | |
230 | } | |
cce74817 | 231 | -re ".*in.*currently asm.*$gdb_prompt $" { |
cb9a9d3e | 232 | pass "step out of main (into assembler)" |
cce74817 JM |
233 | } |
234 | -re ".*Program received signal SIGTRAP.*$gdb_prompt $" { | |
7a292a7a | 235 | pass "Cygmon stopped in ending trap." |
cce74817 | 236 | } |
cb9a9d3e MS |
237 | -re ".*$gdb_prompt $" { fail "step out of main (at end 1)" } |
238 | timeout { fail "step out of main (hang or timeout on step at end 1)" } | |
c906108c SS |
239 | } |
240 | ||
0f815cdf JB |
241 | # When we're talking to a program running on a real stand-alone board, |
242 | # every BSP's exit function behaves differently, so there's no single | |
243 | # way to tell whether we've exited gracefully or not. So don't run | |
244 | # these tests when use_gdb_stub is set, or when we're running under Cygmon. | |
31e45dee FN |
245 | set program_exited_normally 0 |
246 | set program_not_exited 0 | |
247 | set program_in_exit 0 | |
0f815cdf JB |
248 | if {! [target_info exists use_gdb_stub] |
249 | && (! [target_info exists use_cygmon] || ! [target_info use_cygmon])} { | |
2b1a1355 MS |
250 | global program_exited; |
251 | if {[eval expr $program_exited == 0]} { | |
252 | send_gdb "n\n" | |
253 | gdb_expect { | |
254 | -re "Program exited normally.*$gdb_prompt $" { | |
255 | # If we actually have debug info for the start function, | |
256 | # then we won't get the "Single-stepping until function | |
257 | # exit" message. | |
36a22261 | 258 | pass "step to end of run" |
31e45dee | 259 | set program_exited_normally 1 |
2b1a1355 | 260 | } |
a283c5a1 | 261 | -re "Single.*EXIT code 0\r\n.*Program exited normally.*$gdb_prompt $" { |
cb9a9d3e | 262 | pass "step to end of run (status wrapper)" |
31e45dee | 263 | set program_exited_normally 1 |
cb9a9d3e | 264 | } |
afb5c968 CV |
265 | -re "Single.*EXIT code 0\r\n.*$gdb_prompt $" { |
266 | pass "step to end of run (status wrapper)" | |
267 | } | |
2b1a1355 | 268 | -re ".*Single.*Program exited.*$gdb_prompt $" { |
36a22261 | 269 | pass "step to end of run" |
31e45dee | 270 | set program_exited_normally 1 |
2b1a1355 MS |
271 | } |
272 | -re ".*Single.*in exit.*from.*dld.sl.*$gdb_prompt $" { | |
36a22261 | 273 | pass "step to end of run" |
31e45dee | 274 | set program_in_exit 1 |
2b1a1355 | 275 | } |
36a22261 CV |
276 | -re ".*Single.*_int_reset.*$gdb_prompt $" { |
277 | pass "step to end of run" | |
31e45dee FN |
278 | if {![istarget "xstormy16-*-*"]} { |
279 | set program_exited_normally 1 | |
280 | } | |
36a22261 | 281 | } |
2b1a1355 MS |
282 | -re ".*$gdb_prompt $" { |
283 | fail "step to end of run" | |
31e45dee | 284 | set program_not_exited 1 |
2b1a1355 MS |
285 | } |
286 | timeout { | |
287 | fail "(timeout) step to end of run" | |
31e45dee | 288 | set program_not_exited 1 |
2b1a1355 MS |
289 | } |
290 | } | |
291 | } | |
292 | ||
31e45dee FN |
293 | if {$program_in_exit} { |
294 | if {[gdb_test "c" ".*" "continue after exit"] == 0} { | |
295 | set program_exited_normally 1 | |
296 | } | |
297 | } else { | |
298 | unsupported "continue after exit" | |
299 | } | |
300 | ||
2b1a1355 MS |
301 | set timeout $old_timeout |
302 | ||
31e45dee FN |
303 | if {$program_exited_normally} { |
304 | gdb_test "n" ".*The program is not being run.*" "don't step after run" | |
305 | } elseif {$program_not_exited} { | |
306 | unresolved "don't step after run" | |
307 | } else { | |
308 | unsupported "don't step after run" | |
309 | } | |
2b1a1355 MS |
310 | |
311 | set exec_output [remote_exec host "ls core"] | |
312 | ||
313 | if [ regexp "core not found" $exec_output] { | |
314 | pass "No core dumped on quit" | |
7a292a7a | 315 | } else { |
2b1a1355 | 316 | if [ regexp "No such file or directory" $exec_output] { |
cb9a9d3e | 317 | pass "ls: core (No core dumped on quit)" |
2b1a1355 MS |
318 | } else { |
319 | remote_exec build "rm -f core" | |
cb9a9d3e | 320 | fail "ls: core (Core dumped on quit)" |
2b1a1355 | 321 | } |
7a292a7a | 322 | } |
c906108c SS |
323 | } |
324 | ||
325 | #remote_exec build "rm -f ${binfile}" | |
326 | return 0 | |
327 | ||
328 | ||
329 | ||
330 |