]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.reverse/machinestate-precsave.exp
Update copyright year range in all GDB files.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.reverse / machinestate-precsave.exp
CommitLineData
b811d2c2 1# Copyright 2008-2020 Free Software Foundation, Inc.
02506ff1
MS
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# This file is part of the GDB testsuite.
17# This test tests the restoration of various kinds of machine state
18# to their original values with a process record log. We will execute
19# the program forward while it changes various types of data, and
20# then execute it backward to see if their values get restored.
21#
22# The types of machine state (data) that are tested are:
23# register variable
24# auto variable
25# function static variable
26# module static variable
27# module global variable
28#
29# TODO:
30# various, possibly including...
31# .bss variable, .data variable, ...
32# shared library variable
33# heap variable (pointer)...
34# overlay variables...
35# Test forward replay
36#
37
38# This test suitable only for process record-replay
d3895d7d 39if ![supports_process_record] {
02506ff1
MS
40 return
41}
42
7686c074 43standard_testfile machinestate.c ms1.c
55baab26 44set precsave [standard_output_file machinestate.precsave]
02506ff1 45
5b362f04 46if { [prepare_for_testing "failed to prepare" $testfile \
7686c074 47 [list $srcfile $srcfile2]] } {
02506ff1
MS
48 return -1
49}
50
51set newline "\[\r\n\]+"
52
53set beginmain [gdb_get_line_number " begin main " $srcfile]
54set endmain [gdb_get_line_number " end main " $srcfile]
55
56# Test begins
57
58runto main
59
d3895d7d 60if [supports_process_record] {
02506ff1 61 # Activate process record/replay
9f058c10 62 gdb_test_no_output "record" "turn on process record"
02506ff1
MS
63}
64
65gdb_test "break $endmain" \
a80db015 66 "Breakpoint $decimal at .*$srcfile, line $endmain\." \
bb95117e 67 "breakpoint at end of main"
02506ff1
MS
68
69gdb_test "continue" "Breakpoint .* end main .*" "run to end of main"
70
55baab26
TT
71gdb_test "record save $precsave" \
72 "Saved core file $precsave with execution log\." \
02506ff1
MS
73 "save process recfile"
74
cdc7edd7 75gdb_test "kill" "" "kill process, prepare to debug log file" \
02506ff1
MS
76 "Kill the program being debugged\\? \\(y or n\\) " "y"
77
55baab26 78gdb_test "record restore $precsave" \
470e2f4e 79 "Restored records from core file .*" \
02506ff1
MS
80 "reload prec save file"
81
82# Proceed to end of main
83
84gdb_test "break $endmain" \
a80db015 85 "Breakpoint.* file .*$srcfile, line $endmain.*" ""
02506ff1
MS
86
87gdb_test_multiple "continue" "go to end of main forward" {
a80db015 88 -re ".*Breakpoint $decimal,.*$srcfile:$endmain.*$gdb_prompt $" {
02506ff1
MS
89 pass "go to end of main forward"
90 }
91 -re "No more reverse-execution history.* end main .*$gdb_prompt $" {
92 pass "go to end of main forward"
93 }
94}
95
96###
97###
98###
99
100# Now run backward to each of several points where data is changed.
101#
102
103# Module global variable, reverse
104
105set breakloc [gdb_get_line_number \
106 "module_global_state: set breakpoint here" $srcfile]
107
a80db015
LM
108gdb_test "tbreak $breakloc" ".*$srcfile, line $breakloc.*" ""
109gdb_test "reverse-continue" ".*$srcfile:$breakloc.*" "reverse to $breakloc"
02506ff1
MS
110
111gdb_test "print aglobal" ".* = 0$newline" "module global reverse-breakpoint"
112gdb_test "step" ".* module global post-change .*" ""
113gdb_test "print aglobal" ".* = 1$newline" "module global forward past bp"
114gdb_test "reverse-step" ".*$newline$breakloc.*" ""
115gdb_test "print aglobal" ".* = 0$newline" "module global reverse-step to bp"
116
117
118# Module static variable, reverse
119
120set breakloc [gdb_get_line_number \
121 "module_static_state: set breakpoint here" $srcfile]
122
a80db015
LM
123gdb_test "tbreak $breakloc" ".*$srcfile, line $breakloc.*" ""
124gdb_test "reverse-continue" ".*$srcfile:$breakloc.*" "reverse to $breakloc"
02506ff1
MS
125
126gdb_test "print astatic" ".* = 0$newline" "module static reverse-breakpoint"
127gdb_test "step" ".* module static post-change .*" ""
128gdb_test "print astatic" ".* = 1$newline" "module static forward"
129gdb_test "reverse-step" ".*$newline$breakloc.*" ""
130gdb_test "print astatic" ".* = 0$newline" "module static reverse-step"
131
132# Function static variable, reverse
133
134set breakloc [gdb_get_line_number \
135 "function_static_state: set breakpoint here" $srcfile]
136
a80db015
LM
137gdb_test "tbreak $breakloc" ".*$srcfile, line $breakloc.*" ""
138gdb_test "reverse-continue" ".*$srcfile:$breakloc.*" "reverse to $breakloc"
02506ff1
MS
139
140gdb_test "print a" ".* = 0$newline" "function static reverse-breakpoint"
141gdb_test "step" ".* function static post-change .*" ""
142gdb_test "print a" ".* = 1$newline" "function static forward"
143gdb_test "reverse-step" ".*$newline$breakloc.*" ""
144gdb_test "print a" ".* = 0$newline" "function static reverse-step"
145
146# Auto variable, reverse
147
148set breakloc [gdb_get_line_number \
149 "auto_state: set breakpoint here" $srcfile]
150
a80db015
LM
151gdb_test "tbreak $breakloc" ".*$srcfile, line $breakloc.*" ""
152gdb_test "reverse-continue" ".*$srcfile:$breakloc.*" "reverse to $breakloc"
02506ff1
MS
153
154gdb_test "print a" ".* = 0$newline" "auto var reverse-breakpoint"
155gdb_test "step" ".* auto post-change .*" ""
156gdb_test "print a" ".* = 1$newline" "auto var forward"
157gdb_test "reverse-step" ".*$newline$breakloc.*" ""
158gdb_test "print a" ".* = 0$newline" "auto var reverse-step"
159
160# Register variable, reverse
161
162set breakloc [gdb_get_line_number \
163 "register_state: set breakpoint here" $srcfile]
164
a80db015
LM
165gdb_test "tbreak $breakloc" ".*$srcfile, line $breakloc.*" ""
166gdb_test "reverse-continue" ".*$srcfile:$breakloc.*" "reverse to $breakloc"
02506ff1
MS
167
168gdb_test "print a" ".* = 0$newline" "register var reverse-breakpoint"
169gdb_test "step" ".* register post-change .*" ""
4d421147
AB
170gdb_test "print a" ".* = 1$newline" \
171 "register var step post-change, first time"
02506ff1
MS
172gdb_test "reverse-step" ".*$newline$breakloc.*" ""
173gdb_test "print a" ".* = 0$newline" "register var reverse step-to"
174
175# Proceed to beginning of main
176
a80db015
LM
177gdb_test "tbreak $beginmain" ".*$srcfile, line $beginmain.*" ""
178gdb_test "reverse-continue" ".*$srcfile:$beginmain.*" "reverse to main"
02506ff1
MS
179
180# Now repeat tests while replaying forward.
181
182# Register variable, forward
183
184set breakloc [gdb_get_line_number \
185 "register_state: set breakpoint here" $srcfile]
186
a80db015
LM
187gdb_test "tbreak $breakloc" ".*$srcfile, line $breakloc.*" ""
188gdb_test "continue" ".*$srcfile:$breakloc.*" "forward to $breakloc"
02506ff1
MS
189
190gdb_test "print a" ".* = 0$newline" "register var forward-breakpoint"
191gdb_test "reverse-step" ".*hide.*" ""
192gdb_test "step" ".*$newline$breakloc.*" ""
193gdb_test "print a" ".* = 0$newline" "register var forward step-to"
194gdb_test "step" ".* register post-change .*" ""
4d421147
AB
195gdb_test "print a" ".* = 1$newline" \
196 "register var step post-change, second time"
02506ff1
MS
197
198# Auto variable, forward
199
200set breakloc [gdb_get_line_number \
201 "auto_state: set breakpoint here" $srcfile]
202
a80db015
LM
203gdb_test "tbreak $breakloc" ".*$srcfile, line $breakloc.*" ""
204gdb_test "continue" ".*$srcfile:$breakloc.*" "forward to $breakloc"
02506ff1
MS
205
206gdb_test "print a" ".* = 0$newline" "auto var forward-breakpoint"
207gdb_test "reverse-step" ".*hide.*" ""
208gdb_test "step" ".*$newline$breakloc.*" ""
209gdb_test "print a" ".* = 0$newline" "auto var forward step-to"
210gdb_test "step" ".* auto post-change .*" ""
211gdb_test "print a" ".* = 1$newline" "auto var step post-change"
212
213# Function static variable, forward
214
215set breakloc [gdb_get_line_number \
216 "function_static_state: set breakpoint here" $srcfile]
217
a80db015
LM
218gdb_test "tbreak $breakloc" ".*$srcfile, line $breakloc.*" ""
219gdb_test "continue" ".*$srcfile:$breakloc.*" "forward to $breakloc"
02506ff1
MS
220
221gdb_test "print a" ".* = 0$newline" "function static forward-breakpoint"
222gdb_test "reverse-step" ".*hide.*" ""
223gdb_test "step" ".*$newline$breakloc.*" ""
224gdb_test "print a" ".* = 0$newline" "function static forward step-to"
225gdb_test "step" ".* function static post-change .*" ""
226gdb_test "print a" ".* = 1$newline" "function static step post-change"
227
228# Module static variable, forward
229
230set breakloc [gdb_get_line_number \
231 "module_static_state: set breakpoint here" $srcfile]
232
a80db015
LM
233gdb_test "tbreak $breakloc" ".*$srcfile, line $breakloc.*" ""
234gdb_test "continue" ".*$srcfile:$breakloc.*" "forward to $breakloc"
02506ff1
MS
235
236gdb_test "print astatic" ".* = 0$newline" "module static forward-breakpoint"
237gdb_test "reverse-step" ".*hide.*" ""
238gdb_test "step" ".*$newline$breakloc.*" ""
239gdb_test "print astatic" ".* = 0$newline" "module static forward step-to"
240gdb_test "step" ".* module static post-change .*" ""
241gdb_test "print astatic" ".* = 1$newline" "module static step post-change"
242
243# Module global variable, forward
244
245set breakloc [gdb_get_line_number \
246 "module_global_state: set breakpoint here" $srcfile]
247
a80db015
LM
248gdb_test "tbreak $breakloc" ".*$srcfile, line $breakloc.*" ""
249gdb_test "continue" ".*$srcfile:$breakloc.*" "forward to $breakloc"
02506ff1
MS
250
251gdb_test "print aglobal" ".* = 0$newline" "module global forward-breakpoint"
252gdb_test "reverse-step" ".*hide.*" ""
253gdb_test "step" ".*$newline$breakloc.*" ""
254gdb_test "print aglobal" ".* = 0$newline" "module global forward step-to"
255gdb_test "step" ".* module global post-change .*" ""
256gdb_test "print aglobal" ".* = 1$newline" "module global step post-change"
257