]>
Commit | Line | Data |
---|---|---|
8acc9f48 | 1 | # Copyright 2008-2013 Free Software Foundation, Inc. |
28d41a99 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 by reverse execution. 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 | ||
d3895d7d | 38 | if ![supports_reverse] { |
28d41a99 MS |
39 | return |
40 | } | |
41 | ||
7686c074 | 42 | standard_testfile .c ms1.c |
28d41a99 | 43 | |
7686c074 TT |
44 | if { [prepare_for_testing $testfile.exp $testfile \ |
45 | [list $srcfile $srcfile2]] } { | |
28d41a99 MS |
46 | return -1 |
47 | } | |
48 | ||
49 | set newline "\[\r\n\]+" | |
50 | ||
51 | set beginmain [gdb_get_line_number " begin main " $srcfile] | |
52 | set endmain [gdb_get_line_number " end main " $srcfile] | |
53 | ||
54 | # Test begins | |
55 | ||
56 | runto main | |
57 | ||
d3895d7d | 58 | if [supports_process_record] { |
28d41a99 | 59 | # Activate process record/replay |
bcd2dc50 | 60 | gdb_test_no_output "record" "Turn on process record" |
28d41a99 MS |
61 | } |
62 | ||
63 | # Proceed to end of main | |
64 | ||
65 | gdb_test "break $endmain" \ | |
66 | "Breakpoint.* file .*/$srcfile, line $endmain.*" "" | |
67 | gdb_continue_to_breakpoint "end of main" ".*/$srcfile:$endmain.*" | |
68 | ||
69 | ### | |
70 | ### | |
71 | ### | |
72 | ||
73 | # Now run backward to each of several points where data is changed. | |
74 | # | |
75 | ||
76 | # Module global variable, reverse | |
77 | ||
78 | set breakloc [gdb_get_line_number \ | |
79 | "module_global_state: set breakpoint here" $srcfile] | |
80 | ||
81 | gdb_test "tbreak $breakloc" ".*/$srcfile, line $breakloc.*" "" | |
82 | gdb_test "reverse-continue" ".*/$srcfile:$breakloc.*" "reverse to $breakloc" | |
83 | ||
84 | gdb_test "print aglobal" ".* = 0$newline" "module global reverse-breakpoint" | |
85 | gdb_test "step" ".* module global post-change .*" "" | |
86 | gdb_test "print aglobal" ".* = 1$newline" "module global forward past bp" | |
87 | gdb_test "reverse-step" ".*$newline$breakloc.*" "" | |
88 | gdb_test "print aglobal" ".* = 0$newline" "module global reverse-step to bp" | |
89 | ||
90 | ||
91 | # Module static variable, reverse | |
92 | ||
93 | set breakloc [gdb_get_line_number \ | |
94 | "module_static_state: set breakpoint here" $srcfile] | |
95 | ||
96 | gdb_test "tbreak $breakloc" ".*/$srcfile, line $breakloc.*" "" | |
97 | gdb_test "reverse-continue" ".*/$srcfile:$breakloc.*" "reverse to $breakloc" | |
98 | ||
99 | gdb_test "print astatic" ".* = 0$newline" "module static reverse-breakpoint" | |
100 | gdb_test "step" ".* module static post-change .*" "" | |
101 | gdb_test "print astatic" ".* = 1$newline" "module static forward" | |
102 | gdb_test "reverse-step" ".*$newline$breakloc.*" "" | |
103 | gdb_test "print astatic" ".* = 0$newline" "module static reverse-step" | |
104 | ||
105 | # Function static variable, reverse | |
106 | ||
107 | set breakloc [gdb_get_line_number \ | |
108 | "function_static_state: set breakpoint here" $srcfile] | |
109 | ||
110 | gdb_test "tbreak $breakloc" ".*/$srcfile, line $breakloc.*" "" | |
111 | gdb_test "reverse-continue" ".*/$srcfile:$breakloc.*" "reverse to $breakloc" | |
112 | ||
113 | gdb_test "print a" ".* = 0$newline" "function static reverse-breakpoint" | |
114 | gdb_test "step" ".* function static post-change .*" "" | |
115 | gdb_test "print a" ".* = 1$newline" "function static forward" | |
116 | gdb_test "reverse-step" ".*$newline$breakloc.*" "" | |
117 | gdb_test "print a" ".* = 0$newline" "function static reverse-step" | |
118 | ||
119 | # Auto variable, reverse | |
120 | ||
121 | set breakloc [gdb_get_line_number \ | |
122 | "auto_state: set breakpoint here" $srcfile] | |
123 | ||
124 | gdb_test "tbreak $breakloc" ".*/$srcfile, line $breakloc.*" "" | |
125 | gdb_test "reverse-continue" ".*/$srcfile:$breakloc.*" "reverse to $breakloc" | |
126 | ||
127 | gdb_test "print a" ".* = 0$newline" "auto var reverse-breakpoint" | |
128 | gdb_test "step" ".* auto post-change .*" "" | |
129 | gdb_test "print a" ".* = 1$newline" "auto var forward" | |
130 | gdb_test "reverse-step" ".*$newline$breakloc.*" "" | |
131 | gdb_test "print a" ".* = 0$newline" "auto var reverse-step" | |
132 | ||
133 | # Register variable, reverse | |
134 | ||
135 | set breakloc [gdb_get_line_number \ | |
136 | "register_state: set breakpoint here" $srcfile] | |
137 | ||
138 | gdb_test "tbreak $breakloc" ".*/$srcfile, line $breakloc.*" "" | |
139 | gdb_test "reverse-continue" ".*/$srcfile:$breakloc.*" "reverse to $breakloc" | |
140 | ||
141 | gdb_test "print a" ".* = 0$newline" "register var reverse-breakpoint" | |
142 | gdb_test "step" ".* register post-change .*" "" | |
143 | gdb_test "print a" ".* = 1$newline" "register var step post-change" | |
144 | gdb_test "reverse-step" ".*$newline$breakloc.*" "" | |
145 | gdb_test "print a" ".* = 0$newline" "register var reverse step-to" | |
146 | ||
147 | # Proceed to beginning of main | |
148 | ||
149 | gdb_test "tbreak $beginmain" ".*/$srcfile, line $beginmain.*" "" | |
150 | gdb_test "reverse-continue" ".*/$srcfile:$beginmain.*" "reverse to main" | |
151 | ||
152 | # Now repeat tests while replaying forward. | |
153 | ||
154 | # Register variable, forward | |
155 | ||
156 | set breakloc [gdb_get_line_number \ | |
157 | "register_state: set breakpoint here" $srcfile] | |
158 | ||
159 | gdb_test "tbreak $breakloc" ".*/$srcfile, line $breakloc.*" "" | |
160 | gdb_test "continue" ".*/$srcfile:$breakloc.*" "forward to $breakloc" | |
161 | ||
162 | gdb_test "print a" ".* = 0$newline" "register var forward-breakpoint" | |
163 | gdb_test "reverse-step" ".*hide.*" "" | |
164 | gdb_test "step" ".*$newline$breakloc.*" "" | |
165 | gdb_test "print a" ".* = 0$newline" "register var forward step-to" | |
166 | gdb_test "step" ".* register post-change .*" "" | |
167 | gdb_test "print a" ".* = 1$newline" "register var step post-change" | |
168 | ||
169 | # Auto variable, forward | |
170 | ||
171 | set breakloc [gdb_get_line_number \ | |
172 | "auto_state: set breakpoint here" $srcfile] | |
173 | ||
174 | gdb_test "tbreak $breakloc" ".*/$srcfile, line $breakloc.*" "" | |
175 | gdb_test "continue" ".*/$srcfile:$breakloc.*" "forward to $breakloc" | |
176 | ||
177 | gdb_test "print a" ".* = 0$newline" "auto var forward-breakpoint" | |
178 | gdb_test "reverse-step" ".*hide.*" "" | |
179 | gdb_test "step" ".*$newline$breakloc.*" "" | |
180 | gdb_test "print a" ".* = 0$newline" "auto var forward step-to" | |
181 | gdb_test "step" ".* auto post-change .*" "" | |
182 | gdb_test "print a" ".* = 1$newline" "auto var step post-change" | |
183 | ||
184 | # Function static variable, forward | |
185 | ||
186 | set breakloc [gdb_get_line_number \ | |
187 | "function_static_state: set breakpoint here" $srcfile] | |
188 | ||
189 | gdb_test "tbreak $breakloc" ".*/$srcfile, line $breakloc.*" "" | |
190 | gdb_test "continue" ".*/$srcfile:$breakloc.*" "forward to $breakloc" | |
191 | ||
192 | gdb_test "print a" ".* = 0$newline" "function static forward-breakpoint" | |
193 | gdb_test "reverse-step" ".*hide.*" "" | |
194 | gdb_test "step" ".*$newline$breakloc.*" "" | |
195 | gdb_test "print a" ".* = 0$newline" "function static forward step-to" | |
196 | gdb_test "step" ".* function static post-change .*" "" | |
197 | gdb_test "print a" ".* = 1$newline" "function static step post-change" | |
198 | ||
199 | # Module static variable, forward | |
200 | ||
201 | set breakloc [gdb_get_line_number \ | |
202 | "module_static_state: set breakpoint here" $srcfile] | |
203 | ||
204 | gdb_test "tbreak $breakloc" ".*/$srcfile, line $breakloc.*" "" | |
205 | gdb_test "continue" ".*/$srcfile:$breakloc.*" "forward to $breakloc" | |
206 | ||
207 | gdb_test "print astatic" ".* = 0$newline" "module static forward-breakpoint" | |
208 | gdb_test "reverse-step" ".*hide.*" "" | |
209 | gdb_test "step" ".*$newline$breakloc.*" "" | |
210 | gdb_test "print astatic" ".* = 0$newline" "module static forward step-to" | |
211 | gdb_test "step" ".* module static post-change .*" "" | |
212 | gdb_test "print astatic" ".* = 1$newline" "module static step post-change" | |
213 | ||
214 | # Module global variable, forward | |
215 | ||
216 | set breakloc [gdb_get_line_number \ | |
217 | "module_global_state: set breakpoint here" $srcfile] | |
218 | ||
219 | gdb_test "tbreak $breakloc" ".*/$srcfile, line $breakloc.*" "" | |
220 | gdb_test "continue" ".*/$srcfile:$breakloc.*" "forward to $breakloc" | |
221 | ||
222 | gdb_test "print aglobal" ".* = 0$newline" "module global forward-breakpoint" | |
223 | gdb_test "reverse-step" ".*hide.*" "" | |
224 | gdb_test "step" ".*$newline$breakloc.*" "" | |
225 | gdb_test "print aglobal" ".* = 0$newline" "module global forward step-to" | |
226 | gdb_test "step" ".* module global post-change .*" "" | |
227 | gdb_test "print aglobal" ".* = 1$newline" "module global step post-change" | |
228 |