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