Upload Tizen:Base source
[external/gdb.git] / gdb / testsuite / gdb.reverse / watch-precsave.exp
1 # Copyright 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 <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 precord dumpfile
18 # debugging with watchpoints.
19
20 # This test suitable only for process record-replay
21 if ![target_info exists gdb,use_precord] {
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 set end_location  [gdb_get_line_number "end of main"  ]
41 gdb_test "break $end_location" \
42     "Breakpoint $decimal at .*/$srcfile, line $end_location\." \
43     "BP at end of main"
44
45 gdb_test "continue" "Breakpoint .* end of main .*" "run to end of main"
46
47 gdb_test "record save watch.precsave" \
48     "Saved core file watch.precsave with execution log\."  \
49     "save process recfile"
50
51 gdb_test "kill" "" "Kill process, prepare to debug log file" \
52     "Kill the program being debugged\\? \\(y or n\\) " "y"
53
54 gdb_test "record restore watch.precsave" \
55     "Program terminated with signal .*" \
56     "reload core file"
57
58 # Only software watchpoints can be used in reverse
59 gdb_test_no_output "set can-use-hw-watchpoints 0" ""
60
61 gdb_test "break marker1" \
62     "Breakpoint $decimal at $hex: file .*$srcfile, line $decimal.*" \
63     "set breakpoint at marker1"
64
65 gdb_test "break marker2" \
66     "Breakpoint $decimal at $hex: file .*$srcfile, line $decimal.*" \
67     "set breakpoint at marker2"
68
69 gdb_continue_to_breakpoint "marker1" ".*/$srcfile:.*"
70
71 gdb_test "watch ival3" \
72     ".*\[Ww\]atchpoint $decimal: ival3.*" \
73     "set watchpoint on ival3"
74
75 # Continue until first change, from -1 to 0
76
77 gdb_test "continue" \
78     ".*\[Ww\]atchpoint.*ival3.*Old value = -1.*New value = 0.*ival3 = count; ival4 = count;.*" \
79     "watchpoint hit, first time"
80
81 # Continue until the next change, from 0 to 1.
82 gdb_test "continue" \
83     ".*\[Ww\]atchpoint.*ival3.*Old value = 0.*New value = 1.*ival3 = count; ival4 = count;.*" \
84     "watchpoint hit, second time"
85
86 # Continue until the next change, from 1 to 2.
87 gdb_test "continue" \
88     ".*\[Ww\]atchpoint.*ival3.*Old value = 1.*New value = 2.*ival3 = count; ival4 = count;.*" \
89     "watchpoint hit, third time"
90
91 # Continue until the next change, from 2 to 3.
92 gdb_test "continue" \
93     ".*\[Ww\]atchpoint.*ival3.*Old value = 2.*New value = 3.*ival3 = count; ival4 = count;.*" \
94     "watchpoint hit, fourth time"
95
96 # Continue until the next change, from 3 to 4.
97 # Note that this one is outside the loop.
98
99 gdb_test "continue" \
100     ".*\[Ww\]atchpoint.*ival3.*Old value = 3.*New value = 4.*ival3 = count; ival4 = count;.*" \
101     "watchpoint hit, fifth time"
102
103 # Continue until we hit the finishing marker function.
104 # Make sure we hit no more watchpoints.
105
106 gdb_continue_to_breakpoint "marker2" ".*/$srcfile:.*"
107
108 ###
109 ###
110 ###
111
112 gdb_test_no_output "set exec-direction reverse" "set reverse"
113
114 # Reverse until the previous change, from 4 to 3
115 # Note that this one is outside the loop
116
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"
120
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"
125
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"
130
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"
135
136 # Reverse until first change, from 0 to -1
137
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"
141
142 gdb_test_no_output "set can-use-hw-watchpoints 1" "enable hw watchpoints"
143
144 ###
145 ###
146 ###
147
148 gdb_test_no_output "set exec-direction forward" "set forward"
149
150 # Continue until first change, from -1 to 0
151
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"
155
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"
160
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"
165
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"
170
171 # Continue until the next change, from 3 to 4.
172 # Note that this one is outside the loop.
173
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"
177
178 # Continue until we hit the finishing marker function.
179 # Make sure we hit no more watchpoints.
180
181 gdb_test "continue" "marker2 .*" "replay forward to marker2"
182
183 ###
184 ###
185 ###
186
187 gdb_test_no_output "set exec-direction reverse" "set reverse"
188
189 # Reverse until the previous change, from 4 to 3
190 # Note that this one is outside the loop
191
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"
195
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"
200
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"
205
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"
210
211 # Reverse until first change, from 0 to -1
212
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"
216