]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.reverse/step-precsave.exp
GDB copyright headers update after running GDB's copyright.py script.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.reverse / step-precsave.exp
CommitLineData
618f726f 1# Copyright 2008-2016 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. 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
d3895d7d 24if ![supports_process_record] {
02506ff1
MS
25 return
26}
27
7686c074 28standard_testfile step-reverse.c
55baab26 29set precsave [standard_output_file step.precsave]
02506ff1
MS
30
31if { [prepare_for_testing $testfile.exp $testfile $srcfile] } {
32 return -1
33}
34
35runto main
36
d3895d7d 37if [supports_process_record] {
02506ff1 38 # Activate process record/replay
bcd2dc50 39 gdb_test_no_output "record" "Turn on process record"
02506ff1
MS
40}
41
42set end_of_main [gdb_get_line_number "end of main" ]
43gdb_test "break $end_of_main" \
a80db015 44 "Breakpoint $decimal at .*$srcfile, line $end_of_main\." \
02506ff1
MS
45 "BP at end of main"
46
de1c2c52
PA
47# This can take awhile.
48with_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.
02506ff1 53
de1c2c52
PA
54with_timeout_factor 10 {
55 gdb_test "record save $precsave" \
56 "Saved core file $precsave with execution log\." \
57 "save process recfile"
58}
02506ff1
MS
59
60gdb_test "kill" "" "Kill process, prepare to debug log file" \
61 "Kill the program being debugged\\? \\(y or n\\) " "y"
62
55baab26 63gdb_test "record restore $precsave" \
470e2f4e 64 "Restored records from core file .*" \
02506ff1
MS
65 "reload core file"
66
67# plain vanilla step/next (no count)
68
69gdb_test "next" ".*NEXT TEST 1.*" "next test 1"
70gdb_test "step" ".*STEP TEST 1.*" "step test 1"
71
72# step/next with count
73
74gdb_test "next 2" ".*NEXT TEST 2.*" "next test 2"
75gdb_test "step 3" ".*STEP TEST 2.*" "step test 2"
76
77# step over call
78
79gdb_test "step" ".*NEXT OVER THIS CALL.*" "step up to call"
80gdb_test "next" ".*STEP INTO THIS CALL.*" "next over call"
81
82# step into call
83
84gdb_test "step" ".*ARRIVED IN CALLEE.*" "step into call"
85
86# finish out of call
87
88set test_message "finish out of fn call"
89gdb_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
101set test_message "simple stepi"
102gdb_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
117set test_message "stepi into function call"
118gdb_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
140set test_message "stepi back from function call"
141gdb_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
02506ff1 167
bcd2dc50 168gdb_test_no_output "set exec-dir reverse" "set reverse execution"
02506ff1
MS
169
170# stepi backward thru return and into a function
171
172set stepi_location [gdb_get_line_number "ARRIVED IN CALLEE" "$srcfile"]
173set test_message "reverse stepi thru function return"
174gdb_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
199set stepi_location [gdb_get_line_number "STEPI TEST" "$srcfile"]
200set test_message "reverse stepi from a function call"
201gdb_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
223set stepi_location [gdb_get_line_number "FINISH TEST" "$srcfile"]
224set test_message "simple reverse stepi"
225gdb_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
243set test_message "reverse step into fn call"
244gdb_test_multiple "step" "$test_message" {
245 -re "RETURN FROM CALLEE.*$gdb_prompt $" {
246 send_gdb "step\n"
247 exp_continue
248 }
249 -re "ARRIVED IN CALLEE.*$gdb_prompt $" {
250 pass "$test_message"
251 }
252}
253
254# step backward out of called function (thru call)
255
256gdb_test "step" ".*STEP INTO THIS CALL.*" "reverse step out of called fn"
257
258# next backward over call
259
260gdb_test "next" ".*NEXT OVER THIS CALL.*" "reverse next over call"
261
262# step/next backward with count
263
264gdb_test "step 3" ".*REVERSE STEP TEST 1.*" "reverse step test 1"
265gdb_test "next 2" ".*REVERSE NEXT TEST 1.*" "reverse next test 1"
266
267# step/next backward without count
268
269gdb_test "step" ".*STEP TEST 1.*" "reverse step test 2"
270gdb_test "next" ".*NEXT TEST 1.*" "reverse next test 2"
271
272
273
274# Finish test by running forward to the end.
275# FIXME return to this later...
bcd2dc50 276# gdb_test_no_output "set exec-dir forward" "set forward execution"
02506ff1
MS
277# gdb_continue_to_end "step-reverse.exp"
278