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