]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.reverse/step-reverse.exp
Update years in copyright notice for the GDB files.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.reverse / step-reverse.exp
CommitLineData
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. It tests reverse stepping.
17# Lots of code borrowed from "step-test.exp".
18
19#
20# Test step and next in reverse
21#
22
d3895d7d 23if ![supports_reverse] {
28d41a99
MS
24 return
25}
26
7686c074 27standard_testfile
28d41a99
MS
28
29if { [prepare_for_testing $testfile.exp $testfile $srcfile] } {
30 return -1
31}
32
33runto main
34
d3895d7d 35if [supports_process_record] {
28d41a99 36 # Activate process record/replay
bcd2dc50 37 gdb_test_no_output "record" "Turn on process record"
28d41a99
MS
38}
39
40# plain vanilla step/next (no count)
41
42gdb_test "next" ".*NEXT TEST 1.*" "next test 1"
43gdb_test "step" ".*STEP TEST 1.*" "step test 1"
44
45# step/next with count
46
47gdb_test "next 2" ".*NEXT TEST 2.*" "next test 2"
48gdb_test "step 3" ".*STEP TEST 2.*" "step test 2"
49
50# step over call
51
52gdb_test "step" ".*NEXT OVER THIS CALL.*" "step up to call"
53gdb_test "next" ".*STEP INTO THIS CALL.*" "next over call"
54
55# step into call
56
57gdb_test "step" ".*ARRIVED IN CALLEE.*" "step into call"
58
59# finish out of call
60
61set test_message "finish out of fn call"
62gdb_test_multiple "finish" "$test_message" {
63 -re "FINISH TEST.*$gdb_prompt $" {
64 pass "$test_message"
65 }
66 -re "STEP INTO THIS CALL.*$gdb_prompt $" {
67 send_gdb "step\n"
68 exp_continue
69 }
70}
71
72# stepi over flat code (no calls)
73
74set test_message "simple stepi"
75gdb_test_multiple "stepi" "$test_message" {
76 -re "STEPI TEST.*$gdb_prompt $" {
77 pass "$test_message"
78 }
79 -re "FINISH TEST.*$gdb_prompt $" {
80 send_gdb "stepi\n"
81 exp_continue
82 }
83 -re "NEXTI TEST.*$gdb_prompt $" {
84 fail "$test_message (too far)"
85 }
86}
87
88# stepi into a function call
89
90set test_message "stepi into function call"
91gdb_test_multiple "stepi" "$test_message" {
92 -re "ARRIVED IN CALLEE.*$gdb_prompt $" {
93 pass "$test_message"
94 }
95 -re "NEXTI TEST.*$gdb_prompt $" {
96 fail "$test_message (too far)"
97 }
98 -re "RETURN FROM CALLEE.*$gdb_prompt $" {
99 fail "$test_message (too far)"
100 }
101 -re "ENTER CALLEE.*$gdb_prompt $" {
102 send_gdb "stepi\n"
103 exp_continue
104 }
f662c3bc
MS
105 -re "STEPI TEST.*$gdb_prompt $" {
106 send_gdb "stepi\n"
107 exp_continue
108 }
28d41a99
MS
109}
110
111# stepi thru return of a function call
112
113set test_message "stepi back from function call"
114gdb_test_multiple "stepi" "$test_message" {
115 -re "NEXTI TEST.*$gdb_prompt $" {
116 pass "$test_message"
117 }
118 -re "ARRIVED IN CALLEE.*$gdb_prompt $" {
119 send_gdb "stepi\n"
120 exp_continue
121 }
122 -re "RETURN FROM 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 -re "ENTER CALLEE.*$gdb_prompt $" {
131 fail "$test_message (too far)"
132 }
133}
134
135###
136###
137###
138
139# Set reverse execution direction
28d41a99 140
bcd2dc50 141gdb_test_no_output "set exec-dir reverse" "set reverse execution"
28d41a99
MS
142
143# stepi backward thru return and into a function
144
145set stepi_location [gdb_get_line_number "ARRIVED IN CALLEE" "$srcfile"]
146set test_message "reverse stepi thru function return"
147gdb_test_multiple "stepi" "$test_message" {
148 -re "NEXTI TEST.*$gdb_prompt $" {
149 fail "$test_message (start statement)"
150 }
151 -re "RETURN FROM CALLEE.*$gdb_prompt $" {
152 send_gdb "stepi\n"
153 exp_continue
154 }
155 -re "$hex\[ \t\]*$stepi_location.*ARRIVED IN CALLEE.*$gdb_prompt $" {
156 send_gdb "stepi\n"
157 exp_continue
158 }
159 -re "ARRIVED IN CALLEE.*$gdb_prompt $" {
160 pass "$test_message"
161 }
162 -re "ENTER CALLEE.*$gdb_prompt $" {
163 fail "$test_message (too far)"
164 }
165 -re "STEPI TEST.*$gdb_prompt $" {
166 fail "$test_message (too far)"
167 }
168}
169
170# stepi backward out of a function call
171
f662c3bc 172set stepi_location [gdb_get_line_number "STEPI TEST" "$srcfile"]
28d41a99
MS
173set test_message "reverse stepi from a function call"
174gdb_test_multiple "stepi" "$test_message" {
175 -re "ARRIVED IN CALLEE.*$gdb_prompt $" {
176 fail "$test_message (start statement)"
177 }
178 -re "ENTER CALLEE.*$gdb_prompt $" {
179 send_gdb "stepi\n"
180 exp_continue
181 }
f662c3bc 182 -re "${hex} in main .*:$stepi_location.*STEPI TEST.*$gdb_prompt $" {
28d41a99
MS
183 send_gdb "stepi\n"
184 exp_continue
185 }
186 -re "STEPI TEST.*$gdb_prompt $" {
187 pass "$test_message"
188 }
189 -re "STEP INTO THIS CALL.*$gdb_prompt $" {
190 fail "$test_message (too far)"
191 }
192}
193
194# stepi backward over flat code (no calls)
195
196set stepi_location [gdb_get_line_number "FINISH TEST" "$srcfile"]
197set test_message "simple reverse stepi"
198gdb_test_multiple "stepi" "$test_message" {
199 -re "STEPI TEST.*$gdb_prompt $" {
200 fail "$test_message (start statement)"
201 }
202 -re "$hex\[ \t\]*$stepi_location.* FINISH TEST.*$gdb_prompt $" {
203 send_gdb "stepi\n"
204 exp_continue
205 }
206 -re "$stepi_location.* FINISH 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# step backward into function (thru return)
215
216set test_message "reverse step into fn call"
217gdb_test_multiple "step" "$test_message" {
218 -re "RETURN FROM CALLEE.*$gdb_prompt $" {
219 send_gdb "step\n"
220 exp_continue
221 }
222 -re "ARRIVED IN CALLEE.*$gdb_prompt $" {
223 pass "$test_message"
224 }
225}
226
227# step backward out of called function (thru call)
228
229gdb_test "step" ".*STEP INTO THIS CALL.*" "reverse step out of called fn"
230
231# next backward over call
232
233gdb_test "next" ".*NEXT OVER THIS CALL.*" "reverse next over call"
234
235# step/next backward with count
236
237gdb_test "step 3" ".*REVERSE STEP TEST 1.*" "reverse step test 1"
238gdb_test "next 2" ".*REVERSE NEXT TEST 1.*" "reverse next test 1"
239
240# step/next backward without count
241
242gdb_test "step" ".*STEP TEST 1.*" "reverse step test 2"
243gdb_test "next" ".*NEXT TEST 1.*" "reverse next test 2"
244
245
246
247# Finish test by running forward to the end.
248# FIXME return to this later...
bcd2dc50 249# gdb_test_no_output "set exec-dir forward" "set forward execution"
28d41a99
MS
250# gdb_continue_to_end "step-reverse.exp"
251