Commit | Line | Data |
---|---|---|
1bf404ef AC |
1 | # This testcase is part of GDB, the GNU debugger. |
2 | ||
0fb0cc75 | 3 | # Copyright 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2007, 2008, 2009 |
6aba47ca | 4 | # Free 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 | |
e22f8b7c | 8 | # the Free Software Foundation; either version 3 of the License, or |
c906108c | 9 | # (at your option) any later version. |
e22f8b7c | 10 | # |
c906108c SS |
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. | |
e22f8b7c | 15 | # |
c906108c | 16 | # You should have received a copy of the GNU General Public License |
e22f8b7c | 17 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
c906108c SS |
18 | |
19 | # use this to debug: | |
20 | # | |
21 | #log_user 1 | |
22 | ||
23 | # ending-run.exp -- Expect script to test ending a test run in gdb | |
24 | ||
dbc52822 VP |
25 | if { [prepare_for_testing ending-run.exp ending-run] } { |
26 | return -1 | |
c906108c | 27 | } |
c906108c SS |
28 | remote_exec build "rm -f core" |
29 | ||
c906108c SS |
30 | # CHFts23469: Test that you can "clear" a bp set at |
31 | # a line _before_ the routine (which will default to the | |
32 | # first line in the routine, which turns out to correspond | |
33 | # to the prolog--that's another bug...) | |
34 | # | |
b84b7669 MS |
35 | |
36 | gdb_test "b ending-run.c:1" ".*Breakpoint.*ending-run.c, line 1.*" \ | |
37 | "bpt at line before routine" | |
38 | ||
b40e7bf3 JB |
39 | gdb_test "b ending-run.c:14" \ |
40 | ".*Note.*also.*Breakpoint 2.*ending-run.c, line 14.*" \ | |
41 | "b ending-run.c:14, one" | |
c906108c SS |
42 | |
43 | # Set up to go to the next-to-last line of the program | |
44 | # | |
b84b7669 | 45 | gdb_test "b ending-run.c:31" ".*Breakpoint 3.*ending-run.c, line 31.*" |
c906108c SS |
46 | |
47 | # Expect to hit the bp at line "1", but symbolize this | |
085dd6e6 | 48 | # as line "13". Then try to clear it--this should work. |
c906108c | 49 | # |
b741e217 | 50 | gdb_run_cmd |
b40e7bf3 | 51 | gdb_test "" ".*Breakpoint.*1.*callee.*14.*" "run" |
b741e217 | 52 | |
d6e956e5 | 53 | gdb_test "cle" ".*Deleted breakpoints 1 2.*" "clear worked" |
c906108c SS |
54 | send_gdb "i b\n" |
55 | gdb_expect { | |
ed4c619a | 56 | -re ".* breakpoint .* breakpoint .*$gdb_prompt $" { |
cb9a9d3e MS |
57 | fail "cleared bp at line before routine" |
58 | } | |
59 | -re ".*3.*main.*31.*$gdb_prompt $" { | |
60 | pass "cleared bp at line before routine" | |
61 | } | |
62 | -re ".*$gdb_prompt $" { | |
63 | fail "cleared bp at line before routine (info b)" | |
64 | } | |
c906108c SS |
65 | } |
66 | ||
67 | # Test some other "clear" combinations | |
68 | # | |
b84b7669 | 69 | gdb_test "b ending-run.c:1" ".*Breakpoint.*4.*" |
b40e7bf3 JB |
70 | gdb_test "b ending-run.c:14" ".*Note.*also.*Breakpoint.*5.*" "b ending-run.c:14, two" |
71 | gdb_test "cle ending-run.c:14" \ | |
72 | ".*Deleted breakpoints 4 5.*" "Cleared 2 by line" | |
c906108c | 73 | |
b84b7669 | 74 | send_gdb "inf line ending-run.c:14\n" |
c906108c SS |
75 | gdb_expect { |
76 | -re ".*address (0x\[0-9a-fA-F]*).*$gdb_prompt $" { | |
77 | set line_nine $expect_out(1,string) | |
b40e7bf3 JB |
78 | gdb_test "b ending-run.c:14" ".*Breakpoint 6.*ending-run.c, line 14.*" |
79 | gdb_test "b *$line_nine" ".*Note.*also.*Breakpoint 7.*" "Breakpoint 7 at *ending-run.c:14" | |
80 | gdb_test "cle" ".*Deleted breakpoints 6 7.*" "Clear 2 by default" | |
c906108c SS |
81 | } |
82 | -re ".*$gdb_prompt $" { | |
83 | fail "need to fix test for new compile outcome" | |
84 | } | |
85 | } | |
86 | ||
87 | send_gdb "i b\n" | |
88 | gdb_expect { | |
ed4c619a | 89 | -re ".* breakpoint .* breakpoint .*$gdb_prompt $" { |
cb9a9d3e | 90 | fail "all set to continue (didn't clear bps)" |
c906108c | 91 | } |
085dd6e6 | 92 | -re ".*3.*main.*31.*$gdb_prompt $" { |
c906108c SS |
93 | pass "all set to continue" |
94 | } | |
95 | -re ".*$gdb_prompt $" { | |
cb9a9d3e | 96 | fail "all set to continue (missing bp at end)" |
c906108c SS |
97 | } |
98 | } | |
99 | ||
100 | ||
101 | # See if we can step out with control. The "1 2 3" stuff | |
102 | # is output from the program. | |
103 | # | |
004af6c7 DJ |
104 | if ![gdb_skip_stdio_test "cont"] { |
105 | gdb_test "cont" ".*1 2 7 14 23 34 47 62 79.*Breakpoint.*31.*" | |
106 | } else { | |
107 | gdb_test "cont" ".*Breakpoint.*31.*" | |
108 | } | |
13a5e3b8 MS |
109 | |
110 | if ![gdb_skip_stdio_test "Step to return"] { | |
808a31f5 | 111 | gdb_test "next" ".*Goodbye!.*32.*" \ |
13a5e3b8 MS |
112 | "Step to return" |
113 | } else { | |
114 | gdb_test "next" "" "" | |
115 | } | |
c906108c SS |
116 | |
117 | set old_timeout $timeout | |
118 | set timeout 50 | |
2b1a1355 | 119 | set program_exited 0 |
c906108c | 120 | send_gdb "next\n" |
697bc68d | 121 | set nexted 0 |
c906108c | 122 | gdb_expect { |
085dd6e6 | 123 | -re "33.*$gdb_prompt $" { |
c906108c | 124 | # sometimes we stop at the closing brace, if so, do another next |
697bc68d NS |
125 | if { $nexted } { |
126 | fail "step out of main" | |
127 | } else { | |
128 | set nexted 1 | |
129 | send_gdb "next\n" | |
130 | exp_continue | |
c906108c SS |
131 | } |
132 | } | |
133 | -re ".*Unable to find return pc for this frame.*$gdb_prompt $" { | |
697bc68d NS |
134 | fail "step out of main" |
135 | gdb_test "n" ".*" "" | |
c906108c SS |
136 | } |
137 | -re ".*in.*start.*$gdb_prompt $" { | |
697bc68d NS |
138 | pass "step out of main" |
139 | } | |
140 | -re ".*in.*bsp_trap.*$gdb_prompt $" { | |
141 | pass "step out of main" | |
c906108c | 142 | } |
697bc68d NS |
143 | -re ".*in.*init.*$gdb_prompt $" { |
144 | # This is what happens on sparc64-elf ultra. | |
145 | pass "step out of main" | |
146 | } | |
147 | -re ".*in.*dll_crt0_1.*$gdb_prompt $" { | |
148 | # This is what happens on Cygwin. | |
149 | pass "step out of main" | |
085dd6e6 | 150 | } |
2b1a1355 MS |
151 | -re ".*Program exited normally.*$gdb_prompt $" { |
152 | # This is what happens on Linux i86 (and I would expect others) | |
153 | set program_exited 1 | |
154 | pass "step out of main" | |
155 | } | |
697bc68d NS |
156 | -re ".*in .nope ().*$gdb_prompt $" { |
157 | # This is what happens on Solaris currently -sts 1999-08-25 | |
158 | pass "step out of main" | |
159 | } | |
160 | -re ".*in _int_reset ().*$gdb_prompt $" { | |
161 | # This is what happens on Sanyo XStormy16 | |
162 | pass "step out of main" | |
163 | } | |
164 | -re ".*init ().*$gdb_prompt $" { | |
165 | # This is what happens on many Mips targets | |
166 | pass "step out of main" | |
167 | } | |
168 | -re ".*in ..change.mode ().*$gdb_prompt $" { | |
169 | # This is what happens on ARM in thumb mode -fn 2000-02-01 | |
170 | pass "step out of main" | |
171 | } | |
172 | -re ".*__rt_entry ().*$gdb_prompt $" { | |
173 | # This is what happens on the ARM RVDS runtime | |
174 | pass "step out of main" | |
175 | } | |
176 | -re ".*in.*\\\$START\\\$.*from.*dld.sl.*$gdb_prompt $" { | |
177 | pass "step out of main" | |
178 | } | |
179 | -re ".*in __wrap__?main ().*$gdb_prompt $" { | |
180 | pass "step out of main" | |
181 | } | |
182 | -re "__setup_argv_for_main (.*).*$gdb_prompt $" { | |
183 | # On sh, another wrapper function (start_l) exists, so | |
184 | # another `next' is necessary. | |
185 | gdb_test "next" ".*in start_l ().*" "step out of main" | |
186 | } | |
cce74817 | 187 | -re ".*in.*currently asm.*$gdb_prompt $" { |
697bc68d NS |
188 | pass "step out of main" |
189 | } | |
190 | -re "_*start\[0-9\]* \\(\[^)\]*\\).*$gdb_prompt $" { | |
191 | pass "step out of main" | |
cce74817 JM |
192 | } |
193 | -re ".*Program received signal SIGTRAP.*$gdb_prompt $" { | |
697bc68d | 194 | pass "step out of main" |
cce74817 | 195 | } |
697bc68d NS |
196 | -re ".*$gdb_prompt $" { fail "step out of main" } |
197 | timeout { fail "step out of main" } | |
c906108c SS |
198 | } |
199 | ||
0f815cdf JB |
200 | # When we're talking to a program running on a real stand-alone board, |
201 | # every BSP's exit function behaves differently, so there's no single | |
202 | # way to tell whether we've exited gracefully or not. So don't run | |
203 | # these tests when use_gdb_stub is set, or when we're running under Cygmon. | |
31e45dee FN |
204 | set program_exited_normally 0 |
205 | set program_not_exited 0 | |
206 | set program_in_exit 0 | |
0f815cdf JB |
207 | if {! [target_info exists use_gdb_stub] |
208 | && (! [target_info exists use_cygmon] || ! [target_info use_cygmon])} { | |
2b1a1355 MS |
209 | global program_exited; |
210 | if {[eval expr $program_exited == 0]} { | |
211 | send_gdb "n\n" | |
212 | gdb_expect { | |
213 | -re "Program exited normally.*$gdb_prompt $" { | |
214 | # If we actually have debug info for the start function, | |
215 | # then we won't get the "Single-stepping until function | |
216 | # exit" message. | |
36a22261 | 217 | pass "step to end of run" |
31e45dee | 218 | set program_exited_normally 1 |
2b1a1355 | 219 | } |
a283c5a1 | 220 | -re "Single.*EXIT code 0\r\n.*Program exited normally.*$gdb_prompt $" { |
cb9a9d3e | 221 | pass "step to end of run (status wrapper)" |
31e45dee | 222 | set program_exited_normally 1 |
cb9a9d3e | 223 | } |
afb5c968 CV |
224 | -re "Single.*EXIT code 0\r\n.*$gdb_prompt $" { |
225 | pass "step to end of run (status wrapper)" | |
226 | } | |
2b1a1355 | 227 | -re ".*Single.*Program exited.*$gdb_prompt $" { |
36a22261 | 228 | pass "step to end of run" |
31e45dee | 229 | set program_exited_normally 1 |
2b1a1355 MS |
230 | } |
231 | -re ".*Single.*in exit.*from.*dld.sl.*$gdb_prompt $" { | |
36a22261 | 232 | pass "step to end of run" |
31e45dee | 233 | set program_in_exit 1 |
2b1a1355 | 234 | } |
36a22261 CV |
235 | -re ".*Single.*_int_reset.*$gdb_prompt $" { |
236 | pass "step to end of run" | |
31e45dee FN |
237 | if {![istarget "xstormy16-*-*"]} { |
238 | set program_exited_normally 1 | |
239 | } | |
36a22261 | 240 | } |
2b1a1355 MS |
241 | -re ".*$gdb_prompt $" { |
242 | fail "step to end of run" | |
31e45dee | 243 | set program_not_exited 1 |
2b1a1355 MS |
244 | } |
245 | timeout { | |
246 | fail "(timeout) step to end of run" | |
31e45dee | 247 | set program_not_exited 1 |
2b1a1355 MS |
248 | } |
249 | } | |
250 | } | |
251 | ||
31e45dee FN |
252 | if {$program_in_exit} { |
253 | if {[gdb_test "c" ".*" "continue after exit"] == 0} { | |
254 | set program_exited_normally 1 | |
255 | } | |
256 | } else { | |
257 | unsupported "continue after exit" | |
258 | } | |
259 | ||
2b1a1355 MS |
260 | set timeout $old_timeout |
261 | ||
31e45dee FN |
262 | if {$program_exited_normally} { |
263 | gdb_test "n" ".*The program is not being run.*" "don't step after run" | |
264 | } elseif {$program_not_exited} { | |
265 | unresolved "don't step after run" | |
266 | } else { | |
267 | unsupported "don't step after run" | |
268 | } | |
2b1a1355 MS |
269 | |
270 | set exec_output [remote_exec host "ls core"] | |
271 | ||
272 | if [ regexp "core not found" $exec_output] { | |
273 | pass "No core dumped on quit" | |
7a292a7a | 274 | } else { |
2b1a1355 | 275 | if [ regexp "No such file or directory" $exec_output] { |
cb9a9d3e | 276 | pass "ls: core (No core dumped on quit)" |
2b1a1355 MS |
277 | } else { |
278 | remote_exec build "rm -f core" | |
cb9a9d3e | 279 | fail "ls: core (Core dumped on quit)" |
2b1a1355 | 280 | } |
7a292a7a | 281 | } |
c906108c SS |
282 | } |
283 | ||
284 | #remote_exec build "rm -f ${binfile}" | |
285 | return 0 | |
286 | ||
287 | ||
288 | ||
289 |