1 # Copyright 2008-2021 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 reverse debugging
21 if ![supports_reverse] {
27 if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } {
33 if [supports_process_record] {
34 # Activate process record/replay
35 gdb_test_no_output "record" "turn on process record"
38 # Test software watchpoints
39 gdb_test_no_output "set can-use-hw-watchpoints 0" "disable hw watchpoints"
41 gdb_test "break marker1" \
42 "Breakpoint $decimal at $hex: file .*$srcfile, line $decimal.*" \
43 "set breakpoint at marker1"
45 gdb_test "break marker2" \
46 "Breakpoint $decimal at $hex: file .*$srcfile, line $decimal.*" \
47 "set breakpoint at marker2"
49 gdb_continue_to_breakpoint "marker1" ".*$srcfile:.*"
51 gdb_test "watch ival3" \
52 ".*\[Ww\]atchpoint $decimal: ival3.*" \
53 "set watchpoint on ival3"
55 # Continue until first change, from -1 to 0
58 ".*\[Ww\]atchpoint.*ival3.*Old value = -1.*New value = 0.*ival3 = count; ival4 = count;.*" \
59 "watchpoint hit, first time"
61 # Continue until the next change, from 0 to 1.
63 ".*\[Ww\]atchpoint.*ival3.*Old value = 0.*New value = 1.*ival3 = count; ival4 = count;.*" \
64 "watchpoint hit, second time"
66 # Continue until the next change, from 1 to 2.
68 ".*\[Ww\]atchpoint.*ival3.*Old value = 1.*New value = 2.*ival3 = count; ival4 = count;.*" \
69 "watchpoint hit, third time"
71 # Continue until the next change, from 2 to 3.
73 ".*\[Ww\]atchpoint.*ival3.*Old value = 2.*New value = 3.*ival3 = count; ival4 = count;.*" \
74 "watchpoint hit, fourth time"
76 # Continue until the next change, from 3 to 4.
77 # Note that this one is outside the loop.
80 ".*\[Ww\]atchpoint.*ival3.*Old value = 3.*New value = 4.*ival3 = count; ival4 = count;.*" \
81 "watchpoint hit, fifth time"
83 # Continue until we hit the finishing marker function.
84 # Make sure we hit no more watchpoints.
86 gdb_continue_to_breakpoint "marker2" ".*$srcfile:.*"
92 gdb_test_no_output "set exec-direction reverse" \
93 "set reverse, first time"
95 # Reverse until the previous change, from 4 to 3
96 # Note that this one is outside the loop
99 ".*\[Ww\]atchpoint.*ival3.*Old value = 4.*New value = 3.*ival3 = count; ival4 = count;.*" \
100 "watchpoint hit in reverse, first time"
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"
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"
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"
117 # Reverse until first change, from 0 to -1
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"
123 gdb_test_no_output "set can-use-hw-watchpoints 1" "enable hw watchpoints"
129 gdb_test_no_output "set exec-direction forward" "set forward"
131 # Continue until first change, from -1 to 0
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"
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"
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"
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"
152 # Continue until the next change, from 3 to 4.
153 # Note that this one is outside the loop.
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"
159 # Continue until we hit the finishing marker function.
160 # Make sure we hit no more watchpoints.
162 gdb_test "continue" "marker2 .*" "replay forward to marker2"
168 gdb_test_no_output "set exec-direction reverse" \
169 "set reverse, second time"
171 # Reverse until the previous change, from 4 to 3
172 # Note that this one is outside the loop
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"
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"
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"
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"
193 # Reverse until first change, from 0 to -1
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"