Automatic date update in version.in
[binutils-gdb.git] / gdb / testsuite / gdb.reverse / finish-precsave.exp
blobfe77e36e5e0bfd9b19ba683d3554e93ff54abdf5
1 # Copyright 2008-2024 Free Software Foundation, Inc.
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.
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.
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/>.
16 # This file is part of the GDB testsuite.  It tests 'finish' with
17 # reverse debugging.
19 require supports_reverse
21 standard_testfile finish-reverse.c
22 set precsave [standard_output_file finish.precsave]
24 if { [prepare_for_testing "failed to prepare" "$testfile" $srcfile] } {
25     return -1
28 runto_main
30 if [supports_process_record] {
31     # Activate process record/replay
32     gdb_test_no_output "record" "turn on process record"
35 # Run until end, then save execution log. 
37 set breakloc [gdb_get_line_number "end of main" "$srcfile"]
38 gdb_test "break $breakloc" \
39     "Breakpoint $decimal at .*$srcfile, line $breakloc\." \
40     "breakpoint at end of main"
42 gdb_test "continue" "Breakpoint .* end of main .*" "run to end of main"
44 gdb_test "record save $precsave" \
45     "Saved core file $precsave with execution log\."  \
46     "save process recfile"
48 gdb_test "kill" "" "kill process, prepare to debug log file" \
49     "Kill the program being debugged\\? \\(y or n\\) " "y"
51 gdb_test "record restore $precsave" \
52     "Restored records from core file .*" \
53     "reload precord save file"
55 # Test finish from void func
57 set breakloc [gdb_get_line_number "VOID FUNC" "$srcfile"]
58 gdb_test "break void_func" \
59     "Breakpoint $decimal at .*$srcfile, line $breakloc\." \
60     "set breakpoint on void_func"
61 gdb_continue_to_breakpoint "void_func" ".*$srcfile:$breakloc.*"
63 set test_msg "finish from void_func"
64 gdb_test_multiple "finish" "$test_msg" {
65     -re " call to void_func .*$gdb_prompt $" {
66         send_gdb "step\n"
67         exp_continue
68     }
69     -re " void_checkpoint .*$gdb_prompt $" {
70         pass "$test_msg"
71     }
74 # Test finish from char func
76 set breakloc [gdb_get_line_number "CHAR FUNC" "$srcfile"]
77 gdb_test "break char_func" \
78     "Breakpoint $decimal at .*$srcfile, line $breakloc\." \
79     "set breakpoint on char_func"
80 gdb_continue_to_breakpoint "char_func" ".*$srcfile:$breakloc.*"
82 set test_msg "finish from char_func"
83 gdb_test_multiple "finish" "$test_msg" {
84     -re " void_checkpoint .*$gdb_prompt $" {
85         send_gdb "step\n"
86         exp_continue
87     }
88     -re " char_checkpoint .*$gdb_prompt $" {
89         pass "$test_msg"
90     }
93 # Test finish from short func
95 set breakloc [gdb_get_line_number "SHORT FUNC" "$srcfile"]
96 gdb_test "break short_func" \
97     "Breakpoint $decimal at .* line $breakloc\." \
98     "set breakpoint on short_func"
99 gdb_continue_to_breakpoint "short_func" ".*$srcfile:$breakloc.*"
101 set test_msg "finish from short_func"
102 gdb_test_multiple "finish" "$test_msg" {
103     -re " char_checkpoint .*$gdb_prompt $" {
104         send_gdb "step\n"
105         exp_continue
106     }
107     -re " short_checkpoint .*$gdb_prompt $" {
108         pass "$test_msg"
109     }
112 # Test finish from int func
114 set breakloc [gdb_get_line_number "INT FUNC" "$srcfile"]
115 gdb_test "break int_func" \
116     "Breakpoint $decimal at .* line $breakloc\." \
117     "set breakpoint on int_func"
118 gdb_continue_to_breakpoint "int_func" ".*$srcfile:$breakloc.*"
120 set test_msg "finish from int_func"
121 gdb_test_multiple "finish" "$test_msg" {
122     -re " short_checkpoint .*$gdb_prompt $" {
123         send_gdb "step\n"
124         exp_continue
125     }
126     -re " int_checkpoint .*$gdb_prompt $" {
127         pass "$test_msg"
128     }
131 # Test finish from long func
133 set breakloc [gdb_get_line_number "LONG FUNC" "$srcfile"]
134 gdb_test "break long_func" \
135     "Breakpoint $decimal at .* line $breakloc\." \
136     "set breakpoint on long_func"
137 gdb_continue_to_breakpoint "long_func" ".*$srcfile:$breakloc.*"
139 set test_msg "finish from long_func"
140 gdb_test_multiple "finish" "$test_msg" {
141     -re " int_checkpoint .*$gdb_prompt $" {
142         send_gdb "step\n"
143         exp_continue
144     }
145     -re " long_checkpoint .*$gdb_prompt $" {
146         pass "$test_msg"
147     }
150 # Test finish from long long func
152 set breakloc [gdb_get_line_number "LONG LONG FUNC" "$srcfile"]
153 gdb_test "break long_long_func" \
154     "Breakpoint $decimal at .* line $breakloc\." \
155     "set breakpoint on long_long_func"
156 gdb_continue_to_breakpoint "long_long_func" ".*$srcfile:$breakloc.*"
158 set test_msg "finish from long_long_func"
159 gdb_test_multiple "finish" "$test_msg" {
160     -re " long_checkpoint .*$gdb_prompt $" {
161         send_gdb "step\n"
162         exp_continue
163     }
164     -re " long_long_checkpoint .*$gdb_prompt $" {
165         pass "$test_msg"
166     }
174 # Now switch to reverse
175 gdb_test_no_output "set exec-dir reverse" "set reverse execution"
177 # Test reverse finish from long long func
179 set breakloc [gdb_get_line_number "LONG LONG FUNC" "$srcfile"]
180 gdb_continue_to_breakpoint "long_long_func backward" \
181     ".*$srcfile:$breakloc.*"
183 set test_msg "reverse finish from long_long_func"
184 gdb_test_multiple "finish" "$test_msg" {
185     -re ".* long_checkpoint.*$gdb_prompt $" {
186         pass "$test_msg"
187     }
190 # Test reverse finish from long func
192 set breakloc [gdb_get_line_number "LONG FUNC" "$srcfile"]
193 gdb_continue_to_breakpoint "long_func backward" \
194     ".*$srcfile:$breakloc.*"
196 set test_msg "reverse finish from long_func"
197 gdb_test_multiple "finish" "$test_msg" {
198     -re ".* int_checkpoint.*$gdb_prompt $" {
199         pass "$test_msg"
200     }
203 # Test reverse finish from int func
205 set breakloc [gdb_get_line_number "INT FUNC" "$srcfile"]
206 gdb_continue_to_breakpoint "int_func backward" \
207     ".*$srcfile:$breakloc.*"
209 set test_msg "reverse finish from int_func"
210 gdb_test_multiple "finish" "$test_msg" {
211     -re ".* short_checkpoint.*$gdb_prompt $" {
212         pass "$test_msg"
213     }
216 # Test reverse finish from short func
218 set breakloc [gdb_get_line_number "SHORT FUNC" "$srcfile"]
219 gdb_continue_to_breakpoint "short_func backward" \
220     ".*$srcfile:$breakloc.*"
222 set test_msg "reverse finish from short_func"
223 gdb_test_multiple "finish" "$test_msg" {
224     -re ".* char_checkpoint.*$gdb_prompt $" {
225         pass "$test_msg"
226     }
229 # Test reverse finish from char func
231 set breakloc [gdb_get_line_number "CHAR FUNC" "$srcfile"]
232 gdb_continue_to_breakpoint "char_func backward" \
233     ".*$srcfile:$breakloc.*"
235 set test_msg "reverse finish from char_func"
236 gdb_test_multiple "finish" "$test_msg" {
237     -re ".* void_checkpoint.*$gdb_prompt $" {
238         pass "$test_msg"
239     }
242 # Test reverse finish from void func
244 set breakloc [gdb_get_line_number "VOID FUNC" "$srcfile"]
245 gdb_continue_to_breakpoint "void_func backward" \
246     ".*$srcfile:$breakloc.*"
248 set test_msg "reverse finish from void_func"
249 gdb_test_multiple "finish" "$test_msg" {
250     -re ".* call to void_func.*$gdb_prompt $" {
251         pass "$test_msg"
252     }