]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.reverse/step-precsave.exp
Update years in copyright notice for the GDB files.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.reverse / step-precsave.exp
CommitLineData
8acc9f48 1# Copyright 2008-2013 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" \
44 "Breakpoint $decimal at .*/$srcfile, line $end_of_main\." \
45 "BP at end of main"
46
47gdb_test "continue" "Breakpoint .* end of main .*" "run to end of main"
48
55baab26
TT
49gdb_test "record save $precsave" \
50 "Saved core file $precsave with execution log\." \
02506ff1
MS
51 "save process recfile"
52
53gdb_test "kill" "" "Kill process, prepare to debug log file" \
54 "Kill the program being debugged\\? \\(y or n\\) " "y"
55
55baab26 56gdb_test "record restore $precsave" \
02506ff1
MS
57 "Program terminated with signal .*" \
58 "reload core file"
59
60# plain vanilla step/next (no count)
61
62gdb_test "next" ".*NEXT TEST 1.*" "next test 1"
63gdb_test "step" ".*STEP TEST 1.*" "step test 1"
64
65# step/next with count
66
67gdb_test "next 2" ".*NEXT TEST 2.*" "next test 2"
68gdb_test "step 3" ".*STEP TEST 2.*" "step test 2"
69
70# step over call
71
72gdb_test "step" ".*NEXT OVER THIS CALL.*" "step up to call"
73gdb_test "next" ".*STEP INTO THIS CALL.*" "next over call"
74
75# step into call
76
77gdb_test "step" ".*ARRIVED IN CALLEE.*" "step into call"
78
79# finish out of call
80
81set test_message "finish out of fn call"
82gdb_test_multiple "finish" "$test_message" {
83 -re "FINISH TEST.*$gdb_prompt $" {
84 pass "$test_message"
85 }
86 -re "STEP INTO THIS CALL.*$gdb_prompt $" {
87 send_gdb "step\n"
88 exp_continue
89 }
90}
91
92# stepi over flat code (no calls)
93
94set test_message "simple stepi"
95gdb_test_multiple "stepi" "$test_message" {
96 -re "STEPI TEST.*$gdb_prompt $" {
97 pass "$test_message"
98 }
99 -re "FINISH TEST.*$gdb_prompt $" {
100 send_gdb "stepi\n"
101 exp_continue
102 }
103 -re "NEXTI TEST.*$gdb_prompt $" {
104 fail "$test_message (too far)"
105 }
106}
107
108# stepi into a function call
109
110set test_message "stepi into function call"
111gdb_test_multiple "stepi" "$test_message" {
112 -re "ARRIVED IN CALLEE.*$gdb_prompt $" {
113 pass "$test_message"
114 }
115 -re "NEXTI TEST.*$gdb_prompt $" {
116 fail "$test_message (too far)"
117 }
118 -re "RETURN FROM CALLEE.*$gdb_prompt $" {
119 fail "$test_message (too far)"
120 }
121 -re "ENTER CALLEE.*$gdb_prompt $" {
122 send_gdb "stepi\n"
123 exp_continue
124 }
125 -re "STEPI TEST.*$gdb_prompt $" {
126 send_gdb "stepi\n"
127 exp_continue
128 }
129}
130
131# stepi thru return of a function call
132
133set test_message "stepi back from function call"
134gdb_test_multiple "stepi" "$test_message" {
135 -re "NEXTI TEST.*$gdb_prompt $" {
136 pass "$test_message"
137 }
138 -re "ARRIVED IN CALLEE.*$gdb_prompt $" {
139 send_gdb "stepi\n"
140 exp_continue
141 }
142 -re "RETURN FROM CALLEE.*$gdb_prompt $" {
143 send_gdb "stepi\n"
144 exp_continue
145 }
146 -re "STEPI TEST.*$gdb_prompt $" {
147 send_gdb "stepi\n"
148 exp_continue
149 }
150 -re "ENTER CALLEE.*$gdb_prompt $" {
151 fail "$test_message (too far)"
152 }
153}
154
155###
156###
157###
158
159# Set reverse execution direction
02506ff1 160
bcd2dc50 161gdb_test_no_output "set exec-dir reverse" "set reverse execution"
02506ff1
MS
162
163# stepi backward thru return and into a function
164
165set stepi_location [gdb_get_line_number "ARRIVED IN CALLEE" "$srcfile"]
166set test_message "reverse stepi thru function return"
167gdb_test_multiple "stepi" "$test_message" {
168 -re "NEXTI TEST.*$gdb_prompt $" {
169 fail "$test_message (start statement)"
170 }
171 -re "RETURN FROM CALLEE.*$gdb_prompt $" {
172 send_gdb "stepi\n"
173 exp_continue
174 }
175 -re "$hex\[ \t\]*$stepi_location.*ARRIVED IN CALLEE.*$gdb_prompt $" {
176 send_gdb "stepi\n"
177 exp_continue
178 }
179 -re "ARRIVED IN CALLEE.*$gdb_prompt $" {
180 pass "$test_message"
181 }
182 -re "ENTER CALLEE.*$gdb_prompt $" {
183 fail "$test_message (too far)"
184 }
185 -re "STEPI TEST.*$gdb_prompt $" {
186 fail "$test_message (too far)"
187 }
188}
189
190# stepi backward out of a function call
191
192set stepi_location [gdb_get_line_number "STEPI TEST" "$srcfile"]
193set test_message "reverse stepi from a function call"
194gdb_test_multiple "stepi" "$test_message" {
195 -re "ARRIVED IN CALLEE.*$gdb_prompt $" {
196 fail "$test_message (start statement)"
197 }
198 -re "ENTER CALLEE.*$gdb_prompt $" {
199 send_gdb "stepi\n"
200 exp_continue
201 }
202 -re "${hex} in main .*:$stepi_location.*STEPI TEST.*$gdb_prompt $" {
203 send_gdb "stepi\n"
204 exp_continue
205 }
206 -re "STEPI TEST.*$gdb_prompt $" {
207 pass "$test_message"
208 }
209 -re "STEP INTO THIS CALL.*$gdb_prompt $" {
210 fail "$test_message (too far)"
211 }
212}
213
214# stepi backward over flat code (no calls)
215
216set stepi_location [gdb_get_line_number "FINISH TEST" "$srcfile"]
217set test_message "simple reverse stepi"
218gdb_test_multiple "stepi" "$test_message" {
219 -re "STEPI TEST.*$gdb_prompt $" {
220 fail "$test_message (start statement)"
221 }
222 -re "$hex\[ \t\]*$stepi_location.* FINISH TEST.*$gdb_prompt $" {
223 send_gdb "stepi\n"
224 exp_continue
225 }
226 -re "$stepi_location.* FINISH TEST.*$gdb_prompt $" {
227 pass "$test_message"
228 }
229 -re "STEP INTO THIS CALL.*$gdb_prompt $" {
230 fail "$test_message (too far)"
231 }
232}
233
234# step backward into function (thru return)
235
236set test_message "reverse step into fn call"
237gdb_test_multiple "step" "$test_message" {
238 -re "RETURN FROM CALLEE.*$gdb_prompt $" {
239 send_gdb "step\n"
240 exp_continue
241 }
242 -re "ARRIVED IN CALLEE.*$gdb_prompt $" {
243 pass "$test_message"
244 }
245}
246
247# step backward out of called function (thru call)
248
249gdb_test "step" ".*STEP INTO THIS CALL.*" "reverse step out of called fn"
250
251# next backward over call
252
253gdb_test "next" ".*NEXT OVER THIS CALL.*" "reverse next over call"
254
255# step/next backward with count
256
257gdb_test "step 3" ".*REVERSE STEP TEST 1.*" "reverse step test 1"
258gdb_test "next 2" ".*REVERSE NEXT TEST 1.*" "reverse next test 1"
259
260# step/next backward without count
261
262gdb_test "step" ".*STEP TEST 1.*" "reverse step test 2"
263gdb_test "next" ".*NEXT TEST 1.*" "reverse next test 2"
264
265
266
267# Finish test by running forward to the end.
268# FIXME return to this later...
bcd2dc50 269# gdb_test_no_output "set exec-dir forward" "set forward execution"
02506ff1
MS
270# gdb_continue_to_end "step-reverse.exp"
271