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