Update copyright year range in header of all files managed by GDB
[binutils-gdb.git] / gdb / testsuite / gdb.reverse / watch-precsave.exp
blobbb8cab47afddbe9e839af7c0f9d49b284fafdc84
1 # Copyright 2009-2023 Free Software Foundation, Inc.
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.
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.
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/>.
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.
20 # This test suitable only for process record-replay
21 if ![supports_process_record] {
22     return
25 standard_testfile watch-reverse.c
26 set precsave [standard_output_file watch.precsave]
28 if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } {
29     return -1
32 runto_main
34 if [supports_process_record] {
35     # Activate process record/replay
36     gdb_test_no_output "record" "turn on process record"
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"
44 gdb_test "continue" "Breakpoint .* end of main .*" "run to end of main"
46 gdb_test "record save $precsave" \
47     "Saved core file $precsave with execution log\."  \
48     "save process recfile"
50 gdb_test "kill" "" "kill process, prepare to debug log file" \
51     "Kill the program being debugged\\? \\(y or n\\) " "y"
53 gdb_test "record restore $precsave" \
54     "Restored records from core file .*" \
55     "reload core file"
57 # Only software watchpoints can be used in reverse
58 gdb_test_no_output "set can-use-hw-watchpoints 0" ""
60 gdb_test "break marker1" \
61     "Breakpoint $decimal at $hex: file .*$srcfile, line $decimal.*" \
62     "set breakpoint at marker1"
64 gdb_test "break marker2" \
65     "Breakpoint $decimal at $hex: file .*$srcfile, line $decimal.*" \
66     "set breakpoint at marker2"
68 gdb_continue_to_breakpoint "marker1" ".*$srcfile:.*"
70 gdb_test "watch ival3" \
71     ".*\[Ww\]atchpoint $decimal: ival3.*" \
72     "set watchpoint on ival3"
74 # Continue until first change, from -1 to 0
76 gdb_test "continue" \
77     ".*\[Ww\]atchpoint.*ival3.*Old value = -1.*New value = 0.*ival3 = count; ival4 = count;.*" \
78     "watchpoint hit, first time"
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"
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"
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"
95 # Continue until the next change, from 3 to 4.
96 # Note that this one is outside the loop.
98 gdb_test "continue" \
99     ".*\[Ww\]atchpoint.*ival3.*Old value = 3.*New value = 4.*ival3 = count; ival4 = count;.*" \
100     "watchpoint hit, fifth time"
102 # Continue until we hit the finishing marker function.
103 # Make sure we hit no more watchpoints.
105 gdb_continue_to_breakpoint "marker2" ".*$srcfile:.*"
111 gdb_test_no_output "set exec-direction reverse" \
112     "set reverse, first time"
114 # Reverse until the previous change, from 4 to 3
115 # Note that this one is outside the loop
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"
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"
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"
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"
136 # Reverse until first change, from 0 to -1
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"
142 gdb_test_no_output "set can-use-hw-watchpoints 1" "enable hw watchpoints"
148 gdb_test_no_output "set exec-direction forward" "set forward"
150 # Continue until first change, from -1 to 0
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"
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"
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"
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"
171 # Continue until the next change, from 3 to 4.
172 # Note that this one is outside the loop.
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"
178 # Continue until we hit the finishing marker function.
179 # Make sure we hit no more watchpoints.
181 gdb_test "continue" "marker2 .*" "replay forward to marker2"
187 gdb_test_no_output "set exec-direction reverse" \
188     "set reverse, second time"
190 # Reverse until the previous change, from 4 to 3
191 # Note that this one is outside the loop
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"
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"
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"
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"
212 # Reverse until first change, from 0 to -1
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"