xref: /netbsd-src/external/gpl3/gdb.old/dist/gdb/testsuite/gdb.reverse/watch-precsave.exp (revision 200d779b75dbeafa7bc01fd0f60bc61185f6967b)
1# Copyright 2009-2014 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 <http://www.gnu.org/licenses/>.
15
16# Based on a file written by Fred Fish. (fnf@cygnus.com)
17# This file is part of the GDB testsuite.  It tests precord dumpfile
18# debugging with watchpoints.
19
20# This test suitable only for process record-replay
21if ![supports_process_record] {
22    return
23}
24
25standard_testfile watch-reverse.c
26set precsave [standard_output_file watch.precsave]
27
28if { [prepare_for_testing $testfile.exp $testfile $srcfile] } {
29    return -1
30}
31
32runto main
33
34if [supports_process_record] {
35    # Activate process record/replay
36    gdb_test_no_output "record" "Turn on process record"
37}
38
39set end_location  [gdb_get_line_number "end of main"  ]
40gdb_test "break $end_location" \
41    "Breakpoint $decimal at .*/$srcfile, line $end_location\." \
42    "BP at end of main"
43
44gdb_test "continue" "Breakpoint .* end of main .*" "run to end of main"
45
46gdb_test "record save $precsave" \
47    "Saved core file $precsave with execution log\."  \
48    "save process recfile"
49
50gdb_test "kill" "" "Kill process, prepare to debug log file" \
51    "Kill the program being debugged\\? \\(y or n\\) " "y"
52
53gdb_test "record restore $precsave" \
54    "Program terminated with signal .*" \
55    "reload core file"
56
57# Only software watchpoints can be used in reverse
58gdb_test_no_output "set can-use-hw-watchpoints 0" ""
59
60gdb_test "break marker1" \
61    "Breakpoint $decimal at $hex: file .*$srcfile, line $decimal.*" \
62    "set breakpoint at marker1"
63
64gdb_test "break marker2" \
65    "Breakpoint $decimal at $hex: file .*$srcfile, line $decimal.*" \
66    "set breakpoint at marker2"
67
68gdb_continue_to_breakpoint "marker1" ".*/$srcfile:.*"
69
70gdb_test "watch ival3" \
71    ".*\[Ww\]atchpoint $decimal: ival3.*" \
72    "set watchpoint on ival3"
73
74# Continue until first change, from -1 to 0
75
76gdb_test "continue" \
77    ".*\[Ww\]atchpoint.*ival3.*Old value = -1.*New value = 0.*ival3 = count; ival4 = count;.*" \
78    "watchpoint hit, first time"
79
80# Continue until the next change, from 0 to 1.
81gdb_test "continue" \
82    ".*\[Ww\]atchpoint.*ival3.*Old value = 0.*New value = 1.*ival3 = count; ival4 = count;.*" \
83    "watchpoint hit, second time"
84
85# Continue until the next change, from 1 to 2.
86gdb_test "continue" \
87    ".*\[Ww\]atchpoint.*ival3.*Old value = 1.*New value = 2.*ival3 = count; ival4 = count;.*" \
88    "watchpoint hit, third time"
89
90# Continue until the next change, from 2 to 3.
91gdb_test "continue" \
92    ".*\[Ww\]atchpoint.*ival3.*Old value = 2.*New value = 3.*ival3 = count; ival4 = count;.*" \
93    "watchpoint hit, fourth time"
94
95# Continue until the next change, from 3 to 4.
96# Note that this one is outside the loop.
97
98gdb_test "continue" \
99    ".*\[Ww\]atchpoint.*ival3.*Old value = 3.*New value = 4.*ival3 = count; ival4 = count;.*" \
100    "watchpoint hit, fifth time"
101
102# Continue until we hit the finishing marker function.
103# Make sure we hit no more watchpoints.
104
105gdb_continue_to_breakpoint "marker2" ".*/$srcfile:.*"
106
107###
108###
109###
110
111gdb_test_no_output "set exec-direction reverse" "set reverse"
112
113# Reverse until the previous change, from 4 to 3
114# Note that this one is outside the loop
115
116gdb_test "continue" \
117    ".*\[Ww\]atchpoint.*ival3.*Old value = 4.*New value = 3.*ival3 = count; ival4 = count;.*" \
118    "watchpoint hit in reverse, first time"
119
120# Reverse until the previous change, from 3 to 2.
121gdb_test "continue" \
122    ".*\[Ww\]atchpoint.*ival3.*Old value = 3.*New value = 2.*ival3 = count; ival4 = count;.*" \
123    "watchpoint hit in reverse, second time"
124
125# Reverse until the previous change, from 2 to 1.
126gdb_test "continue" \
127    ".*\[Ww\]atchpoint.*ival3.*Old value = 2.*New value = 1.*ival3 = count; ival4 = count;.*" \
128    "watchpoint hit in reverse, third time"
129
130# Reverse until the previous change, from 1 to 0.
131gdb_test "continue" \
132    ".*\[Ww\]atchpoint.*ival3.*Old value = 1.*New value = 0.*ival3 = count; ival4 = count;.*" \
133    "watchpoint hit in reverse, fourth time"
134
135# Reverse until first change, from 0 to -1
136
137gdb_test "continue" \
138    ".*\[Ww\]atchpoint.*ival3.*Old value = 0.*New value = -1.*ival3 = count; ival4 = count;.*" \
139    "watchpoint hit in reverse, fifth time"
140
141gdb_test_no_output "set can-use-hw-watchpoints 1" "enable hw watchpoints"
142
143###
144###
145###
146
147gdb_test_no_output "set exec-direction forward" "set forward"
148
149# Continue until first change, from -1 to 0
150
151gdb_test "continue" \
152    ".*\[Ww\]atchpoint.*ival3.*Old value = -1.*New value = 0.*ival3 = count; ival4 = count;.*" \
153    "watchpoint hit, forward replay, first time"
154
155# Continue until the next change, from 0 to 1.
156gdb_test "continue" \
157    ".*\[Ww\]atchpoint.*ival3.*Old value = 0.*New value = 1.*ival3 = count; ival4 = count;.*" \
158    "watchpoint hit, forward replay, second time"
159
160# Continue until the next change, from 1 to 2.
161gdb_test "continue" \
162    ".*\[Ww\]atchpoint.*ival3.*Old value = 1.*New value = 2.*ival3 = count; ival4 = count;.*" \
163    "watchpoint hit, forward replay, third time"
164
165# Continue until the next change, from 2 to 3.
166gdb_test "continue" \
167    ".*\[Ww\]atchpoint.*ival3.*Old value = 2.*New value = 3.*ival3 = count; ival4 = count;.*" \
168    "watchpoint hit, forward replay, fourth time"
169
170# Continue until the next change, from 3 to 4.
171# Note that this one is outside the loop.
172
173gdb_test "continue" \
174    ".*\[Ww\]atchpoint.*ival3.*Old value = 3.*New value = 4.*ival3 = count; ival4 = count;.*" \
175    "watchpoint hit, forward replay, fifth time"
176
177# Continue until we hit the finishing marker function.
178# Make sure we hit no more watchpoints.
179
180gdb_test "continue" "marker2 .*" "replay forward to marker2"
181
182###
183###
184###
185
186gdb_test_no_output "set exec-direction reverse" "set reverse"
187
188# Reverse until the previous change, from 4 to 3
189# Note that this one is outside the loop
190
191gdb_test "continue" \
192    ".*\[Ww\]atchpoint.*ival3.*Old value = 4.*New value = 3.*ival3 = count; ival4 = count;.*" \
193    "watchpoint hit in reverse, HW, first time"
194
195# Reverse until the previous change, from 3 to 2.
196gdb_test "continue" \
197    ".*\[Ww\]atchpoint.*ival3.*Old value = 3.*New value = 2.*ival3 = count; ival4 = count;.*" \
198    "watchpoint hit in reverse, HW, second time"
199
200# Reverse until the previous change, from 2 to 1.
201gdb_test "continue" \
202    ".*\[Ww\]atchpoint.*ival3.*Old value = 2.*New value = 1.*ival3 = count; ival4 = count;.*" \
203    "watchpoint hit in reverse, HW, third time"
204
205# Reverse until the previous change, from 1 to 0.
206gdb_test "continue" \
207    ".*\[Ww\]atchpoint.*ival3.*Old value = 1.*New value = 0.*ival3 = count; ival4 = count;.*" \
208    "watchpoint hit in reverse, HW, fourth time"
209
210# Reverse until first change, from 0 to -1
211
212gdb_test "continue" \
213    ".*\[Ww\]atchpoint.*ival3.*Old value = 0.*New value = -1.*ival3 = count; ival4 = count;.*" \
214    "watchpoint hit in reverse, HW, fifth time"
215
216