1 |
330 |
jeremybenn |
# Copyright 2008, 2009, 2010 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 .
|
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 ![target_info exists gdb,can_reverse] {
|
22 |
|
|
return
|
23 |
|
|
}
|
24 |
|
|
|
25 |
|
|
set testfile "watch-reverse"
|
26 |
|
|
set srcfile ${testfile}.c
|
27 |
|
|
set binfile ${objdir}/${subdir}/${testfile}
|
28 |
|
|
|
29 |
|
|
if { [prepare_for_testing $testfile.exp $testfile $srcfile] } {
|
30 |
|
|
return -1
|
31 |
|
|
}
|
32 |
|
|
|
33 |
|
|
runto main
|
34 |
|
|
|
35 |
|
|
if [target_info exists gdb,use_precord] {
|
36 |
|
|
# Activate process record/replay
|
37 |
|
|
gdb_test_no_output "record" "Turn on process record"
|
38 |
|
|
}
|
39 |
|
|
|
40 |
|
|
# Test software watchpoints
|
41 |
|
|
gdb_test_no_output "set can-use-hw-watchpoints 0" "disable hw watchpoints"
|
42 |
|
|
|
43 |
|
|
gdb_test "break marker1" \
|
44 |
|
|
"Breakpoint $decimal at $hex: file .*$srcfile, line $decimal.*" \
|
45 |
|
|
"set breakpoint at marker1"
|
46 |
|
|
|
47 |
|
|
gdb_test "break marker2" \
|
48 |
|
|
"Breakpoint $decimal at $hex: file .*$srcfile, line $decimal.*" \
|
49 |
|
|
"set breakpoint at marker2"
|
50 |
|
|
|
51 |
|
|
gdb_continue_to_breakpoint "marker1" ".*/$srcfile:.*"
|
52 |
|
|
|
53 |
|
|
gdb_test "watch ival3" \
|
54 |
|
|
".*\[Ww\]atchpoint $decimal: ival3.*" \
|
55 |
|
|
"set watchpoint on ival3"
|
56 |
|
|
|
57 |
|
|
# Continue until first change, from -1 to 0
|
58 |
|
|
|
59 |
|
|
gdb_test "continue" \
|
60 |
|
|
".*\[Ww\]atchpoint.*ival3.*Old value = -1.*New value = 0.*ival3 = count; ival4 = count;.*" \
|
61 |
|
|
"watchpoint hit, first time"
|
62 |
|
|
|
63 |
|
|
# Continue until the next change, from 0 to 1.
|
64 |
|
|
gdb_test "continue" \
|
65 |
|
|
".*\[Ww\]atchpoint.*ival3.*Old value = 0.*New value = 1.*ival3 = count; ival4 = count;.*" \
|
66 |
|
|
"watchpoint hit, second time"
|
67 |
|
|
|
68 |
|
|
# Continue until the next change, from 1 to 2.
|
69 |
|
|
gdb_test "continue" \
|
70 |
|
|
".*\[Ww\]atchpoint.*ival3.*Old value = 1.*New value = 2.*ival3 = count; ival4 = count;.*" \
|
71 |
|
|
"watchpoint hit, third time"
|
72 |
|
|
|
73 |
|
|
# Continue until the next change, from 2 to 3.
|
74 |
|
|
gdb_test "continue" \
|
75 |
|
|
".*\[Ww\]atchpoint.*ival3.*Old value = 2.*New value = 3.*ival3 = count; ival4 = count;.*" \
|
76 |
|
|
"watchpoint hit, fourth time"
|
77 |
|
|
|
78 |
|
|
# Continue until the next change, from 3 to 4.
|
79 |
|
|
# Note that this one is outside the loop.
|
80 |
|
|
|
81 |
|
|
gdb_test "continue" \
|
82 |
|
|
".*\[Ww\]atchpoint.*ival3.*Old value = 3.*New value = 4.*ival3 = count; ival4 = count;.*" \
|
83 |
|
|
"watchpoint hit, fifth time"
|
84 |
|
|
|
85 |
|
|
# Continue until we hit the finishing marker function.
|
86 |
|
|
# Make sure we hit no more watchpoints.
|
87 |
|
|
|
88 |
|
|
gdb_continue_to_breakpoint "marker2" ".*/$srcfile:.*"
|
89 |
|
|
|
90 |
|
|
###
|
91 |
|
|
###
|
92 |
|
|
###
|
93 |
|
|
|
94 |
|
|
gdb_test_no_output "set exec-direction reverse" "set reverse"
|
95 |
|
|
|
96 |
|
|
# Reverse until the previous change, from 4 to 3
|
97 |
|
|
# Note that this one is outside the loop
|
98 |
|
|
|
99 |
|
|
gdb_test "continue" \
|
100 |
|
|
".*\[Ww\]atchpoint.*ival3.*Old value = 4.*New value = 3.*ival3 = count; ival4 = count;.*" \
|
101 |
|
|
"watchpoint hit in reverse, first time"
|
102 |
|
|
|
103 |
|
|
# Reverse until the previous change, from 3 to 2.
|
104 |
|
|
gdb_test "continue" \
|
105 |
|
|
".*\[Ww\]atchpoint.*ival3.*Old value = 3.*New value = 2.*ival3 = count; ival4 = count;.*" \
|
106 |
|
|
"watchpoint hit in reverse, second time"
|
107 |
|
|
|
108 |
|
|
# Reverse until the previous change, from 2 to 1.
|
109 |
|
|
gdb_test "continue" \
|
110 |
|
|
".*\[Ww\]atchpoint.*ival3.*Old value = 2.*New value = 1.*ival3 = count; ival4 = count;.*" \
|
111 |
|
|
"watchpoint hit in reverse, third time"
|
112 |
|
|
|
113 |
|
|
# Reverse until the previous change, from 1 to 0.
|
114 |
|
|
gdb_test "continue" \
|
115 |
|
|
".*\[Ww\]atchpoint.*ival3.*Old value = 1.*New value = 0.*ival3 = count; ival4 = count;.*" \
|
116 |
|
|
"watchpoint hit in reverse, fourth time"
|
117 |
|
|
|
118 |
|
|
# Reverse until first change, from 0 to -1
|
119 |
|
|
|
120 |
|
|
gdb_test "continue" \
|
121 |
|
|
".*\[Ww\]atchpoint.*ival3.*Old value = 0.*New value = -1.*ival3 = count; ival4 = count;.*" \
|
122 |
|
|
"watchpoint hit in reverse, fifth time"
|
123 |
|
|
|
124 |
|
|
gdb_test_no_output "set can-use-hw-watchpoints 1" "enable hw watchpoints"
|
125 |
|
|
|
126 |
|
|
###
|
127 |
|
|
###
|
128 |
|
|
###
|
129 |
|
|
|
130 |
|
|
gdb_test_no_output "set exec-direction forward" "set forward"
|
131 |
|
|
|
132 |
|
|
# Continue until first change, from -1 to 0
|
133 |
|
|
|
134 |
|
|
gdb_test "continue" \
|
135 |
|
|
".*\[Ww\]atchpoint.*ival3.*Old value = -1.*New value = 0.*ival3 = count; ival4 = count;.*" \
|
136 |
|
|
"watchpoint hit, forward replay, first time"
|
137 |
|
|
|
138 |
|
|
# Continue until the next change, from 0 to 1.
|
139 |
|
|
gdb_test "continue" \
|
140 |
|
|
".*\[Ww\]atchpoint.*ival3.*Old value = 0.*New value = 1.*ival3 = count; ival4 = count;.*" \
|
141 |
|
|
"watchpoint hit, forward replay, second time"
|
142 |
|
|
|
143 |
|
|
# Continue until the next change, from 1 to 2.
|
144 |
|
|
gdb_test "continue" \
|
145 |
|
|
".*\[Ww\]atchpoint.*ival3.*Old value = 1.*New value = 2.*ival3 = count; ival4 = count;.*" \
|
146 |
|
|
"watchpoint hit, forward replay, third time"
|
147 |
|
|
|
148 |
|
|
# Continue until the next change, from 2 to 3.
|
149 |
|
|
gdb_test "continue" \
|
150 |
|
|
".*\[Ww\]atchpoint.*ival3.*Old value = 2.*New value = 3.*ival3 = count; ival4 = count;.*" \
|
151 |
|
|
"watchpoint hit, forward replay, fourth time"
|
152 |
|
|
|
153 |
|
|
# Continue until the next change, from 3 to 4.
|
154 |
|
|
# Note that this one is outside the loop.
|
155 |
|
|
|
156 |
|
|
gdb_test "continue" \
|
157 |
|
|
".*\[Ww\]atchpoint.*ival3.*Old value = 3.*New value = 4.*ival3 = count; ival4 = count;.*" \
|
158 |
|
|
"watchpoint hit, forward replay, fifth time"
|
159 |
|
|
|
160 |
|
|
# Continue until we hit the finishing marker function.
|
161 |
|
|
# Make sure we hit no more watchpoints.
|
162 |
|
|
|
163 |
|
|
gdb_test "continue" "marker2 .*" "replay forward to marker2"
|
164 |
|
|
|
165 |
|
|
###
|
166 |
|
|
###
|
167 |
|
|
###
|
168 |
|
|
|
169 |
|
|
gdb_test_no_output "set exec-direction reverse" "set reverse"
|
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 |
|
|
|