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 { | |
77 | -re ".*breakpoint.*breakpoint.*$gdb_prompt $" { fail "clear bp" } | |
085dd6e6 | 78 | -re ".*3.*main.*31.*$gdb_prompt $" { pass "cleared bp at line before routine" } |
c906108c SS |
79 | -re ".*$gdb_prompt $" { fail "info b" } |
80 | } | |
81 | ||
82 | # Test some other "clear" combinations | |
83 | # | |
b84b7669 | 84 | gdb_test "b ending-run.c:1" ".*Breakpoint.*4.*" |
7dbd117d | 85 | gdb_test "b ending-run.c:13" ".*Note.*also.*Breakpoint.*5.*" "b ending-run.c:13, two" |
b84b7669 MS |
86 | gdb_test "cle ending-run.c:13" \ |
87 | ".*Deleted breakpoint 5.*" "Only cleared 1 by line" | |
c906108c | 88 | |
b84b7669 | 89 | send_gdb "inf line ending-run.c:13\n" |
c906108c SS |
90 | gdb_expect { |
91 | -re ".*address (0x\[0-9a-fA-F]*).*$gdb_prompt $" { | |
92 | set line_eight $expect_out(1,string) | |
a0b3c4fd | 93 | gdb_test "b 13" ".*Breakpoint.*6.*" |
c906108c SS |
94 | gdb_test "cle *$line_eight" ".*Deleted breakpoints 6 4.*" "Clear 2 by address" |
95 | } | |
96 | -re ".*$gdb_prompt $" { | |
97 | fail "need to fix test for new compile outcome" | |
98 | } | |
99 | } | |
100 | ||
b84b7669 | 101 | send_gdb "inf line ending-run.c:14\n" |
c906108c SS |
102 | gdb_expect { |
103 | -re ".*address (0x\[0-9a-fA-F]*).*$gdb_prompt $" { | |
104 | set line_nine $expect_out(1,string) | |
b84b7669 MS |
105 | gdb_test "b ending-run.c:14" ".*Breakpoint 7.*ending-run.c, line 14.*" |
106 | gdb_test "b *$line_nine" ".*Note.*also.*Breakpoint 8.*" | |
a0b3c4fd | 107 | gdb_test "c" ".*Breakpoint.*7.*callee.*14.*" |
c906108c SS |
108 | gdb_test "cle" ".*Deleted breakpoints 8 7.*" "Clear 2 by default" |
109 | } | |
110 | -re ".*$gdb_prompt $" { | |
111 | fail "need to fix test for new compile outcome" | |
112 | } | |
113 | } | |
114 | ||
115 | send_gdb "i b\n" | |
116 | gdb_expect { | |
117 | -re ".*breakpoint.*breakpoint.*$gdb_prompt $" { | |
118 | fail "didn't clear bps" | |
119 | } | |
085dd6e6 | 120 | -re ".*3.*main.*31.*$gdb_prompt $" { |
c906108c SS |
121 | pass "all set to continue" |
122 | } | |
123 | -re ".*$gdb_prompt $" { | |
124 | fail "missing bp at end" | |
125 | } | |
126 | } | |
127 | ||
128 | ||
129 | # See if we can step out with control. The "1 2 3" stuff | |
130 | # is output from the program. | |
131 | # | |
004af6c7 DJ |
132 | if ![gdb_skip_stdio_test "cont"] { |
133 | gdb_test "cont" ".*1 2 7 14 23 34 47 62 79.*Breakpoint.*31.*" | |
134 | } else { | |
135 | gdb_test "cont" ".*Breakpoint.*31.*" | |
136 | } | |
13a5e3b8 MS |
137 | |
138 | if ![gdb_skip_stdio_test "Step to return"] { | |
808a31f5 | 139 | gdb_test "next" ".*Goodbye!.*32.*" \ |
13a5e3b8 MS |
140 | "Step to return" |
141 | } else { | |
142 | gdb_test "next" "" "" | |
143 | } | |
c906108c SS |
144 | |
145 | set old_timeout $timeout | |
146 | set timeout 50 | |
2b1a1355 | 147 | set program_exited 0 |
c906108c SS |
148 | send_gdb "next\n" |
149 | gdb_expect { | |
085dd6e6 | 150 | -re "33.*$gdb_prompt $" { |
c906108c SS |
151 | # sometimes we stop at the closing brace, if so, do another next |
152 | send_gdb "next\n" | |
153 | gdb_expect { | |
154 | -re ".*Unable to find return pc for this frame.*$gdb_prompt $" { | |
155 | fail "Old bug came back!" | |
156 | gdb_test "n" ".*" "" | |
157 | } | |
158 | -re ".*in.*start.*$gdb_prompt $" { | |
159 | pass "step out of main" | |
160 | } | |
9b0c4aeb FN |
161 | -re ".*in.*bsp_trap.*$gdb_prompt $" { |
162 | pass "step out of main" | |
163 | } | |
b84b7669 MS |
164 | -re ".*in.*init.*$gdb_prompt $" { |
165 | # This is what happens on sparc64-elf ultra. | |
166 | pass "step out of main" | |
167 | } | |
2b1a1355 MS |
168 | -re ".*Program exited normally.*$gdb_prompt $" { |
169 | # This is what happens on Linux i86 (and I would expect others) | |
170 | set program_exited 1 | |
171 | pass "step out of main" | |
172 | } | |
104c1213 JM |
173 | -re ".*in .nope ().*$gdb_prompt $" { |
174 | # This is what happens on Solaris currently -sts 1999-08-25 | |
175 | pass "step out of main on Solaris" | |
176 | } | |
a10c9419 | 177 | -re ".*in _int_reset ().*$gdb_prompt $" { |
84826df1 | 178 | # This is what happens on Sanyo XStormy16 |
a10c9419 CV |
179 | pass "step out of main" |
180 | } | |
6b8426a6 MH |
181 | -re ".*init ().*$gdb_prompt $" { |
182 | # This is what happens on many Mips targets | |
183 | pass "step out of main" | |
184 | } | |
8b93c638 JM |
185 | -re ".*in ..change.mode ().*$gdb_prompt $" { |
186 | # This is what happens on ARM in thumb mode -fn 2000-02-01 | |
187 | pass "step out of main on ARM thumb" | |
188 | } | |
085dd6e6 JM |
189 | -re ".*in.*\\\$START\\\$.*from.*dld.sl.*$gdb_prompt $" { |
190 | pass "step out of main" | |
191 | } | |
0f71a2f6 | 192 | -re ".*$gdb_prompt $" { fail "step at end 2" } |
c906108c SS |
193 | timeout { fail "hang or timeout on step at end 2" } |
194 | } | |
195 | } | |
196 | -re ".*Unable to find return pc for this frame.*$gdb_prompt $" { | |
197 | fail "Old bug came back!" | |
198 | gdb_test "n" ".*" "" | |
199 | } | |
200 | -re ".*in.*start.*$gdb_prompt $" { | |
201 | pass "step out of main" | |
202 | } | |
085dd6e6 JM |
203 | -re ".*in.*\\\$START\\\$.*from.*dld.sl.*$gdb_prompt $" { |
204 | pass "step out of main 2" | |
205 | } | |
2b1a1355 MS |
206 | -re ".*Program exited normally.*$gdb_prompt $" { |
207 | # This is what happens on Linux i86 (and I would expect others) | |
208 | set program_exited 1 | |
209 | pass "step out of main" | |
210 | } | |
cce74817 JM |
211 | -re ".*in.*currently asm.*$gdb_prompt $" { |
212 | pass "step out of main into assembler" | |
213 | } | |
214 | -re ".*Program received signal SIGTRAP.*$gdb_prompt $" { | |
7a292a7a | 215 | pass "Cygmon stopped in ending trap." |
cce74817 | 216 | } |
0f71a2f6 | 217 | -re ".*$gdb_prompt $" { fail "step at end 1" } |
c906108c SS |
218 | timeout { fail "hang or timeout on step at end 1" } |
219 | } | |
220 | ||
7a292a7a | 221 | if {![target_info exists use_cygmon] || ![target_info use_cygmon]} { |
2b1a1355 MS |
222 | global program_exited; |
223 | if {[eval expr $program_exited == 0]} { | |
224 | send_gdb "n\n" | |
225 | gdb_expect { | |
226 | -re "Program exited normally.*$gdb_prompt $" { | |
227 | # If we actually have debug info for the start function, | |
228 | # then we won't get the "Single-stepping until function | |
229 | # exit" message. | |
36a22261 | 230 | pass "step to end of run" |
2b1a1355 MS |
231 | } |
232 | -re ".*Single.*Program exited.*$gdb_prompt $" { | |
36a22261 | 233 | pass "step to end of run" |
2b1a1355 MS |
234 | } |
235 | -re ".*Single.*in exit.*from.*dld.sl.*$gdb_prompt $" { | |
36a22261 | 236 | pass "step to end of run" |
2b1a1355 MS |
237 | gdb_test "c" ".*" "continue after exit" |
238 | } | |
36a22261 CV |
239 | -re ".*Single.*_int_reset.*$gdb_prompt $" { |
240 | pass "step to end of run" | |
84826df1 | 241 | setup_xfail "xstormy16-*-*" |
36a22261 | 242 | } |
2b1a1355 MS |
243 | -re ".*$gdb_prompt $" { |
244 | fail "step to end of run" | |
245 | } | |
246 | timeout { | |
247 | fail "(timeout) step to end of run" | |
248 | } | |
249 | } | |
250 | } | |
251 | ||
252 | set timeout $old_timeout | |
253 | ||
254 | gdb_test "n" ".*The program is not being run.*" "don't step after run" | |
255 | ||
256 | set exec_output [remote_exec host "ls core"] | |
257 | ||
258 | if [ regexp "core not found" $exec_output] { | |
259 | pass "No core dumped on quit" | |
7a292a7a | 260 | } else { |
2b1a1355 MS |
261 | if [ regexp "No such file or directory" $exec_output] { |
262 | pass "ls: core: No core dumped on quit" | |
263 | } else { | |
264 | remote_exec build "rm -f core" | |
265 | fail "Core dumped on quit" | |
266 | } | |
7a292a7a | 267 | } |
c906108c SS |
268 | } |
269 | ||
270 | #remote_exec build "rm -f ${binfile}" | |
271 | return 0 | |
272 | ||
273 | ||
274 | ||
275 |