8fd21f03e2baf8fa3eb5c32dd52050b5af294d8b
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.reverse / finish-precsave.exp
1 # Copyright 2008-2021 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 'finish' with
17 # reverse debugging.
18
19 if ![supports_reverse] {
20 return
21 }
22
23 standard_testfile finish-reverse.c
24 set precsave [standard_output_file finish.precsave]
25
26 if { [prepare_for_testing "failed to prepare" "$testfile" $srcfile] } {
27 return -1
28 }
29
30 runto_main
31
32 if [supports_process_record] {
33 # Activate process record/replay
34 gdb_test_no_output "record" "turn on process record"
35 }
36
37 # Run until end, then save execution log.
38
39 set breakloc [gdb_get_line_number "end of main" "$srcfile"]
40 gdb_test "break $breakloc" \
41 "Breakpoint $decimal at .*$srcfile, line $breakloc\." \
42 "breakpoint at end of main"
43
44 gdb_test "continue" "Breakpoint .* end of main .*" "run to end of main"
45
46 gdb_test "record save $precsave" \
47 "Saved core file $precsave with execution log\." \
48 "save process recfile"
49
50 gdb_test "kill" "" "kill process, prepare to debug log file" \
51 "Kill the program being debugged\\? \\(y or n\\) " "y"
52
53 gdb_test "record restore $precsave" \
54 "Restored records from core file .*" \
55 "reload precord save file"
56
57 # Test finish from void func
58
59 set breakloc [gdb_get_line_number "VOID FUNC" "$srcfile"]
60 gdb_test "break void_func" \
61 "Breakpoint $decimal at .*$srcfile, line $breakloc\." \
62 "set breakpoint on void_func"
63 gdb_continue_to_breakpoint "void_func" ".*$srcfile:$breakloc.*"
64
65 set test_msg "finish from void_func"
66 gdb_test_multiple "finish" "$test_msg" {
67 -re " call to void_func .*$gdb_prompt $" {
68 send_gdb "step\n"
69 exp_continue
70 }
71 -re " void_checkpoint .*$gdb_prompt $" {
72 pass "$test_msg"
73 }
74 }
75
76 # Test finish from char func
77
78 set breakloc [gdb_get_line_number "CHAR FUNC" "$srcfile"]
79 gdb_test "break char_func" \
80 "Breakpoint $decimal at .*$srcfile, line $breakloc\." \
81 "set breakpoint on char_func"
82 gdb_continue_to_breakpoint "char_func" ".*$srcfile:$breakloc.*"
83
84 set test_msg "finish from char_func"
85 gdb_test_multiple "finish" "$test_msg" {
86 -re " void_checkpoint .*$gdb_prompt $" {
87 send_gdb "step\n"
88 exp_continue
89 }
90 -re " char_checkpoint .*$gdb_prompt $" {
91 pass "$test_msg"
92 }
93 }
94
95 # Test finish from short func
96
97 set breakloc [gdb_get_line_number "SHORT FUNC" "$srcfile"]
98 gdb_test "break short_func" \
99 "Breakpoint $decimal at .* line $breakloc\." \
100 "set breakpoint on short_func"
101 gdb_continue_to_breakpoint "short_func" ".*$srcfile:$breakloc.*"
102
103 set test_msg "finish from short_func"
104 gdb_test_multiple "finish" "$test_msg" {
105 -re " char_checkpoint .*$gdb_prompt $" {
106 send_gdb "step\n"
107 exp_continue
108 }
109 -re " short_checkpoint .*$gdb_prompt $" {
110 pass "$test_msg"
111 }
112 }
113
114 # Test finish from int func
115
116 set breakloc [gdb_get_line_number "INT FUNC" "$srcfile"]
117 gdb_test "break int_func" \
118 "Breakpoint $decimal at .* line $breakloc\." \
119 "set breakpoint on int_func"
120 gdb_continue_to_breakpoint "int_func" ".*$srcfile:$breakloc.*"
121
122 set test_msg "finish from int_func"
123 gdb_test_multiple "finish" "$test_msg" {
124 -re " short_checkpoint .*$gdb_prompt $" {
125 send_gdb "step\n"
126 exp_continue
127 }
128 -re " int_checkpoint .*$gdb_prompt $" {
129 pass "$test_msg"
130 }
131 }
132
133 # Test finish from long func
134
135 set breakloc [gdb_get_line_number "LONG FUNC" "$srcfile"]
136 gdb_test "break long_func" \
137 "Breakpoint $decimal at .* line $breakloc\." \
138 "set breakpoint on long_func"
139 gdb_continue_to_breakpoint "long_func" ".*$srcfile:$breakloc.*"
140
141 set test_msg "finish from long_func"
142 gdb_test_multiple "finish" "$test_msg" {
143 -re " int_checkpoint .*$gdb_prompt $" {
144 send_gdb "step\n"
145 exp_continue
146 }
147 -re " long_checkpoint .*$gdb_prompt $" {
148 pass "$test_msg"
149 }
150 }
151
152 # Test finish from long long func
153
154 set breakloc [gdb_get_line_number "LONG LONG FUNC" "$srcfile"]
155 gdb_test "break long_long_func" \
156 "Breakpoint $decimal at .* line $breakloc\." \
157 "set breakpoint on long_long_func"
158 gdb_continue_to_breakpoint "long_long_func" ".*$srcfile:$breakloc.*"
159
160 set test_msg "finish from long_long_func"
161 gdb_test_multiple "finish" "$test_msg" {
162 -re " long_checkpoint .*$gdb_prompt $" {
163 send_gdb "step\n"
164 exp_continue
165 }
166 -re " long_long_checkpoint .*$gdb_prompt $" {
167 pass "$test_msg"
168 }
169 }
170
171
172 ###
173 ###
174 ###
175
176 # Now switch to reverse
177 gdb_test_no_output "set exec-dir reverse" "set reverse execution"
178
179 # Test reverse finish from long long func
180
181 set breakloc [gdb_get_line_number "LONG LONG FUNC" "$srcfile"]
182 gdb_continue_to_breakpoint "long_long_func backward" \
183 ".*$srcfile:$breakloc.*"
184
185 set test_msg "reverse finish from long_long_func"
186 gdb_test_multiple "finish" "$test_msg" {
187 -re ".* long_checkpoint.*$gdb_prompt $" {
188 pass "$test_msg"
189 }
190 }
191
192 # Test reverse finish from long func
193
194 set breakloc [gdb_get_line_number "LONG FUNC" "$srcfile"]
195 gdb_continue_to_breakpoint "long_func backward" \
196 ".*$srcfile:$breakloc.*"
197
198 set test_msg "reverse finish from long_func"
199 gdb_test_multiple "finish" "$test_msg" {
200 -re ".* int_checkpoint.*$gdb_prompt $" {
201 pass "$test_msg"
202 }
203 }
204
205 # Test reverse finish from int func
206
207 set breakloc [gdb_get_line_number "INT FUNC" "$srcfile"]
208 gdb_continue_to_breakpoint "int_func backward" \
209 ".*$srcfile:$breakloc.*"
210
211 set test_msg "reverse finish from int_func"
212 gdb_test_multiple "finish" "$test_msg" {
213 -re ".* short_checkpoint.*$gdb_prompt $" {
214 pass "$test_msg"
215 }
216 }
217
218 # Test reverse finish from short func
219
220 set breakloc [gdb_get_line_number "SHORT FUNC" "$srcfile"]
221 gdb_continue_to_breakpoint "short_func backward" \
222 ".*$srcfile:$breakloc.*"
223
224 set test_msg "reverse finish from short_func"
225 gdb_test_multiple "finish" "$test_msg" {
226 -re ".* char_checkpoint.*$gdb_prompt $" {
227 pass "$test_msg"
228 }
229 }
230
231 # Test reverse finish from char func
232
233 set breakloc [gdb_get_line_number "CHAR FUNC" "$srcfile"]
234 gdb_continue_to_breakpoint "char_func backward" \
235 ".*$srcfile:$breakloc.*"
236
237 set test_msg "reverse finish from char_func"
238 gdb_test_multiple "finish" "$test_msg" {
239 -re ".* void_checkpoint.*$gdb_prompt $" {
240 pass "$test_msg"
241 }
242 }
243
244 # Test reverse finish from void func
245
246 set breakloc [gdb_get_line_number "VOID FUNC" "$srcfile"]
247 gdb_continue_to_breakpoint "void_func backward" \
248 ".*$srcfile:$breakloc.*"
249
250 set test_msg "reverse finish from void_func"
251 gdb_test_multiple "finish" "$test_msg" {
252 -re ".* call to void_func.*$gdb_prompt $" {
253 pass "$test_msg"
254 }
255 }
This page took 0.034006 seconds and 3 git commands to generate.