1 # Copyright 2009-2012 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] {
25 set testfile "watch-reverse"
26 set srcfile ${testfile}.c
27 set binfile ${objdir}/${subdir}/${testfile}
29 if { [prepare_for_testing $testfile.exp $testfile $srcfile] } {
35 if [supports_process_record] {
36 # Activate process record/replay
37 gdb_test_no_output "record" "Turn on process record"
40 set end_location [gdb_get_line_number "end of main" ]
41 gdb_test "break $end_location" \
42 "Breakpoint $decimal at .*/$srcfile, line $end_location\." \
45 gdb_test "continue" "Breakpoint .* end of main .*" "run to end of main"
47 gdb_test "record save watch.precsave" \
48 "Saved core file watch.precsave with execution log\." \
49 "save process recfile"
51 gdb_test "kill" "" "Kill process, prepare to debug log file" \
52 "Kill the program being debugged\\? \\(y or n\\) " "y"
54 gdb_test "record restore watch.precsave" \
55 "Program terminated with signal .*" \
58 # Only software watchpoints can be used in reverse
59 gdb_test_no_output "set can-use-hw-watchpoints 0" ""
61 gdb_test "break marker1" \
62 "Breakpoint $decimal at $hex: file .*$srcfile, line $decimal.*" \
63 "set breakpoint at marker1"
65 gdb_test "break marker2" \
66 "Breakpoint $decimal at $hex: file .*$srcfile, line $decimal.*" \
67 "set breakpoint at marker2"
69 gdb_continue_to_breakpoint "marker1" ".*/$srcfile:.*"
71 gdb_test "watch ival3" \
72 ".*\[Ww\]atchpoint $decimal: ival3.*" \
73 "set watchpoint on ival3"
75 # Continue until first change, from -1 to 0
78 ".*\[Ww\]atchpoint.*ival3.*Old value = -1.*New value = 0.*ival3 = count; ival4 = count;.*" \
79 "watchpoint hit, first time"
81 # Continue until the next change, from 0 to 1.
83 ".*\[Ww\]atchpoint.*ival3.*Old value = 0.*New value = 1.*ival3 = count; ival4 = count;.*" \
84 "watchpoint hit, second time"
86 # Continue until the next change, from 1 to 2.
88 ".*\[Ww\]atchpoint.*ival3.*Old value = 1.*New value = 2.*ival3 = count; ival4 = count;.*" \
89 "watchpoint hit, third time"
91 # Continue until the next change, from 2 to 3.
93 ".*\[Ww\]atchpoint.*ival3.*Old value = 2.*New value = 3.*ival3 = count; ival4 = count;.*" \
94 "watchpoint hit, fourth time"
96 # Continue until the next change, from 3 to 4.
97 # Note that this one is outside the loop.
100 ".*\[Ww\]atchpoint.*ival3.*Old value = 3.*New value = 4.*ival3 = count; ival4 = count;.*" \
101 "watchpoint hit, fifth time"
103 # Continue until we hit the finishing marker function.
104 # Make sure we hit no more watchpoints.
106 gdb_continue_to_breakpoint "marker2" ".*/$srcfile:.*"
112 gdb_test_no_output "set exec-direction reverse" "set reverse"
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" "set reverse"
189 # Reverse until the previous change, from 4 to 3
190 # Note that this one is outside the loop
192 gdb_test "continue" \
193 ".*\[Ww\]atchpoint.*ival3.*Old value = 4.*New value = 3.*ival3 = count; ival4 = count;.*" \
194 "watchpoint hit in reverse, HW, first time"
196 # Reverse until the previous change, from 3 to 2.
197 gdb_test "continue" \
198 ".*\[Ww\]atchpoint.*ival3.*Old value = 3.*New value = 2.*ival3 = count; ival4 = count;.*" \
199 "watchpoint hit in reverse, HW, second time"
201 # Reverse until the previous change, from 2 to 1.
202 gdb_test "continue" \
203 ".*\[Ww\]atchpoint.*ival3.*Old value = 2.*New value = 1.*ival3 = count; ival4 = count;.*" \
204 "watchpoint hit in reverse, HW, third time"
206 # Reverse until the previous change, from 1 to 0.
207 gdb_test "continue" \
208 ".*\[Ww\]atchpoint.*ival3.*Old value = 1.*New value = 0.*ival3 = count; ival4 = count;.*" \
209 "watchpoint hit in reverse, HW, fourth time"
211 # Reverse until first change, from 0 to -1
213 gdb_test "continue" \
214 ".*\[Ww\]atchpoint.*ival3.*Old value = 0.*New value = -1.*ival3 = count; ival4 = count;.*" \
215 "watchpoint hit in reverse, HW, fifth time"