]>
Commit | Line | Data |
---|---|---|
6aba47ca | 1 | # Copyright 2005, 2007 Free Software Foundation, Inc. |
099ac3dd MS |
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 | if $tracelevel then { | |
21 | strace $tracelevel | |
22 | } | |
23 | ||
24 | if { ![isnative] } then { | |
25 | continue | |
26 | } | |
27 | ||
28 | # Until "set follow-fork-mode" and "catch fork" are implemented on | |
29 | # other targets... | |
30 | # | |
31 | if {![istarget "*-*-linux*"]} then { | |
32 | continue | |
33 | } | |
34 | ||
35 | set prms_id 0 | |
36 | set bug_id 0 | |
37 | ||
38 | set testfile "checkpoint" | |
39 | set srcfile ${testfile}.c | |
40 | set binfile ${objdir}/${subdir}/${testfile} | |
41 | ||
42 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { | |
b60f0898 JB |
43 | untested checkpoint.exp |
44 | return -1 | |
099ac3dd MS |
45 | } |
46 | ||
47 | # Start with a fresh gdb | |
48 | ||
49 | gdb_exit | |
50 | gdb_start | |
51 | gdb_reinitialize_dir $srcdir/$subdir | |
52 | gdb_load ${binfile} | |
53 | ||
54 | global gdb_prompt | |
55 | ||
56 | # | |
57 | # This tests gdb checkpoint and restart. | |
58 | # | |
59 | ||
60 | remote_download host ${srcdir}/${subdir}/pi.txt pi.txt | |
61 | ||
62 | runto_main | |
63 | set break1_loc [gdb_get_line_number "breakpoint 1"] | |
64 | set break2_loc [gdb_get_line_number "breakpoint 2"] | |
65 | set break3_loc [gdb_get_line_number "breakpoint 3"] | |
66 | set break4_loc [gdb_get_line_number "breakpoint 4"] | |
67 | ||
68 | gdb_breakpoint $break1_loc | |
69 | gdb_test "continue" "breakpoint 1.*" "break1 start" | |
70 | ||
71 | gdb_test "checkpoint" "" "" | |
72 | gdb_test "continue 10" "breakpoint 1.*" "break1 two" | |
73 | ||
74 | gdb_test "checkpoint" "" "" | |
75 | gdb_test "continue 10" "breakpoint 1.*" "break1 three" | |
76 | ||
77 | gdb_test "checkpoint" "" "" | |
78 | gdb_test "continue 10" "breakpoint 1.*" "break1 four" | |
79 | ||
80 | gdb_test "checkpoint" "" "" | |
81 | gdb_test "continue 10" "breakpoint 1.*" "break1 five" | |
82 | ||
83 | gdb_test "checkpoint" "" "" | |
84 | gdb_test "continue 10" "breakpoint 1.*" "break1 six" | |
85 | ||
86 | gdb_test "checkpoint" "" "" | |
87 | gdb_test "continue 10" "breakpoint 1.*" "break1 seven" | |
88 | ||
89 | gdb_test "checkpoint" "" "" | |
90 | gdb_test "continue 10" "breakpoint 1.*" "break1 eight" | |
91 | ||
92 | gdb_test "checkpoint" "" "" | |
93 | gdb_test "continue 10" "breakpoint 1.*" "break1 nine" | |
94 | ||
95 | gdb_test "checkpoint" "" "" | |
96 | gdb_test "continue 10" "breakpoint 1.*" "break1 ten" | |
97 | ||
98 | gdb_test "checkpoint" "" "" | |
99 | ||
100 | gdb_test "info checkpoints" \ | |
101 | " 10 .* 9 .* 8 .* 7 .* 6 .* 5 .* 4 .* 3 .* 2 .* 1 .*" \ | |
102 | "info checkpoints one" | |
103 | ||
104 | delete_breakpoints | |
105 | gdb_breakpoint $break2_loc | |
106 | gdb_test "continue" "breakpoint 2.*" "break2 one" | |
107 | ||
108 | gdb_test "restart 1" "Switching to .*breakpoint 1.*" "restart 1 one" | |
109 | gdb_test "print i" " = 78" "verify i 1 one" | |
110 | gdb_test "step" "if .c == EOF.*" "step in 1 one" | |
111 | gdb_test "print lines" " = 1.*" "verify lines 1 one" | |
112 | ||
113 | gdb_test "restart 2" "Switching to .*breakpoint 1.*" "restart 2 one" | |
114 | gdb_test "step" "if .c == EOF.*" "step in 2 one" | |
115 | gdb_test "print i + 1 == lines * 79" " = 1" "verify i 2 one" | |
116 | gdb_test "print lines" " = 11.*" "verify lines 2 one" | |
117 | ||
118 | gdb_test "restart 3" "Switching to .*breakpoint 1.*" "restart 3 one" | |
119 | gdb_test "step" "if .c == EOF.*" "step in 3 one" | |
120 | gdb_test "print i + 1 == lines * 79" " = 1" "verify i 3 one" | |
121 | gdb_test "print lines" " = 21.*" "verify lines 3 one" | |
122 | ||
123 | gdb_test "restart 4" "Switching to .*breakpoint 1.*" "restart 4 one" | |
124 | gdb_test "step" "if .c == EOF.*" "step in 4 one" | |
125 | gdb_test "print i + 1 == lines * 79" " = 1" "verify i 4 one" | |
126 | gdb_test "print lines" " = 31.*" "verify lines 4 one" | |
127 | ||
128 | gdb_test "restart 5" "Switching to .*breakpoint 1.*" "restart 5 one" | |
129 | gdb_test "step" "if .c == EOF.*" "step in 5 one" | |
130 | gdb_test "print i + 1 == lines * 79" " = 1" "verify i 5 one" | |
131 | gdb_test "print lines" " = 41.*" "verify lines 5 one" | |
132 | ||
133 | gdb_test "restart 6" "Switching to .*breakpoint 1.*" "restart 6 one" | |
134 | gdb_test "step" "if .c == EOF.*" "step in 6 one" | |
135 | gdb_test "print i + 1 == lines * 79" " = 1" "verify i 6 one" | |
136 | gdb_test "print lines" " = 51.*" "verify lines 6 one" | |
137 | ||
138 | gdb_test "restart 7" "Switching to .*breakpoint 1.*" "restart 7 one" | |
139 | gdb_test "step" "if .c == EOF.*" "step in 7 one" | |
140 | gdb_test "print i + 1 == lines * 79" " = 1" "verify i 7 one" | |
141 | gdb_test "print lines" " = 61.*" "verify lines 7 one" | |
142 | ||
143 | gdb_test "restart 8" "Switching to .*breakpoint 1.*" "restart 8 one" | |
144 | gdb_test "step" "if .c == EOF.*" "step in 8 one" | |
145 | gdb_test "print i + 1 == lines * 79" " = 1" "verify i 8 one" | |
146 | gdb_test "print lines" " = 71.*" "verify lines 8 one" | |
147 | ||
148 | gdb_test "restart 9" "Switching to .*breakpoint 1.*" "restart 9 one" | |
149 | gdb_test "step" "if .c == EOF.*" "step in 9 one" | |
150 | gdb_test "print i + 1 == lines * 79" " = 1" "verify i 9 one" | |
151 | gdb_test "print lines" " = 81.*" "verify lines 9 one" | |
152 | ||
153 | gdb_test "restart 10" "Switching to .*breakpoint 1.*" "restart 10 one" | |
154 | gdb_test "step" "if .c == EOF.*" "step in 10 one" | |
155 | gdb_test "print i + 1 == lines * 79" " = 1" "verify i 10 one" | |
156 | gdb_test "print lines" " = 91.*" "verify lines 10 one" | |
157 | ||
158 | # | |
159 | # Now let the files be closed by the original process, | |
160 | # and diff them. | |
161 | ||
162 | gdb_test "restart 0" "Switching to .*breakpoint 2.*" "restart 0 one" | |
163 | gdb_breakpoint $break3_loc | |
164 | gdb_test "continue" "breakpoint 3.*" "break3 one" | |
165 | ||
166 | gdb_test "shell diff -s pi.txt copy1.txt" \ | |
167 | "Files pi.txt and copy1.txt are identical.*" \ | |
168 | "Diff input and output one" | |
169 | ||
170 | # | |
171 | # And now run from various checkpoints, allowing | |
172 | # various amounts of input and output. | |
173 | # | |
174 | ||
175 | gdb_breakpoint $break1_loc | |
176 | ||
177 | gdb_test "restart 1" "Switching to .*c == EOF.*" "restart 1 two" | |
178 | gdb_test "continue" "" "" | |
179 | gdb_test "continue 100" "breakpoint 1.*" "breakpoint 1 1 one" | |
180 | gdb_test "step" "if .c == EOF.*" "step in 1 two" | |
181 | gdb_test "print lines" " = 102.*" "verify lines 1 two" | |
182 | ||
183 | gdb_test "restart 2" "Switching to .*c == EOF.*" "restart 2 two" | |
184 | gdb_test "continue" "" "" | |
185 | gdb_test "continue 100" "breakpoint 1.*" "breakpoint 1 2 one" | |
186 | gdb_test "step" "if .c == EOF.*" "step in 2 two" | |
187 | gdb_test "print lines" " = 112.*" "verify lines 2 two" | |
188 | ||
189 | gdb_test "restart 3" "Switching to .*c == EOF.*" "restart 3 two" | |
190 | gdb_test "continue" "" "" | |
191 | gdb_test "continue 500" "breakpoint 1.*" "breakpoint 1 3 one" | |
192 | gdb_test "step" "if .c == EOF.*" "step in 3 two" | |
193 | gdb_test "print lines" " = 522.*" "verify lines 3 two" | |
194 | ||
195 | gdb_test "restart 4" "Switching to .*c == EOF.*" "restart 4 two" | |
196 | gdb_test "continue" "" "" | |
197 | gdb_test "continue 500" "breakpoint 1.*" "breakpoint 1 4 one" | |
198 | gdb_test "step" "if .c == EOF.*" "step in 4 two" | |
199 | gdb_test "print lines" " = 532.*" "verify lines 4 two" | |
200 | ||
201 | gdb_test "restart 5" "Switching to .*c == EOF.*" "restart 5 two" | |
202 | gdb_test "continue" "" "" | |
203 | gdb_test "continue 1000" "breakpoint 1.*" "breakpoint 1 5 one" | |
204 | gdb_test "step" "if .c == EOF.*" "step in 5 two" | |
205 | gdb_test "print lines" " = 1042.*" "verify lines 5 two" | |
206 | ||
207 | gdb_test "restart 6" "Switching to .*c == EOF.*" "restart 6 two" | |
208 | gdb_test "continue" "" "" | |
209 | gdb_test "continue 1000" "breakpoint 1.*" "breakpoint 1 6 one" | |
210 | gdb_test "step" "if .c == EOF.*" "step in 6 two" | |
211 | gdb_test "print lines" " = 1052.*" "verify lines 5 two" | |
212 | ||
213 | gdb_test "restart 7" "Switching to .*c == EOF.*" "restart 7 two" | |
214 | gdb_test "continue" "" "" | |
215 | gdb_test "continue 1100" "breakpoint 1.*" "breakpoint 1 7 one" | |
216 | gdb_test "step" "if .c == EOF.*" "step in 7 two" | |
217 | gdb_test "print lines" " = 1162.*" "verify lines 7 two" | |
218 | ||
219 | gdb_test "shell diff -s pi.txt copy1.txt" \ | |
220 | "Files pi.txt and copy1.txt are identical.*" \ | |
221 | "Diff input and output two" | |
222 | ||
223 | # | |
224 | # OK, now allow the original program to delete the output file, | |
225 | # and verify that the checkpoints can still write to it. | |
226 | # | |
227 | ||
228 | gdb_test "restart 0" "Switching to .*breakpoint 3.*" "restart 0 one" | |
229 | gdb_breakpoint $break4_loc | |
230 | gdb_test "continue" "breakpoint 4.*" "break4 one" | |
231 | ||
232 | gdb_test "shell diff pi.txt copy1.txt" \ | |
233 | "diff: copy1.txt: No such file or directory" \ | |
234 | "delete copy1" | |
235 | ||
236 | delete_breakpoints | |
237 | gdb_breakpoint $break2_loc | |
238 | ||
239 | gdb_test "restart 1" "if .c == EOF.*" "restart 1 three" | |
240 | gdb_test "continue" "breakpoint 2.*" "break2 1 one" | |
241 | gdb_test "print ftell (out) > 100000" " = 1.*" "outfile still open 1" | |
242 | ||
243 | gdb_test "restart 2" "if .c == EOF.*" "restart 1 three" | |
244 | gdb_test "continue" "breakpoint 2.*" "break2 2 one" | |
245 | gdb_test "print ftell (out) > 100000" " = 1.*" "outfile still open 2" | |
246 | ||
247 | gdb_test "restart 3" "if .c == EOF.*" "restart 1 three" | |
248 | gdb_test "continue" "breakpoint 2.*" "break2 3 one" | |
249 | gdb_test "print ftell (out) > 100000" " = 1.*" "outfile still open 3" | |
250 | ||
251 | gdb_test "restart 4" "if .c == EOF.*" "restart 1 three" | |
252 | gdb_test "continue" "breakpoint 2.*" "break2 4 one" | |
253 | gdb_test "print ftell (out) > 100000" " = 1.*" "outfile still open 4" | |
254 | ||
255 | gdb_test "restart 5" "if .c == EOF.*" "restart 1 three" | |
256 | gdb_test "continue" "breakpoint 2.*" "break2 5 one" | |
257 | gdb_test "print ftell (out) > 100000" " = 1.*" "outfile still open 5" | |
258 | ||
259 | gdb_test "restart 6" "if .c == EOF.*" "restart 1 three" | |
260 | gdb_test "continue" "breakpoint 2.*" "break2 6 one" | |
261 | gdb_test "print ftell (out) > 100000" " = 1.*" "outfile still open 6" | |
262 | ||
263 | gdb_test "restart 7" "if .c == EOF.*" "restart 1 three" | |
264 | gdb_test "continue" "breakpoint 2.*" "break2 7 one" | |
265 | gdb_test "print ftell (out) > 100000" " = 1.*" "outfile still open 7" | |
266 | ||
267 | gdb_test "restart 8" "if .c == EOF.*" "restart 1 three" | |
268 | gdb_test "continue" "breakpoint 2.*" "break2 8 one" | |
269 | gdb_test "print ftell (out) > 100000" " = 1.*" "outfile still open 8" | |
270 | ||
271 | gdb_test "restart 9" "if .c == EOF.*" "restart 1 three" | |
272 | gdb_test "continue" "breakpoint 2.*" "break2 9 one" | |
273 | gdb_test "print ftell (out) > 100000" " = 1.*" "outfile still open 9" | |
274 | ||
275 | gdb_test "restart 10" "if .c == EOF.*" "restart 1 three" | |
276 | gdb_test "continue" "breakpoint 2.*" "break2 10 one" | |
277 | gdb_test "print ftell (out) > 100000" " = 1.*" "outfile still open 10" | |
278 | ||
279 | # | |
280 | # Now confirm that if one fork exits, we automatically switch to another one. | |
281 | # | |
282 | ||
283 | delete_breakpoints | |
284 | gdb_test "continue" \ | |
285 | "Deleting copy.*Program exited normally.*Switching to.*" \ | |
286 | "Exit, dropped into next fork one" | |
287 | ||
288 | gdb_test "continue" \ | |
289 | "Deleting copy.*Program exited normally.*Switching to.*" \ | |
290 | "Exit, dropped into next fork two" | |
291 | ||
292 | gdb_test "continue" \ | |
293 | "Deleting copy.*Program exited normally.*Switching to.*" \ | |
294 | "Exit, dropped into next fork three" | |
295 | ||
296 | gdb_test "continue" \ | |
297 | "Deleting copy.*Program exited normally.*Switching to.*" \ | |
298 | "Exit, dropped into next fork four" | |
299 | ||
300 | gdb_test "continue" \ | |
301 | "Deleting copy.*Program exited normally.*Switching to.*" \ | |
302 | "Exit, dropped into next fork five" | |
303 | ||
304 | # | |
305 | # There should be still at least five forks left | |
306 | # | |
307 | ||
308 | gdb_test "info checkpoints" " 5 .* 4 .* 3 .* 2 .* 1 .*" \ | |
309 | "info checkpoints two" | |
310 | ||
311 | # | |
312 | # Kill should now terminate all of them. | |
313 | # | |
314 | ||
315 | gdb_test "kill" "" "kill all one" \ | |
316 | "Kill the program being debugged.*y or n. $" "y" | |
317 | ||
318 | # | |
319 | # and confirm that all are gone | |
320 | # | |
321 | ||
322 | gdb_test "restart 0" "Not found.*" "no more checkpoint 0" | |
323 | gdb_test "restart 1" "Not found.*" "no more checkpoint 1" | |
324 | gdb_test "restart 2" "Not found.*" "no more checkpoint 2" | |
325 | gdb_test "restart 3" "Not found.*" "no more checkpoint 3" | |
326 | gdb_test "restart 4" "Not found.*" "no more checkpoint 4" | |
327 | gdb_test "restart 5" "Not found.*" "no more checkpoint 5" | |
328 | gdb_test "restart 6" "Not found.*" "no more checkpoint 6" | |
329 | gdb_test "restart 7" "Not found.*" "no more checkpoint 7" | |
330 | gdb_test "restart 8" "Not found.*" "no more checkpoint 8" | |
331 | gdb_test "restart 9" "Not found.*" "no more checkpoint 9" | |
332 | gdb_test "restart 10" "Not found.*" "no more checkpoint 10" | |
333 | ||
334 | # | |
335 | # Now let's try setting a large number of checkpoints (>1000) | |
336 | # | |
337 | ||
338 | gdb_exit | |
339 | gdb_start | |
340 | gdb_reinitialize_dir $srcdir/$subdir | |
341 | gdb_load ${binfile} | |
342 | ||
343 | runto_main | |
344 | gdb_breakpoint $break1_loc | |
345 | ||
346 | send_gdb "commands\n" | |
347 | send_gdb " silent\n" | |
348 | send_gdb " if (lines % 2)\n" | |
349 | send_gdb " checkpoint\n" | |
350 | send_gdb " end\n" | |
351 | send_gdb " continue\n" | |
352 | send_gdb "end\n" | |
353 | ||
354 | gdb_expect { | |
355 | -re ".*$gdb_prompt $" { pass "set checkpoint breakpoint" } | |
356 | timeout { fail "(timeout) set checkpoint breakpoint" } | |
357 | } | |
358 | ||
359 | gdb_breakpoint $break2_loc | |
360 | gdb_test "continue" "breakpoint 2.*" "break2 with many checkpoints" | |
361 | ||
362 | gdb_test "info checkpoints" " 600 .* 0 .*" \ | |
363 | "info checkpoints with at least 600 checkpoints" | |
364 | ||
365 | # | |
366 | # OK, kill 'em all... | |
367 | # | |
368 | ||
369 | gdb_test "kill" "" "kill all one" \ | |
370 | "Kill the program being debugged.*y or n. $" "y" | |
371 | ||
372 | # | |
373 | # Finished: cleanup | |
374 | # | |
375 | ||
376 | remote_exec build "rm -f pi.txt" |