Automatic Copyright Year update after running gdb/copyright.py
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.reverse / watch-reverse.exp
1 # Copyright 2008-2022 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 reverse debugging
18 # with watchpoints.
19
20
21 if ![supports_reverse] {
22 return
23 }
24
25 standard_testfile
26
27 if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } {
28 return -1
29 }
30
31 runto_main
32
33 if [supports_process_record] {
34 # Activate process record/replay
35 gdb_test_no_output "record" "turn on process record"
36 }
37
38 # Test software watchpoints
39 gdb_test_no_output "set can-use-hw-watchpoints 0" "disable hw watchpoints"
40
41 gdb_test "break marker1" \
42 "Breakpoint $decimal at $hex: file .*$srcfile, line $decimal.*" \
43 "set breakpoint at marker1"
44
45 gdb_test "break marker2" \
46 "Breakpoint $decimal at $hex: file .*$srcfile, line $decimal.*" \
47 "set breakpoint at marker2"
48
49 gdb_continue_to_breakpoint "marker1" ".*$srcfile:.*"
50
51 gdb_test "watch ival3" \
52 ".*\[Ww\]atchpoint $decimal: ival3.*" \
53 "set watchpoint on ival3"
54
55 # Continue until first change, from -1 to 0
56
57 gdb_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.
62 gdb_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.
67 gdb_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.
72 gdb_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
79 gdb_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
86 gdb_continue_to_breakpoint "marker2" ".*$srcfile:.*"
87
88 ###
89 ###
90 ###
91
92 gdb_test_no_output "set exec-direction reverse" \
93 "set reverse, first time"
94
95 # Reverse until the previous change, from 4 to 3
96 # Note that this one is outside the loop
97
98 gdb_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.
103 gdb_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.
108 gdb_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.
113 gdb_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
119 gdb_test "continue" \
120 ".*\[Ww\]atchpoint.*ival3.*Old value = 0.*New value = -1.*ival3 = count; ival4 = count;.*" \
121 "watchpoint hit in reverse, fifth time"
122
123 gdb_test_no_output "set can-use-hw-watchpoints 1" "enable hw watchpoints"
124
125 ###
126 ###
127 ###
128
129 gdb_test_no_output "set exec-direction forward" "set forward"
130
131 # Continue until first change, from -1 to 0
132
133 gdb_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.
138 gdb_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.
143 gdb_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.
148 gdb_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
155 gdb_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
162 gdb_test "continue" "marker2 .*" "replay forward to marker2"
163
164 ###
165 ###
166 ###
167
168 gdb_test_no_output "set exec-direction reverse" \
169 "set reverse, second time"
170
171 # Reverse until the previous change, from 4 to 3
172 # Note that this one is outside the loop
173
174 gdb_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.
179 gdb_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.
184 gdb_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.
189 gdb_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
195 gdb_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 0.0349 seconds and 4 git commands to generate.