]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.reverse/step-precsave.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.reverse / step-precsave.exp
CommitLineData
1d506c26 1# Copyright 2008-2024 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
ade3e4f5 24require supports_process_record
02506ff1 25
7686c074 26standard_testfile step-reverse.c
55baab26 27set precsave [standard_output_file step.precsave]
02506ff1 28
5b362f04 29if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } {
02506ff1
MS
30 return -1
31}
32
50441f0f 33runto_main
02506ff1 34
ade3e4f5
TT
35# Activate process record/replay
36gdb_test_no_output "record" "turn on process record"
02506ff1
MS
37
38set end_of_main [gdb_get_line_number "end of main" ]
39gdb_test "break $end_of_main" \
a80db015 40 "Breakpoint $decimal at .*$srcfile, line $end_of_main\." \
bb95117e 41 "breakpoint at end of main"
02506ff1 42
de1c2c52
PA
43# This can take awhile.
44with_timeout_factor 20 {
4ccdfbec
TV
45 gdb_test_multiple "continue" "run to end of main" {
46 -re -wrap "Breakpoint .* end of main .*" {
47 pass $gdb_test_name
68f7d34d 48 }
4ccdfbec
TV
49 -re -wrap "Process record does not support instruction 0xc5 at.*" {
50 kfail "record/23188" $gdb_test_name
68f7d34d 51 }
4ccdfbec
TV
52 -re -wrap "Process record does not support instruction 0xfae64 at.*" {
53 kfail "record/25038" $gdb_test_name
d6e76313 54 }
4fd1ba16
SM
55 -re -wrap "Process record does not support instruction 0x62 at.*" {
56 kfail "record/30807" $gdb_test_name
57 }
68f7d34d 58 }
de1c2c52
PA
59}
60
61# So can this, against gdbserver, for example.
02506ff1 62
de1c2c52
PA
63with_timeout_factor 10 {
64 gdb_test "record save $precsave" \
65 "Saved core file $precsave with execution log\." \
66 "save process recfile"
67}
02506ff1 68
cdc7edd7 69gdb_test "kill" "" "kill process, prepare to debug log file" \
02506ff1
MS
70 "Kill the program being debugged\\? \\(y or n\\) " "y"
71
55baab26 72gdb_test "record restore $precsave" \
470e2f4e 73 "Restored records from core file .*" \
02506ff1
MS
74 "reload core file"
75
76# plain vanilla step/next (no count)
77
78gdb_test "next" ".*NEXT TEST 1.*" "next test 1"
79gdb_test "step" ".*STEP TEST 1.*" "step test 1"
80
81# step/next with count
82
83gdb_test "next 2" ".*NEXT TEST 2.*" "next test 2"
84gdb_test "step 3" ".*STEP TEST 2.*" "step test 2"
85
86# step over call
87
1f3e37e0
BL
88gdb_test "step" ".*NEXT OVER THIS RECURSION.*" "step up to call"
89gdb_test "next" ".*NEXT OVER THIS CALL.*" "skip recursive call"
02506ff1
MS
90gdb_test "next" ".*STEP INTO THIS CALL.*" "next over call"
91
92# step into call
93
94gdb_test "step" ".*ARRIVED IN CALLEE.*" "step into call"
95
96# finish out of call
97
98set test_message "finish out of fn call"
99gdb_test_multiple "finish" "$test_message" {
100 -re "FINISH TEST.*$gdb_prompt $" {
101 pass "$test_message"
102 }
103 -re "STEP INTO THIS CALL.*$gdb_prompt $" {
104 send_gdb "step\n"
105 exp_continue
106 }
107}
108
109# stepi over flat code (no calls)
110
111set test_message "simple stepi"
112gdb_test_multiple "stepi" "$test_message" {
113 -re "STEPI TEST.*$gdb_prompt $" {
114 pass "$test_message"
115 }
116 -re "FINISH TEST.*$gdb_prompt $" {
117 send_gdb "stepi\n"
118 exp_continue
119 }
120 -re "NEXTI TEST.*$gdb_prompt $" {
121 fail "$test_message (too far)"
122 }
123}
124
125# stepi into a function call
126
c47860a4
TV
127set alphanum_re "\[a-zA-Z0-9\]"
128set pic_thunk_re "__$alphanum_re*\\.get_pc_thunk\\.$alphanum_re* \\(\\)"
02506ff1
MS
129set test_message "stepi into function call"
130gdb_test_multiple "stepi" "$test_message" {
131 -re "ARRIVED IN CALLEE.*$gdb_prompt $" {
132 pass "$test_message"
133 }
134 -re "NEXTI TEST.*$gdb_prompt $" {
135 fail "$test_message (too far)"
136 }
137 -re "RETURN FROM CALLEE.*$gdb_prompt $" {
138 fail "$test_message (too far)"
139 }
140 -re "ENTER CALLEE.*$gdb_prompt $" {
141 send_gdb "stepi\n"
142 exp_continue
143 }
144 -re "STEPI TEST.*$gdb_prompt $" {
145 send_gdb "stepi\n"
146 exp_continue
147 }
c47860a4
TV
148 -re "$pic_thunk_re.*$gdb_prompt $" {
149 send_gdb "stepi\n"
150 exp_continue
151 }
02506ff1
MS
152}
153
154# stepi thru return of a function call
155
156set test_message "stepi back from function call"
157gdb_test_multiple "stepi" "$test_message" {
158 -re "NEXTI TEST.*$gdb_prompt $" {
159 pass "$test_message"
160 }
161 -re "ARRIVED IN CALLEE.*$gdb_prompt $" {
162 send_gdb "stepi\n"
163 exp_continue
164 }
165 -re "RETURN FROM CALLEE.*$gdb_prompt $" {
166 send_gdb "stepi\n"
167 exp_continue
168 }
169 -re "STEPI TEST.*$gdb_prompt $" {
170 send_gdb "stepi\n"
171 exp_continue
172 }
173 -re "ENTER CALLEE.*$gdb_prompt $" {
174 fail "$test_message (too far)"
175 }
176}
177
178###
179###
180###
181
182# Set reverse execution direction
02506ff1 183
bcd2dc50 184gdb_test_no_output "set exec-dir reverse" "set reverse execution"
02506ff1
MS
185
186# stepi backward thru return and into a function
187
188set stepi_location [gdb_get_line_number "ARRIVED IN CALLEE" "$srcfile"]
189set test_message "reverse stepi thru function return"
190gdb_test_multiple "stepi" "$test_message" {
191 -re "NEXTI TEST.*$gdb_prompt $" {
192 fail "$test_message (start statement)"
193 }
194 -re "RETURN FROM CALLEE.*$gdb_prompt $" {
195 send_gdb "stepi\n"
196 exp_continue
197 }
198 -re "$hex\[ \t\]*$stepi_location.*ARRIVED IN CALLEE.*$gdb_prompt $" {
199 send_gdb "stepi\n"
200 exp_continue
201 }
202 -re "ARRIVED IN CALLEE.*$gdb_prompt $" {
203 pass "$test_message"
204 }
205 -re "ENTER CALLEE.*$gdb_prompt $" {
206 fail "$test_message (too far)"
207 }
208 -re "STEPI TEST.*$gdb_prompt $" {
209 fail "$test_message (too far)"
210 }
211}
212
213# stepi backward out of a function call
214
6e7db5d6
GL
215set start_pc [get_hexadecimal_valueof "\$pc" 0 "getting PC at start of stepi backwards"]
216set step_count 0
02506ff1
MS
217set stepi_location [gdb_get_line_number "STEPI TEST" "$srcfile"]
218set test_message "reverse stepi from a function call"
219gdb_test_multiple "stepi" "$test_message" {
220 -re "ARRIVED IN CALLEE.*$gdb_prompt $" {
6e7db5d6
GL
221 incr step_count
222 if { [get_hexadecimal_valueof "\$pc" 0 "getting PC after $step_count steps"] == $start_pc } {
223 fail "$test_message (start statement)"
224 } else {
225 send_gdb "stepi\n"
226 exp_continue
227 }
02506ff1
MS
228 }
229 -re "ENTER CALLEE.*$gdb_prompt $" {
230 send_gdb "stepi\n"
231 exp_continue
232 }
c47860a4
TV
233 -re "$pic_thunk_re.*$gdb_prompt $" {
234 send_gdb "stepi\n"
235 exp_continue
236 }
02506ff1
MS
237 -re "${hex} in main .*:$stepi_location.*STEPI TEST.*$gdb_prompt $" {
238 send_gdb "stepi\n"
239 exp_continue
240 }
241 -re "STEPI TEST.*$gdb_prompt $" {
242 pass "$test_message"
243 }
244 -re "STEP INTO THIS CALL.*$gdb_prompt $" {
245 fail "$test_message (too far)"
246 }
247}
248
249# stepi backward over flat code (no calls)
250
251set stepi_location [gdb_get_line_number "FINISH TEST" "$srcfile"]
252set test_message "simple reverse stepi"
253gdb_test_multiple "stepi" "$test_message" {
254 -re "STEPI TEST.*$gdb_prompt $" {
255 fail "$test_message (start statement)"
256 }
257 -re "$hex\[ \t\]*$stepi_location.* FINISH TEST.*$gdb_prompt $" {
258 send_gdb "stepi\n"
259 exp_continue
260 }
261 -re "$stepi_location.* FINISH TEST.*$gdb_prompt $" {
262 pass "$test_message"
263 }
264 -re "STEP INTO THIS CALL.*$gdb_prompt $" {
265 fail "$test_message (too far)"
266 }
267}
268
269# step backward into function (thru return)
270
4a7e075c
YQ
271gdb_test "step" "(RETURN FROM CALLEE|ARRIVED IN CALLEE).*" \
272 "reverse step into fn call"
273
274# step backward out of called function (thru call)
275
276set test_message "reverse step out of called fn"
02506ff1 277gdb_test_multiple "step" "$test_message" {
4a7e075c
YQ
278 -re "STEP INTO THIS CALL.*.*$gdb_prompt $" {
279 pass "$test_message"
280 }
281 -re "ARRIVED IN CALLEE.*$gdb_prompt $" {
02506ff1
MS
282 send_gdb "step\n"
283 exp_continue
284 }
4a7e075c
YQ
285 -re "ENTER CALLEE.*$gdb_prompt $" {
286 send_gdb "step\n"
287 exp_continue
02506ff1
MS
288 }
289}
290
1f3e37e0 291# Next backward over calls.
02506ff1
MS
292
293gdb_test "next" ".*NEXT OVER THIS CALL.*" "reverse next over call"
1f3e37e0 294gdb_test "next" ".*NEXT OVER THIS RECURSION.*" "reverse next over recursive call"
02506ff1
MS
295
296# step/next backward with count
297
298gdb_test "step 3" ".*REVERSE STEP TEST 1.*" "reverse step test 1"
299gdb_test "next 2" ".*REVERSE NEXT TEST 1.*" "reverse next test 1"
300
301# step/next backward without count
302
303gdb_test "step" ".*STEP TEST 1.*" "reverse step test 2"
304gdb_test "next" ".*NEXT TEST 1.*" "reverse next test 2"
305
306
307
308# Finish test by running forward to the end.
309# FIXME return to this later...
bcd2dc50 310# gdb_test_no_output "set exec-dir forward" "set forward execution"
02506ff1
MS
311# gdb_continue_to_end "step-reverse.exp"
312