]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.reverse/watch-precsave.exp
Update copyright year range in all GDB files.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.reverse / watch-precsave.exp
1 # Copyright 2009-2020 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
21 if ![supports_process_record] {
22 return
23 }
24
25 standard_testfile watch-reverse.c
26 set precsave [standard_output_file watch.precsave]
27
28 if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } {
29 return -1
30 }
31
32 runto main
33
34 if [supports_process_record] {
35 # Activate process record/replay
36 gdb_test_no_output "record" "turn on process record"
37 }
38
39 set end_location [gdb_get_line_number "end of main" ]
40 gdb_test "break $end_location" \
41 "Breakpoint $decimal at .*$srcfile, line $end_location\." \
42 "breakpoint at end of main"
43
44 gdb_test "continue" "Breakpoint .* end of main .*" "run to end of main"
45
46 gdb_test "record save $precsave" \
47 "Saved core file $precsave with execution log\." \
48 "save process recfile"
49
50 gdb_test "kill" "" "kill process, prepare to debug log file" \
51 "Kill the program being debugged\\? \\(y or n\\) " "y"
52
53 gdb_test "record restore $precsave" \
54 "Restored records from core file .*" \
55 "reload core file"
56
57 # Only software watchpoints can be used in reverse
58 gdb_test_no_output "set can-use-hw-watchpoints 0" ""
59
60 gdb_test "break marker1" \
61 "Breakpoint $decimal at $hex: file .*$srcfile, line $decimal.*" \
62 "set breakpoint at marker1"
63
64 gdb_test "break marker2" \
65 "Breakpoint $decimal at $hex: file .*$srcfile, line $decimal.*" \
66 "set breakpoint at marker2"
67
68 gdb_continue_to_breakpoint "marker1" ".*$srcfile:.*"
69
70 gdb_test "watch ival3" \
71 ".*\[Ww\]atchpoint $decimal: ival3.*" \
72 "set watchpoint on ival3"
73
74 # Continue until first change, from -1 to 0
75
76 gdb_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.
81 gdb_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.
86 gdb_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.
91 gdb_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
98 gdb_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
105 gdb_continue_to_breakpoint "marker2" ".*$srcfile:.*"
106
107 ###
108 ###
109 ###
110
111 gdb_test_no_output "set exec-direction reverse" \
112 "set reverse, first time"
113
114 # Reverse until the previous change, from 4 to 3
115 # Note that this one is outside the loop
116
117 gdb_test "continue" \
118 ".*\[Ww\]atchpoint.*ival3.*Old value = 4.*New value = 3.*ival3 = count; ival4 = count;.*" \
119 "watchpoint hit in reverse, first time"
120
121 # Reverse until the previous change, from 3 to 2.
122 gdb_test "continue" \
123 ".*\[Ww\]atchpoint.*ival3.*Old value = 3.*New value = 2.*ival3 = count; ival4 = count;.*" \
124 "watchpoint hit in reverse, second time"
125
126 # Reverse until the previous change, from 2 to 1.
127 gdb_test "continue" \
128 ".*\[Ww\]atchpoint.*ival3.*Old value = 2.*New value = 1.*ival3 = count; ival4 = count;.*" \
129 "watchpoint hit in reverse, third time"
130
131 # Reverse until the previous change, from 1 to 0.
132 gdb_test "continue" \
133 ".*\[Ww\]atchpoint.*ival3.*Old value = 1.*New value = 0.*ival3 = count; ival4 = count;.*" \
134 "watchpoint hit in reverse, fourth time"
135
136 # Reverse until first change, from 0 to -1
137
138 gdb_test "continue" \
139 ".*\[Ww\]atchpoint.*ival3.*Old value = 0.*New value = -1.*ival3 = count; ival4 = count;.*" \
140 "watchpoint hit in reverse, fifth time"
141
142 gdb_test_no_output "set can-use-hw-watchpoints 1" "enable hw watchpoints"
143
144 ###
145 ###
146 ###
147
148 gdb_test_no_output "set exec-direction forward" "set forward"
149
150 # Continue until first change, from -1 to 0
151
152 gdb_test "continue" \
153 ".*\[Ww\]atchpoint.*ival3.*Old value = -1.*New value = 0.*ival3 = count; ival4 = count;.*" \
154 "watchpoint hit, forward replay, first time"
155
156 # Continue until the next change, from 0 to 1.
157 gdb_test "continue" \
158 ".*\[Ww\]atchpoint.*ival3.*Old value = 0.*New value = 1.*ival3 = count; ival4 = count;.*" \
159 "watchpoint hit, forward replay, second time"
160
161 # Continue until the next change, from 1 to 2.
162 gdb_test "continue" \
163 ".*\[Ww\]atchpoint.*ival3.*Old value = 1.*New value = 2.*ival3 = count; ival4 = count;.*" \
164 "watchpoint hit, forward replay, third time"
165
166 # Continue until the next change, from 2 to 3.
167 gdb_test "continue" \
168 ".*\[Ww\]atchpoint.*ival3.*Old value = 2.*New value = 3.*ival3 = count; ival4 = count;.*" \
169 "watchpoint hit, forward replay, fourth time"
170
171 # Continue until the next change, from 3 to 4.
172 # Note that this one is outside the loop.
173
174 gdb_test "continue" \
175 ".*\[Ww\]atchpoint.*ival3.*Old value = 3.*New value = 4.*ival3 = count; ival4 = count;.*" \
176 "watchpoint hit, forward replay, fifth time"
177
178 # Continue until we hit the finishing marker function.
179 # Make sure we hit no more watchpoints.
180
181 gdb_test "continue" "marker2 .*" "replay forward to marker2"
182
183 ###
184 ###
185 ###
186
187 gdb_test_no_output "set exec-direction reverse" \
188 "set reverse, second time"
189
190 # Reverse until the previous change, from 4 to 3
191 # Note that this one is outside the loop
192
193 gdb_test "continue" \
194 ".*\[Ww\]atchpoint.*ival3.*Old value = 4.*New value = 3.*ival3 = count; ival4 = count;.*" \
195 "watchpoint hit in reverse, HW, first time"
196
197 # Reverse until the previous change, from 3 to 2.
198 gdb_test "continue" \
199 ".*\[Ww\]atchpoint.*ival3.*Old value = 3.*New value = 2.*ival3 = count; ival4 = count;.*" \
200 "watchpoint hit in reverse, HW, second time"
201
202 # Reverse until the previous change, from 2 to 1.
203 gdb_test "continue" \
204 ".*\[Ww\]atchpoint.*ival3.*Old value = 2.*New value = 1.*ival3 = count; ival4 = count;.*" \
205 "watchpoint hit in reverse, HW, third time"
206
207 # Reverse until the previous change, from 1 to 0.
208 gdb_test "continue" \
209 ".*\[Ww\]atchpoint.*ival3.*Old value = 1.*New value = 0.*ival3 = count; ival4 = count;.*" \
210 "watchpoint hit in reverse, HW, fourth time"
211
212 # Reverse until first change, from 0 to -1
213
214 gdb_test "continue" \
215 ".*\[Ww\]atchpoint.*ival3.*Old value = 0.*New value = -1.*ival3 = count; ival4 = count;.*" \
216 "watchpoint hit in reverse, HW, fifth time"
217