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
19 require supports_reverse
23 if { [prepare_for_testing "failed to prepare" "$testfile" $srcfile] } {
29 if [supports_process_record] {
30 # Activate process record/replay
31 gdb_test_no_output "record" "turn on process record"
34 # Test finish from void func
36 set breakloc [gdb_get_line_number "VOID FUNC" "$srcfile"]
37 gdb_test "break void_func" \
38 "Breakpoint $decimal at .*$srcfile, line $breakloc\." \
39 "set breakpoint on void_func"
40 gdb_continue_to_breakpoint "void_func" ".*$srcfile:$breakloc.*"
42 set test_msg "finish from void_func"
43 gdb_test_multiple "finish" "$test_msg" {
44 -re " call to void_func .*$gdb_prompt $" {
48 -re " void_checkpoint .*$gdb_prompt $" {
53 # Test finish from char func
55 set breakloc [gdb_get_line_number "CHAR FUNC" "$srcfile"]
56 gdb_test "break char_func" \
57 "Breakpoint $decimal at .*$srcfile, line $breakloc\." \
58 "set breakpoint on char_func"
59 gdb_continue_to_breakpoint "char_func" ".*$srcfile:$breakloc.*"
61 set test_msg "finish from char_func"
62 gdb_test_multiple "finish" "$test_msg" {
63 -re " void_checkpoint .*$gdb_prompt $" {
67 -re " char_checkpoint .*$gdb_prompt $" {
72 # Test finish from short func
74 set breakloc [gdb_get_line_number "SHORT FUNC" "$srcfile"]
75 gdb_test "break short_func" \
76 "Breakpoint $decimal at .* line $breakloc\." \
77 "set breakpoint on short_func"
78 gdb_continue_to_breakpoint "short_func" ".*$srcfile:$breakloc.*"
80 set test_msg "finish from short_func"
81 gdb_test_multiple "finish" "$test_msg" {
82 -re " char_checkpoint .*$gdb_prompt $" {
86 -re " short_checkpoint .*$gdb_prompt $" {
91 # Test finish from int func
93 set breakloc [gdb_get_line_number "INT FUNC" "$srcfile"]
94 gdb_test "break int_func" \
95 "Breakpoint $decimal at .* line $breakloc\." \
96 "set breakpoint on int_func"
97 gdb_continue_to_breakpoint "int_func" ".*$srcfile:$breakloc.*"
99 set test_msg "finish from int_func"
100 gdb_test_multiple "finish" "$test_msg" {
101 -re " short_checkpoint .*$gdb_prompt $" {
105 -re " int_checkpoint .*$gdb_prompt $" {
110 # Test finish from long func
112 set breakloc [gdb_get_line_number "LONG FUNC" "$srcfile"]
113 gdb_test "break long_func" \
114 "Breakpoint $decimal at .* line $breakloc\." \
115 "set breakpoint on long_func"
116 gdb_continue_to_breakpoint "long_func" ".*$srcfile:$breakloc.*"
118 set test_msg "finish from long_func"
119 gdb_test_multiple "finish" "$test_msg" {
120 -re " int_checkpoint .*$gdb_prompt $" {
124 -re " long_checkpoint .*$gdb_prompt $" {
129 # Test finish from long long func
131 set breakloc [gdb_get_line_number "LONG LONG FUNC" "$srcfile"]
132 gdb_test "break long_long_func" \
133 "Breakpoint $decimal at .* line $breakloc\." \
134 "set breakpoint on long_long_func"
135 gdb_continue_to_breakpoint "long_long_func" ".*$srcfile:$breakloc.*"
137 set test_msg "finish from long_long_func"
138 gdb_test_multiple "finish" "$test_msg" {
139 -re " long_checkpoint .*$gdb_prompt $" {
143 -re " long_long_checkpoint .*$gdb_prompt $" {
153 # Now switch to reverse
154 gdb_test_no_output "set exec-dir reverse" "set reverse execution"
156 # Test reverse finish from long long func
158 set breakloc [gdb_get_line_number "LONG LONG FUNC" "$srcfile"]
159 gdb_continue_to_breakpoint "long_long_func backward" \
160 ".*$srcfile:$breakloc.*"
162 set test_msg "reverse finish from long_long_func"
163 gdb_test_multiple "finish" "$test_msg" {
164 -re ".* long_checkpoint.*$gdb_prompt $" {
169 # Test reverse finish from long func
171 set breakloc [gdb_get_line_number "LONG FUNC" "$srcfile"]
172 gdb_continue_to_breakpoint "long_func backward" \
173 ".*$srcfile:$breakloc.*"
175 set test_msg "reverse finish from long_func"
176 gdb_test_multiple "finish" "$test_msg" {
177 -re ".* int_checkpoint.*$gdb_prompt $" {
182 # Test reverse finish from int func
184 set breakloc [gdb_get_line_number "INT FUNC" "$srcfile"]
185 gdb_continue_to_breakpoint "int_func backward" \
186 ".*$srcfile:$breakloc.*"
188 set test_msg "reverse finish from int_func"
189 gdb_test_multiple "finish" "$test_msg" {
190 -re ".* short_checkpoint.*$gdb_prompt $" {
195 # Test reverse finish from short func
197 set breakloc [gdb_get_line_number "SHORT FUNC" "$srcfile"]
198 gdb_continue_to_breakpoint "short_func backward" \
199 ".*$srcfile:$breakloc.*"
201 set test_msg "reverse finish from short_func"
202 gdb_test_multiple "finish" "$test_msg" {
203 -re ".* char_checkpoint.*$gdb_prompt $" {
208 # Test reverse finish from char func
210 set breakloc [gdb_get_line_number "CHAR FUNC" "$srcfile"]
211 gdb_continue_to_breakpoint "char_func backward" \
212 ".*$srcfile:$breakloc.*"
214 set test_msg "reverse finish from char_func"
215 gdb_test_multiple "finish" "$test_msg" {
216 -re ".* void_checkpoint.*$gdb_prompt $" {
221 # Test reverse finish from void func
223 set breakloc [gdb_get_line_number "VOID FUNC" "$srcfile"]
224 gdb_continue_to_breakpoint "void_func backward" \
225 ".*$srcfile:$breakloc.*"
227 set test_msg "reverse finish from void_func"
228 gdb_test_multiple "finish" "$test_msg" {
229 -re ".* call to void_func.*$gdb_prompt $" {