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