]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.base/checkpoint.exp
Fix more cases of improper test names
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / checkpoint.exp
CommitLineData
618f726f 1# Copyright 2005-2016 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
e22f8b7c 5# the Free Software Foundation; either version 3 of the License, or
099ac3dd 6# (at your option) any later version.
e22f8b7c 7#
099ac3dd
MS
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.
e22f8b7c 12#
099ac3dd 13# You should have received a copy of the GNU General Public License
e22f8b7c 14# along with this program. If not, see <http://www.gnu.org/licenses/>. */
099ac3dd 15
db9d7fc5 16if { [is_remote target] || ![isnative] } then {
099ac3dd
MS
17 continue
18}
19
20# Until "set follow-fork-mode" and "catch fork" are implemented on
21# other targets...
22#
23if {![istarget "*-*-linux*"]} then {
24 continue
25}
26
e1316e60
PA
27# Must name the source file explicitly, otherwise when driven by
28# checkpoints-ns.exp, we'd try compiling checkpoints-ns.c, which
29# doesn't exist.
30standard_testfile checkpoint.c
099ac3dd 31
59b28c5d
TT
32set pi_txt [gdb_remote_download host ${srcdir}/${subdir}/pi.txt]
33if {[is_remote host]} {
34 set copy1_txt copy1.txt
35} else {
36 set copy1_txt [standard_output_file copy1.txt]
37}
38
5b362f04 39if {[prepare_for_testing "failed to prepare" $testfile $srcfile \
59b28c5d 40 [list debug "additional_flags=-DPI_TXT=\"$pi_txt\" -DCOPY1_TXT=\"$copy1_txt\""]]} {
b60f0898 41 return -1
099ac3dd
MS
42}
43
099ac3dd
MS
44global gdb_prompt
45
46#
47# This tests gdb checkpoint and restart.
48#
49
099ac3dd
MS
50runto_main
51set break1_loc [gdb_get_line_number "breakpoint 1"]
52set break2_loc [gdb_get_line_number "breakpoint 2"]
53set break3_loc [gdb_get_line_number "breakpoint 3"]
54set break4_loc [gdb_get_line_number "breakpoint 4"]
55
56gdb_breakpoint $break1_loc
57gdb_test "continue" "breakpoint 1.*" "break1 start"
58
de7ff789 59gdb_test "checkpoint" ".*" ""
099ac3dd
MS
60gdb_test "continue 10" "breakpoint 1.*" "break1 two"
61
de7ff789 62gdb_test "checkpoint" ".*" ""
099ac3dd
MS
63gdb_test "continue 10" "breakpoint 1.*" "break1 three"
64
de7ff789 65gdb_test "checkpoint" ".*" ""
099ac3dd
MS
66gdb_test "continue 10" "breakpoint 1.*" "break1 four"
67
de7ff789 68gdb_test "checkpoint" ".*" ""
099ac3dd
MS
69gdb_test "continue 10" "breakpoint 1.*" "break1 five"
70
de7ff789 71gdb_test "checkpoint" ".*" ""
099ac3dd
MS
72gdb_test "continue 10" "breakpoint 1.*" "break1 six"
73
de7ff789 74gdb_test "checkpoint" ".*" ""
099ac3dd
MS
75gdb_test "continue 10" "breakpoint 1.*" "break1 seven"
76
de7ff789 77gdb_test "checkpoint" ".*" ""
099ac3dd
MS
78gdb_test "continue 10" "breakpoint 1.*" "break1 eight"
79
de7ff789 80gdb_test "checkpoint" ".*" ""
099ac3dd
MS
81gdb_test "continue 10" "breakpoint 1.*" "break1 nine"
82
de7ff789 83gdb_test "checkpoint" ".*" ""
099ac3dd
MS
84gdb_test "continue 10" "breakpoint 1.*" "break1 ten"
85
de7ff789 86gdb_test "checkpoint" ".*" ""
099ac3dd
MS
87
88gdb_test "info checkpoints" \
2f341b6e 89 " 1 .* 2 .* 3 .* 4 .* 5 .* 6 .* 7 .* 8 .* 9 .* 10 .*" \
099ac3dd
MS
90 "info checkpoints one"
91
92delete_breakpoints
93gdb_breakpoint $break2_loc
94gdb_test "continue" "breakpoint 2.*" "break2 one"
95
96gdb_test "restart 1" "Switching to .*breakpoint 1.*" "restart 1 one"
97gdb_test "print i" " = 78" "verify i 1 one"
98gdb_test "step" "if .c == EOF.*" "step in 1 one"
99gdb_test "print lines" " = 1.*" "verify lines 1 one"
100
101gdb_test "restart 2" "Switching to .*breakpoint 1.*" "restart 2 one"
102gdb_test "step" "if .c == EOF.*" "step in 2 one"
103gdb_test "print i + 1 == lines * 79" " = 1" "verify i 2 one"
104gdb_test "print lines" " = 11.*" "verify lines 2 one"
105
106gdb_test "restart 3" "Switching to .*breakpoint 1.*" "restart 3 one"
107gdb_test "step" "if .c == EOF.*" "step in 3 one"
108gdb_test "print i + 1 == lines * 79" " = 1" "verify i 3 one"
109gdb_test "print lines" " = 21.*" "verify lines 3 one"
110
111gdb_test "restart 4" "Switching to .*breakpoint 1.*" "restart 4 one"
112gdb_test "step" "if .c == EOF.*" "step in 4 one"
113gdb_test "print i + 1 == lines * 79" " = 1" "verify i 4 one"
114gdb_test "print lines" " = 31.*" "verify lines 4 one"
115
116gdb_test "restart 5" "Switching to .*breakpoint 1.*" "restart 5 one"
117gdb_test "step" "if .c == EOF.*" "step in 5 one"
118gdb_test "print i + 1 == lines * 79" " = 1" "verify i 5 one"
119gdb_test "print lines" " = 41.*" "verify lines 5 one"
120
121gdb_test "restart 6" "Switching to .*breakpoint 1.*" "restart 6 one"
122gdb_test "step" "if .c == EOF.*" "step in 6 one"
123gdb_test "print i + 1 == lines * 79" " = 1" "verify i 6 one"
124gdb_test "print lines" " = 51.*" "verify lines 6 one"
125
126gdb_test "restart 7" "Switching to .*breakpoint 1.*" "restart 7 one"
127gdb_test "step" "if .c == EOF.*" "step in 7 one"
128gdb_test "print i + 1 == lines * 79" " = 1" "verify i 7 one"
129gdb_test "print lines" " = 61.*" "verify lines 7 one"
130
131gdb_test "restart 8" "Switching to .*breakpoint 1.*" "restart 8 one"
132gdb_test "step" "if .c == EOF.*" "step in 8 one"
133gdb_test "print i + 1 == lines * 79" " = 1" "verify i 8 one"
134gdb_test "print lines" " = 71.*" "verify lines 8 one"
135
136gdb_test "restart 9" "Switching to .*breakpoint 1.*" "restart 9 one"
137gdb_test "step" "if .c == EOF.*" "step in 9 one"
138gdb_test "print i + 1 == lines * 79" " = 1" "verify i 9 one"
139gdb_test "print lines" " = 81.*" "verify lines 9 one"
140
141gdb_test "restart 10" "Switching to .*breakpoint 1.*" "restart 10 one"
142gdb_test "step" "if .c == EOF.*" "step in 10 one"
143gdb_test "print i + 1 == lines * 79" " = 1" "verify i 10 one"
144gdb_test "print lines" " = 91.*" "verify lines 10 one"
145
146#
147# Now let the files be closed by the original process,
148# and diff them.
149
150gdb_test "restart 0" "Switching to .*breakpoint 2.*" "restart 0 one"
151gdb_breakpoint $break3_loc
152gdb_test "continue" "breakpoint 3.*" "break3 one"
153
59b28c5d
TT
154gdb_test "shell diff -s $pi_txt $copy1_txt" \
155 "Files .*pi.txt and .*copy1.txt are identical.*" \
bb95117e 156 "diff input and output one"
099ac3dd
MS
157
158#
159# And now run from various checkpoints, allowing
160# various amounts of input and output.
161#
162
163gdb_breakpoint $break1_loc
164
165gdb_test "restart 1" "Switching to .*c == EOF.*" "restart 1 two"
de7ff789 166gdb_test "continue" ".*" ""
099ac3dd
MS
167gdb_test "continue 100" "breakpoint 1.*" "breakpoint 1 1 one"
168gdb_test "step" "if .c == EOF.*" "step in 1 two"
169gdb_test "print lines" " = 102.*" "verify lines 1 two"
170
171gdb_test "restart 2" "Switching to .*c == EOF.*" "restart 2 two"
de7ff789 172gdb_test "continue" ".*" ""
099ac3dd
MS
173gdb_test "continue 100" "breakpoint 1.*" "breakpoint 1 2 one"
174gdb_test "step" "if .c == EOF.*" "step in 2 two"
175gdb_test "print lines" " = 112.*" "verify lines 2 two"
176
177gdb_test "restart 3" "Switching to .*c == EOF.*" "restart 3 two"
de7ff789 178gdb_test "continue" ".*" ""
099ac3dd
MS
179gdb_test "continue 500" "breakpoint 1.*" "breakpoint 1 3 one"
180gdb_test "step" "if .c == EOF.*" "step in 3 two"
181gdb_test "print lines" " = 522.*" "verify lines 3 two"
182
183gdb_test "restart 4" "Switching to .*c == EOF.*" "restart 4 two"
de7ff789 184gdb_test "continue" ".*" ""
099ac3dd
MS
185gdb_test "continue 500" "breakpoint 1.*" "breakpoint 1 4 one"
186gdb_test "step" "if .c == EOF.*" "step in 4 two"
187gdb_test "print lines" " = 532.*" "verify lines 4 two"
188
189gdb_test "restart 5" "Switching to .*c == EOF.*" "restart 5 two"
de7ff789 190gdb_test "continue" ".*" ""
099ac3dd
MS
191gdb_test "continue 1000" "breakpoint 1.*" "breakpoint 1 5 one"
192gdb_test "step" "if .c == EOF.*" "step in 5 two"
193gdb_test "print lines" " = 1042.*" "verify lines 5 two"
194
195gdb_test "restart 6" "Switching to .*c == EOF.*" "restart 6 two"
de7ff789 196gdb_test "continue" ".*" ""
099ac3dd
MS
197gdb_test "continue 1000" "breakpoint 1.*" "breakpoint 1 6 one"
198gdb_test "step" "if .c == EOF.*" "step in 6 two"
199gdb_test "print lines" " = 1052.*" "verify lines 5 two"
200
201gdb_test "restart 7" "Switching to .*c == EOF.*" "restart 7 two"
de7ff789 202gdb_test "continue" ".*" ""
099ac3dd
MS
203gdb_test "continue 1100" "breakpoint 1.*" "breakpoint 1 7 one"
204gdb_test "step" "if .c == EOF.*" "step in 7 two"
205gdb_test "print lines" " = 1162.*" "verify lines 7 two"
206
59b28c5d
TT
207gdb_test "shell diff -s $pi_txt $copy1_txt" \
208 "Files .*pi.txt and .*copy1.txt are identical.*" \
bb95117e 209 "diff input and output two"
099ac3dd
MS
210
211#
212# OK, now allow the original program to delete the output file,
213# and verify that the checkpoints can still write to it.
214#
215
216gdb_test "restart 0" "Switching to .*breakpoint 3.*" "restart 0 one"
217gdb_breakpoint $break4_loc
218gdb_test "continue" "breakpoint 4.*" "break4 one"
219
59b28c5d
TT
220gdb_test "shell diff $pi_txt $copy1_txt" \
221 "diff: .*copy1.txt: No such file or directory" \
099ac3dd
MS
222 "delete copy1"
223
224delete_breakpoints
225gdb_breakpoint $break2_loc
226
227gdb_test "restart 1" "if .c == EOF.*" "restart 1 three"
228gdb_test "continue" "breakpoint 2.*" "break2 1 one"
229gdb_test "print ftell (out) > 100000" " = 1.*" "outfile still open 1"
230
5965d69d 231gdb_test "restart 2" "if .c == EOF.*" "restart 2 three"
099ac3dd
MS
232gdb_test "continue" "breakpoint 2.*" "break2 2 one"
233gdb_test "print ftell (out) > 100000" " = 1.*" "outfile still open 2"
234
5965d69d 235gdb_test "restart 3" "if .c == EOF.*" "restart 3 three"
099ac3dd
MS
236gdb_test "continue" "breakpoint 2.*" "break2 3 one"
237gdb_test "print ftell (out) > 100000" " = 1.*" "outfile still open 3"
238
5965d69d 239gdb_test "restart 4" "if .c == EOF.*" "restart 4 three"
099ac3dd
MS
240gdb_test "continue" "breakpoint 2.*" "break2 4 one"
241gdb_test "print ftell (out) > 100000" " = 1.*" "outfile still open 4"
242
5965d69d 243gdb_test "restart 5" "if .c == EOF.*" "restart 5 three"
099ac3dd
MS
244gdb_test "continue" "breakpoint 2.*" "break2 5 one"
245gdb_test "print ftell (out) > 100000" " = 1.*" "outfile still open 5"
246
5965d69d 247gdb_test "restart 6" "if .c == EOF.*" "restart 6 three"
099ac3dd
MS
248gdb_test "continue" "breakpoint 2.*" "break2 6 one"
249gdb_test "print ftell (out) > 100000" " = 1.*" "outfile still open 6"
250
5965d69d 251gdb_test "restart 7" "if .c == EOF.*" "restart 7 three"
099ac3dd
MS
252gdb_test "continue" "breakpoint 2.*" "break2 7 one"
253gdb_test "print ftell (out) > 100000" " = 1.*" "outfile still open 7"
254
5965d69d 255gdb_test "restart 8" "if .c == EOF.*" "restart 8 three"
099ac3dd
MS
256gdb_test "continue" "breakpoint 2.*" "break2 8 one"
257gdb_test "print ftell (out) > 100000" " = 1.*" "outfile still open 8"
258
5965d69d 259gdb_test "restart 9" "if .c == EOF.*" "restart 9 three"
099ac3dd
MS
260gdb_test "continue" "breakpoint 2.*" "break2 9 one"
261gdb_test "print ftell (out) > 100000" " = 1.*" "outfile still open 9"
262
5965d69d 263gdb_test "restart 10" "if .c == EOF.*" "restart 10 three"
099ac3dd
MS
264gdb_test "continue" "breakpoint 2.*" "break2 10 one"
265gdb_test "print ftell (out) > 100000" " = 1.*" "outfile still open 10"
266
267#
268# Now confirm that if one fork exits, we automatically switch to another one.
269#
270
271delete_breakpoints
272gdb_test "continue" \
fda326dd 273 "Deleting copy.*$inferior_exited_re normally.*Switching to.*" \
bb95117e 274 "exit, dropped into next fork one"
099ac3dd
MS
275
276gdb_test "continue" \
fda326dd 277 "Deleting copy.*$inferior_exited_re normally.*Switching to.*" \
bb95117e 278 "exit, dropped into next fork two"
099ac3dd
MS
279
280gdb_test "continue" \
fda326dd 281 "Deleting copy.*$inferior_exited_re normally.*Switching to.*" \
bb95117e 282 "exit, dropped into next fork three"
099ac3dd
MS
283
284gdb_test "continue" \
fda326dd 285 "Deleting copy.*$inferior_exited_re normally.*Switching to.*" \
bb95117e 286 "exit, dropped into next fork four"
099ac3dd
MS
287
288gdb_test "continue" \
fda326dd 289 "Deleting copy.*$inferior_exited_re normally.*Switching to.*" \
bb95117e 290 "exit, dropped into next fork five"
099ac3dd
MS
291
292#
293# There should be still at least five forks left
294#
295
2f341b6e 296gdb_test "info checkpoints" " 1 .* 2 .* 3 .* 4 .* 5 .*" \
099ac3dd
MS
297 "info checkpoints two"
298
299#
300# Kill should now terminate all of them.
301#
302
303gdb_test "kill" "" "kill all one" \
304 "Kill the program being debugged.*y or n. $" "y"
305
306#
307# and confirm that all are gone
308#
309
310gdb_test "restart 0" "Not found.*" "no more checkpoint 0"
311gdb_test "restart 1" "Not found.*" "no more checkpoint 1"
312gdb_test "restart 2" "Not found.*" "no more checkpoint 2"
313gdb_test "restart 3" "Not found.*" "no more checkpoint 3"
314gdb_test "restart 4" "Not found.*" "no more checkpoint 4"
315gdb_test "restart 5" "Not found.*" "no more checkpoint 5"
316gdb_test "restart 6" "Not found.*" "no more checkpoint 6"
317gdb_test "restart 7" "Not found.*" "no more checkpoint 7"
318gdb_test "restart 8" "Not found.*" "no more checkpoint 8"
319gdb_test "restart 9" "Not found.*" "no more checkpoint 9"
320gdb_test "restart 10" "Not found.*" "no more checkpoint 10"
321
322#
e469c7fb 323# Now let's try setting a large number of checkpoints (>600)
099ac3dd
MS
324#
325
326gdb_exit
327gdb_start
328gdb_reinitialize_dir $srcdir/$subdir
329gdb_load ${binfile}
330
331runto_main
332gdb_breakpoint $break1_loc
333
ad3986f0
MS
334gdb_test "commands\nsilent\nif (lines % 2)\ncheckpoint\nend\n continue\nend" \
335 "" \
336 "set checkpoint breakpoint"
099ac3dd 337
e469c7fb
DE
338set prev_timeout $timeout
339set timeout [expr $timeout + 120]
340verbose "Timeout now $timeout sec."
341
099ac3dd
MS
342gdb_breakpoint $break2_loc
343gdb_test "continue" "breakpoint 2.*" "break2 with many checkpoints"
344
47b67b60
DJ
345set count 0
346set msg "info checkpoints with at least 600 checkpoints"
347gdb_test_multiple "info checkpoints" $msg {
348 -re " $decimal process \[^\r\]*\r\n" {
349 incr count
350 exp_continue
351 }
352 -re "$gdb_prompt $" {
353 if { $count >= 600 } {
354 pass $msg
355 } else {
356 fail $msg
357 }
358 }
359}
099ac3dd
MS
360
361#
362# OK, kill 'em all...
363#
364
e469c7fb 365gdb_test "kill" "" "kill all one with many checkpoints" \
099ac3dd
MS
366 "Kill the program being debugged.*y or n. $" "y"
367
e469c7fb
DE
368# Restore old timeout
369set timeout $prev_timeout
370verbose "Timeout now $timeout sec."
371
099ac3dd
MS
372#
373# Finished: cleanup
374#