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