Tweak gdb.reverse/step-precsave.exp and gdb.reverse/step-reverse.exp
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.reverse / step-precsave.exp
1 # Copyright 2008-2016 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 # This file is part of the GDB testsuite. It tests reverse stepping.
17 # Lots of code borrowed from "step-test.exp".
18
19 #
20 # Test step and next with a reloaded process record file.
21 #
22
23 # This test suitable only for process record-replay
24 if ![supports_process_record] {
25 return
26 }
27
28 standard_testfile step-reverse.c
29 set precsave [standard_output_file step.precsave]
30
31 if { [prepare_for_testing $testfile.exp $testfile $srcfile] } {
32 return -1
33 }
34
35 runto main
36
37 if [supports_process_record] {
38 # Activate process record/replay
39 gdb_test_no_output "record" "Turn on process record"
40 }
41
42 set end_of_main [gdb_get_line_number "end of main" ]
43 gdb_test "break $end_of_main" \
44 "Breakpoint $decimal at .*$srcfile, line $end_of_main\." \
45 "BP at end of main"
46
47 # This can take awhile.
48 with_timeout_factor 20 {
49 gdb_test "continue" "Breakpoint .* end of main .*" "run to end of main"
50 }
51
52 # So can this, against gdbserver, for example.
53
54 with_timeout_factor 10 {
55 gdb_test "record save $precsave" \
56 "Saved core file $precsave with execution log\." \
57 "save process recfile"
58 }
59
60 gdb_test "kill" "" "Kill process, prepare to debug log file" \
61 "Kill the program being debugged\\? \\(y or n\\) " "y"
62
63 gdb_test "record restore $precsave" \
64 "Restored records from core file .*" \
65 "reload core file"
66
67 # plain vanilla step/next (no count)
68
69 gdb_test "next" ".*NEXT TEST 1.*" "next test 1"
70 gdb_test "step" ".*STEP TEST 1.*" "step test 1"
71
72 # step/next with count
73
74 gdb_test "next 2" ".*NEXT TEST 2.*" "next test 2"
75 gdb_test "step 3" ".*STEP TEST 2.*" "step test 2"
76
77 # step over call
78
79 gdb_test "step" ".*NEXT OVER THIS CALL.*" "step up to call"
80 gdb_test "next" ".*STEP INTO THIS CALL.*" "next over call"
81
82 # step into call
83
84 gdb_test "step" ".*ARRIVED IN CALLEE.*" "step into call"
85
86 # finish out of call
87
88 set test_message "finish out of fn call"
89 gdb_test_multiple "finish" "$test_message" {
90 -re "FINISH TEST.*$gdb_prompt $" {
91 pass "$test_message"
92 }
93 -re "STEP INTO THIS CALL.*$gdb_prompt $" {
94 send_gdb "step\n"
95 exp_continue
96 }
97 }
98
99 # stepi over flat code (no calls)
100
101 set test_message "simple stepi"
102 gdb_test_multiple "stepi" "$test_message" {
103 -re "STEPI TEST.*$gdb_prompt $" {
104 pass "$test_message"
105 }
106 -re "FINISH TEST.*$gdb_prompt $" {
107 send_gdb "stepi\n"
108 exp_continue
109 }
110 -re "NEXTI TEST.*$gdb_prompt $" {
111 fail "$test_message (too far)"
112 }
113 }
114
115 # stepi into a function call
116
117 set test_message "stepi into function call"
118 gdb_test_multiple "stepi" "$test_message" {
119 -re "ARRIVED IN CALLEE.*$gdb_prompt $" {
120 pass "$test_message"
121 }
122 -re "NEXTI TEST.*$gdb_prompt $" {
123 fail "$test_message (too far)"
124 }
125 -re "RETURN FROM CALLEE.*$gdb_prompt $" {
126 fail "$test_message (too far)"
127 }
128 -re "ENTER CALLEE.*$gdb_prompt $" {
129 send_gdb "stepi\n"
130 exp_continue
131 }
132 -re "STEPI TEST.*$gdb_prompt $" {
133 send_gdb "stepi\n"
134 exp_continue
135 }
136 }
137
138 # stepi thru return of a function call
139
140 set test_message "stepi back from function call"
141 gdb_test_multiple "stepi" "$test_message" {
142 -re "NEXTI TEST.*$gdb_prompt $" {
143 pass "$test_message"
144 }
145 -re "ARRIVED IN CALLEE.*$gdb_prompt $" {
146 send_gdb "stepi\n"
147 exp_continue
148 }
149 -re "RETURN FROM CALLEE.*$gdb_prompt $" {
150 send_gdb "stepi\n"
151 exp_continue
152 }
153 -re "STEPI TEST.*$gdb_prompt $" {
154 send_gdb "stepi\n"
155 exp_continue
156 }
157 -re "ENTER CALLEE.*$gdb_prompt $" {
158 fail "$test_message (too far)"
159 }
160 }
161
162 ###
163 ###
164 ###
165
166 # Set reverse execution direction
167
168 gdb_test_no_output "set exec-dir reverse" "set reverse execution"
169
170 # stepi backward thru return and into a function
171
172 set stepi_location [gdb_get_line_number "ARRIVED IN CALLEE" "$srcfile"]
173 set test_message "reverse stepi thru function return"
174 gdb_test_multiple "stepi" "$test_message" {
175 -re "NEXTI TEST.*$gdb_prompt $" {
176 fail "$test_message (start statement)"
177 }
178 -re "RETURN FROM CALLEE.*$gdb_prompt $" {
179 send_gdb "stepi\n"
180 exp_continue
181 }
182 -re "$hex\[ \t\]*$stepi_location.*ARRIVED IN CALLEE.*$gdb_prompt $" {
183 send_gdb "stepi\n"
184 exp_continue
185 }
186 -re "ARRIVED IN CALLEE.*$gdb_prompt $" {
187 pass "$test_message"
188 }
189 -re "ENTER CALLEE.*$gdb_prompt $" {
190 fail "$test_message (too far)"
191 }
192 -re "STEPI TEST.*$gdb_prompt $" {
193 fail "$test_message (too far)"
194 }
195 }
196
197 # stepi backward out of a function call
198
199 set stepi_location [gdb_get_line_number "STEPI TEST" "$srcfile"]
200 set test_message "reverse stepi from a function call"
201 gdb_test_multiple "stepi" "$test_message" {
202 -re "ARRIVED IN CALLEE.*$gdb_prompt $" {
203 fail "$test_message (start statement)"
204 }
205 -re "ENTER CALLEE.*$gdb_prompt $" {
206 send_gdb "stepi\n"
207 exp_continue
208 }
209 -re "${hex} in main .*:$stepi_location.*STEPI TEST.*$gdb_prompt $" {
210 send_gdb "stepi\n"
211 exp_continue
212 }
213 -re "STEPI TEST.*$gdb_prompt $" {
214 pass "$test_message"
215 }
216 -re "STEP INTO THIS CALL.*$gdb_prompt $" {
217 fail "$test_message (too far)"
218 }
219 }
220
221 # stepi backward over flat code (no calls)
222
223 set stepi_location [gdb_get_line_number "FINISH TEST" "$srcfile"]
224 set test_message "simple reverse stepi"
225 gdb_test_multiple "stepi" "$test_message" {
226 -re "STEPI TEST.*$gdb_prompt $" {
227 fail "$test_message (start statement)"
228 }
229 -re "$hex\[ \t\]*$stepi_location.* FINISH TEST.*$gdb_prompt $" {
230 send_gdb "stepi\n"
231 exp_continue
232 }
233 -re "$stepi_location.* FINISH TEST.*$gdb_prompt $" {
234 pass "$test_message"
235 }
236 -re "STEP INTO THIS CALL.*$gdb_prompt $" {
237 fail "$test_message (too far)"
238 }
239 }
240
241 # step backward into function (thru return)
242
243 gdb_test "step" "(RETURN FROM CALLEE|ARRIVED IN CALLEE).*" \
244 "reverse step into fn call"
245
246 # step backward out of called function (thru call)
247
248 set test_message "reverse step out of called fn"
249 gdb_test_multiple "step" "$test_message" {
250 -re "STEP INTO THIS CALL.*.*$gdb_prompt $" {
251 pass "$test_message"
252 }
253 -re "ARRIVED IN CALLEE.*$gdb_prompt $" {
254 send_gdb "step\n"
255 exp_continue
256 }
257 -re "ENTER CALLEE.*$gdb_prompt $" {
258 send_gdb "step\n"
259 exp_continue
260 }
261 }
262
263 # next backward over call
264
265 gdb_test "next" ".*NEXT OVER THIS CALL.*" "reverse next over call"
266
267 # step/next backward with count
268
269 gdb_test "step 3" ".*REVERSE STEP TEST 1.*" "reverse step test 1"
270 gdb_test "next 2" ".*REVERSE NEXT TEST 1.*" "reverse next test 1"
271
272 # step/next backward without count
273
274 gdb_test "step" ".*STEP TEST 1.*" "reverse step test 2"
275 gdb_test "next" ".*NEXT TEST 1.*" "reverse next test 2"
276
277
278
279 # Finish test by running forward to the end.
280 # FIXME return to this later...
281 # gdb_test_no_output "set exec-dir forward" "set forward execution"
282 # gdb_continue_to_end "step-reverse.exp"
283
This page took 0.03795 seconds and 5 git commands to generate.