]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.reverse/watch-reverse.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.reverse / watch-reverse.exp
CommitLineData
1d506c26 1# Copyright 2008-2024 Free Software Foundation, Inc.
28d41a99
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
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 reverse debugging
18# with watchpoints.
19
20
5954db83 21require supports_reverse
28d41a99 22
7686c074 23standard_testfile
28d41a99 24
5b362f04 25if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } {
28d41a99
MS
26 return -1
27}
28
50441f0f 29runto_main
28d41a99 30
d3895d7d 31if [supports_process_record] {
28d41a99 32 # Activate process record/replay
9f058c10 33 gdb_test_no_output "record" "turn on process record"
28d41a99
MS
34}
35
930636d2 36# Test software watchpoints
89493308 37gdb_test_no_output "set can-use-hw-watchpoints 0" "disable hw watchpoints"
28d41a99
MS
38
39gdb_test "break marker1" \
40 "Breakpoint $decimal at $hex: file .*$srcfile, line $decimal.*" \
41 "set breakpoint at marker1"
42
43gdb_test "break marker2" \
44 "Breakpoint $decimal at $hex: file .*$srcfile, line $decimal.*" \
45 "set breakpoint at marker2"
46
a80db015 47gdb_continue_to_breakpoint "marker1" ".*$srcfile:.*"
28d41a99
MS
48
49gdb_test "watch ival3" \
50 ".*\[Ww\]atchpoint $decimal: ival3.*" \
51 "set watchpoint on ival3"
52
53# Continue until first change, from -1 to 0
54
55gdb_test "continue" \
56 ".*\[Ww\]atchpoint.*ival3.*Old value = -1.*New value = 0.*ival3 = count; ival4 = count;.*" \
57 "watchpoint hit, first time"
58
59# Continue until the next change, from 0 to 1.
60gdb_test "continue" \
61 ".*\[Ww\]atchpoint.*ival3.*Old value = 0.*New value = 1.*ival3 = count; ival4 = count;.*" \
62 "watchpoint hit, second time"
63
64# Continue until the next change, from 1 to 2.
65gdb_test "continue" \
66 ".*\[Ww\]atchpoint.*ival3.*Old value = 1.*New value = 2.*ival3 = count; ival4 = count;.*" \
67 "watchpoint hit, third time"
68
69# Continue until the next change, from 2 to 3.
70gdb_test "continue" \
71 ".*\[Ww\]atchpoint.*ival3.*Old value = 2.*New value = 3.*ival3 = count; ival4 = count;.*" \
72 "watchpoint hit, fourth time"
73
74# Continue until the next change, from 3 to 4.
75# Note that this one is outside the loop.
76
77gdb_test "continue" \
78 ".*\[Ww\]atchpoint.*ival3.*Old value = 3.*New value = 4.*ival3 = count; ival4 = count;.*" \
79 "watchpoint hit, fifth time"
80
81# Continue until we hit the finishing marker function.
82# Make sure we hit no more watchpoints.
83
a80db015 84gdb_continue_to_breakpoint "marker2" ".*$srcfile:.*"
28d41a99
MS
85
86###
87###
88###
89
4d421147
AB
90gdb_test_no_output "set exec-direction reverse" \
91 "set reverse, first time"
28d41a99
MS
92
93# Reverse until the previous change, from 4 to 3
94# Note that this one is outside the loop
95
96gdb_test "continue" \
97 ".*\[Ww\]atchpoint.*ival3.*Old value = 4.*New value = 3.*ival3 = count; ival4 = count;.*" \
98 "watchpoint hit in reverse, first time"
99
100# Reverse until the previous change, from 3 to 2.
101gdb_test "continue" \
102 ".*\[Ww\]atchpoint.*ival3.*Old value = 3.*New value = 2.*ival3 = count; ival4 = count;.*" \
103 "watchpoint hit in reverse, second time"
104
105# Reverse until the previous change, from 2 to 1.
106gdb_test "continue" \
107 ".*\[Ww\]atchpoint.*ival3.*Old value = 2.*New value = 1.*ival3 = count; ival4 = count;.*" \
108 "watchpoint hit in reverse, third time"
109
110# Reverse until the previous change, from 1 to 0.
111gdb_test "continue" \
112 ".*\[Ww\]atchpoint.*ival3.*Old value = 1.*New value = 0.*ival3 = count; ival4 = count;.*" \
113 "watchpoint hit in reverse, fourth time"
114
115# Reverse until first change, from 0 to -1
116
117gdb_test "continue" \
118 ".*\[Ww\]atchpoint.*ival3.*Old value = 0.*New value = -1.*ival3 = count; ival4 = count;.*" \
119 "watchpoint hit in reverse, fifth time"
930636d2 120
288363c1
HD
121gdb_test_no_output "disable \$bpnum" "disable non-hw watchpoint"
122
89493308 123gdb_test_no_output "set can-use-hw-watchpoints 1" "enable hw watchpoints"
930636d2 124
288363c1
HD
125gdb_test_no_output "enable \$bpnum" "enable hw watchpoint"
126
930636d2
MS
127###
128###
129###
130
bcd2dc50 131gdb_test_no_output "set exec-direction forward" "set forward"
930636d2
MS
132
133# Continue until first change, from -1 to 0
134
135gdb_test "continue" \
136 ".*\[Ww\]atchpoint.*ival3.*Old value = -1.*New value = 0.*ival3 = count; ival4 = count;.*" \
137 "watchpoint hit, forward replay, first time"
138
139# Continue until the next change, from 0 to 1.
140gdb_test "continue" \
141 ".*\[Ww\]atchpoint.*ival3.*Old value = 0.*New value = 1.*ival3 = count; ival4 = count;.*" \
142 "watchpoint hit, forward replay, second time"
143
144# Continue until the next change, from 1 to 2.
145gdb_test "continue" \
146 ".*\[Ww\]atchpoint.*ival3.*Old value = 1.*New value = 2.*ival3 = count; ival4 = count;.*" \
147 "watchpoint hit, forward replay, third time"
148
149# Continue until the next change, from 2 to 3.
150gdb_test "continue" \
151 ".*\[Ww\]atchpoint.*ival3.*Old value = 2.*New value = 3.*ival3 = count; ival4 = count;.*" \
152 "watchpoint hit, forward replay, fourth time"
153
154# Continue until the next change, from 3 to 4.
155# Note that this one is outside the loop.
156
157gdb_test "continue" \
158 ".*\[Ww\]atchpoint.*ival3.*Old value = 3.*New value = 4.*ival3 = count; ival4 = count;.*" \
159 "watchpoint hit, forward replay, fifth time"
160
161# Continue until we hit the finishing marker function.
162# Make sure we hit no more watchpoints.
163
164gdb_test "continue" "marker2 .*" "replay forward to marker2"
165
166###
167###
168###
169
4d421147
AB
170gdb_test_no_output "set exec-direction reverse" \
171 "set reverse, second time"
930636d2
MS
172
173# Reverse until the previous change, from 4 to 3
174# Note that this one is outside the loop
175
176gdb_test "continue" \
177 ".*\[Ww\]atchpoint.*ival3.*Old value = 4.*New value = 3.*ival3 = count; ival4 = count;.*" \
178 "watchpoint hit in reverse, HW, first time"
179
180# Reverse until the previous change, from 3 to 2.
181gdb_test "continue" \
182 ".*\[Ww\]atchpoint.*ival3.*Old value = 3.*New value = 2.*ival3 = count; ival4 = count;.*" \
183 "watchpoint hit in reverse, HW, second time"
184
185# Reverse until the previous change, from 2 to 1.
186gdb_test "continue" \
187 ".*\[Ww\]atchpoint.*ival3.*Old value = 2.*New value = 1.*ival3 = count; ival4 = count;.*" \
188 "watchpoint hit in reverse, HW, third time"
189
190# Reverse until the previous change, from 1 to 0.
191gdb_test "continue" \
192 ".*\[Ww\]atchpoint.*ival3.*Old value = 1.*New value = 0.*ival3 = count; ival4 = count;.*" \
193 "watchpoint hit in reverse, HW, fourth time"
194
195# Reverse until first change, from 0 to -1
196
197gdb_test "continue" \
198 ".*\[Ww\]atchpoint.*ival3.*Old value = 0.*New value = -1.*ival3 = count; ival4 = count;.*" \
199 "watchpoint hit in reverse, HW, fifth time"
200