1 # Copyright 2009-2014 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 standard_testfile watch-reverse.c
26 set precsave [standard_output_file watch.precsave]
28 if { [prepare_for_testing $testfile.exp $testfile $srcfile] } {
34 if [supports_process_record] {
35 # Activate process record/replay
36 gdb_test_no_output "record" "Turn on process record"
39 set end_location [gdb_get_line_number "end of main" ]
40 gdb_test "break $end_location" \
41 "Breakpoint $decimal at .*$srcfile, line $end_location\." \
44 gdb_test "continue" "Breakpoint .* end of main .*" "run to end of main"
46 gdb_test "record save $precsave" \
47 "Saved core file $precsave with execution log\." \
48 "save process recfile"
50 gdb_test "kill" "" "Kill process, prepare to debug log file" \
51 "Kill the program being debugged\\? \\(y or n\\) " "y"
53 gdb_test "record restore $precsave" \
54 "Program terminated with signal .*" \
57 # Only software watchpoints can be used in reverse
58 gdb_test_no_output "set can-use-hw-watchpoints 0" ""
60 gdb_test "break marker1" \
61 "Breakpoint $decimal at $hex: file .*$srcfile, line $decimal.*" \
62 "set breakpoint at marker1"
64 gdb_test "break marker2" \
65 "Breakpoint $decimal at $hex: file .*$srcfile, line $decimal.*" \
66 "set breakpoint at marker2"
68 gdb_continue_to_breakpoint "marker1" ".*$srcfile:.*"
70 gdb_test "watch ival3" \
71 ".*\[Ww\]atchpoint $decimal: ival3.*" \
72 "set watchpoint on ival3"
74 # Continue until first change, from -1 to 0
77 ".*\[Ww\]atchpoint.*ival3.*Old value = -1.*New value = 0.*ival3 = count; ival4 = count;.*" \
78 "watchpoint hit, first time"
80 # Continue until the next change, from 0 to 1.
82 ".*\[Ww\]atchpoint.*ival3.*Old value = 0.*New value = 1.*ival3 = count; ival4 = count;.*" \
83 "watchpoint hit, second time"
85 # Continue until the next change, from 1 to 2.
87 ".*\[Ww\]atchpoint.*ival3.*Old value = 1.*New value = 2.*ival3 = count; ival4 = count;.*" \
88 "watchpoint hit, third time"
90 # Continue until the next change, from 2 to 3.
92 ".*\[Ww\]atchpoint.*ival3.*Old value = 2.*New value = 3.*ival3 = count; ival4 = count;.*" \
93 "watchpoint hit, fourth time"
95 # Continue until the next change, from 3 to 4.
96 # Note that this one is outside the loop.
99 ".*\[Ww\]atchpoint.*ival3.*Old value = 3.*New value = 4.*ival3 = count; ival4 = count;.*" \
100 "watchpoint hit, fifth time"
102 # Continue until we hit the finishing marker function.
103 # Make sure we hit no more watchpoints.
105 gdb_continue_to_breakpoint "marker2" ".*$srcfile:.*"
111 gdb_test_no_output "set exec-direction reverse" "set reverse"
113 # Reverse until the previous change, from 4 to 3
114 # Note that this one is outside the loop
116 gdb_test "continue" \
117 ".*\[Ww\]atchpoint.*ival3.*Old value = 4.*New value = 3.*ival3 = count; ival4 = count;.*" \
118 "watchpoint hit in reverse, first time"
120 # Reverse until the previous change, from 3 to 2.
121 gdb_test "continue" \
122 ".*\[Ww\]atchpoint.*ival3.*Old value = 3.*New value = 2.*ival3 = count; ival4 = count;.*" \
123 "watchpoint hit in reverse, second time"
125 # Reverse until the previous change, from 2 to 1.
126 gdb_test "continue" \
127 ".*\[Ww\]atchpoint.*ival3.*Old value = 2.*New value = 1.*ival3 = count; ival4 = count;.*" \
128 "watchpoint hit in reverse, third time"
130 # Reverse until the previous change, from 1 to 0.
131 gdb_test "continue" \
132 ".*\[Ww\]atchpoint.*ival3.*Old value = 1.*New value = 0.*ival3 = count; ival4 = count;.*" \
133 "watchpoint hit in reverse, fourth time"
135 # Reverse until first change, from 0 to -1
137 gdb_test "continue" \
138 ".*\[Ww\]atchpoint.*ival3.*Old value = 0.*New value = -1.*ival3 = count; ival4 = count;.*" \
139 "watchpoint hit in reverse, fifth time"
141 gdb_test_no_output "set can-use-hw-watchpoints 1" "enable hw watchpoints"
147 gdb_test_no_output "set exec-direction forward" "set forward"
149 # Continue until first change, from -1 to 0
151 gdb_test "continue" \
152 ".*\[Ww\]atchpoint.*ival3.*Old value = -1.*New value = 0.*ival3 = count; ival4 = count;.*" \
153 "watchpoint hit, forward replay, first time"
155 # Continue until the next change, from 0 to 1.
156 gdb_test "continue" \
157 ".*\[Ww\]atchpoint.*ival3.*Old value = 0.*New value = 1.*ival3 = count; ival4 = count;.*" \
158 "watchpoint hit, forward replay, second time"
160 # Continue until the next change, from 1 to 2.
161 gdb_test "continue" \
162 ".*\[Ww\]atchpoint.*ival3.*Old value = 1.*New value = 2.*ival3 = count; ival4 = count;.*" \
163 "watchpoint hit, forward replay, third time"
165 # Continue until the next change, from 2 to 3.
166 gdb_test "continue" \
167 ".*\[Ww\]atchpoint.*ival3.*Old value = 2.*New value = 3.*ival3 = count; ival4 = count;.*" \
168 "watchpoint hit, forward replay, fourth time"
170 # Continue until the next change, from 3 to 4.
171 # Note that this one is outside the loop.
173 gdb_test "continue" \
174 ".*\[Ww\]atchpoint.*ival3.*Old value = 3.*New value = 4.*ival3 = count; ival4 = count;.*" \
175 "watchpoint hit, forward replay, fifth time"
177 # Continue until we hit the finishing marker function.
178 # Make sure we hit no more watchpoints.
180 gdb_test "continue" "marker2 .*" "replay forward to marker2"
186 gdb_test_no_output "set exec-direction reverse" "set reverse"
188 # Reverse until the previous change, from 4 to 3
189 # Note that this one is outside the loop
191 gdb_test "continue" \
192 ".*\[Ww\]atchpoint.*ival3.*Old value = 4.*New value = 3.*ival3 = count; ival4 = count;.*" \
193 "watchpoint hit in reverse, HW, first time"
195 # Reverse until the previous change, from 3 to 2.
196 gdb_test "continue" \
197 ".*\[Ww\]atchpoint.*ival3.*Old value = 3.*New value = 2.*ival3 = count; ival4 = count;.*" \
198 "watchpoint hit in reverse, HW, second time"
200 # Reverse until the previous change, from 2 to 1.
201 gdb_test "continue" \
202 ".*\[Ww\]atchpoint.*ival3.*Old value = 2.*New value = 1.*ival3 = count; ival4 = count;.*" \
203 "watchpoint hit in reverse, HW, third time"
205 # Reverse until the previous change, from 1 to 0.
206 gdb_test "continue" \
207 ".*\[Ww\]atchpoint.*ival3.*Old value = 1.*New value = 0.*ival3 = count; ival4 = count;.*" \
208 "watchpoint hit in reverse, HW, fourth time"
210 # Reverse until first change, from 0 to -1
212 gdb_test "continue" \
213 ".*\[Ww\]atchpoint.*ival3.*Old value = 0.*New value = -1.*ival3 = count; ival4 = count;.*" \
214 "watchpoint hit in reverse, HW, fifth time"