1 # Copyright 2008, 2009, 2010 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 if ![target_info exists gdb,can_reverse] {
23 set testfile "finish-reverse"
24 set srcfile ${testfile}.c
26 if { [prepare_for_testing $testfile.exp "$testfile" $srcfile] } {
32 if [target_info exists gdb,use_precord] {
33 # Activate process record/replay
34 gdb_test "record" "" "Turn on process record"
35 # FIXME: command ought to acknowledge, so we can test if it succeeded.
38 # Test finish from void func
40 set breakloc [gdb_get_line_number "VOID FUNC" "$srcfile"]
41 gdb_test "break void_func" \
42 "Breakpoint $decimal at .*/$srcfile, line $breakloc\." \
43 "set breakpoint on void_func"
44 gdb_continue_to_breakpoint "void_func" ".*/$srcfile:$breakloc.*"
46 set test_msg "finish from void_func"
47 gdb_test_multiple "finish" "$test_msg" {
48 -re " call to void_func .*$gdb_prompt $" {
52 -re " void_checkpoint .*$gdb_prompt $" {
57 # Test finish from char func
59 set breakloc [gdb_get_line_number "CHAR FUNC" "$srcfile"]
60 gdb_test "break char_func" \
61 "Breakpoint $decimal at .*/$srcfile, line $breakloc\." \
62 "set breakpoint on char_func"
63 gdb_continue_to_breakpoint "char_func" ".*/$srcfile:$breakloc.*"
65 set test_msg "finish from char_func"
66 gdb_test_multiple "finish" "$test_msg" {
67 -re " void_checkpoint .*$gdb_prompt $" {
71 -re " char_checkpoint .*$gdb_prompt $" {
76 # Test finish from short func
78 set breakloc [gdb_get_line_number "SHORT FUNC" "$srcfile"]
79 gdb_test "break short_func" \
80 "Breakpoint $decimal at .* line $breakloc\." \
81 "set breakpoint on short_func"
82 gdb_continue_to_breakpoint "short_func" ".*/$srcfile:$breakloc.*"
84 set test_msg "finish from short_func"
85 gdb_test_multiple "finish" "$test_msg" {
86 -re " char_checkpoint .*$gdb_prompt $" {
90 -re " short_checkpoint .*$gdb_prompt $" {
95 # Test finish from int func
97 set breakloc [gdb_get_line_number "INT FUNC" "$srcfile"]
98 gdb_test "break int_func" \
99 "Breakpoint $decimal at .* line $breakloc\." \
100 "set breakpoint on int_func"
101 gdb_continue_to_breakpoint "int_func" ".*/$srcfile:$breakloc.*"
103 set test_msg "finish from int_func"
104 gdb_test_multiple "finish" "$test_msg" {
105 -re " short_checkpoint .*$gdb_prompt $" {
109 -re " int_checkpoint .*$gdb_prompt $" {
114 # Test finish from long func
116 set breakloc [gdb_get_line_number "LONG FUNC" "$srcfile"]
117 gdb_test "break long_func" \
118 "Breakpoint $decimal at .* line $breakloc\." \
119 "set breakpoint on long_func"
120 gdb_continue_to_breakpoint "long_func" ".*/$srcfile:$breakloc.*"
122 set test_msg "finish from long_func"
123 gdb_test_multiple "finish" "$test_msg" {
124 -re " int_checkpoint .*$gdb_prompt $" {
128 -re " long_checkpoint .*$gdb_prompt $" {
133 # Test finish from long long func
135 set breakloc [gdb_get_line_number "LONG LONG FUNC" "$srcfile"]
136 gdb_test "break long_long_func" \
137 "Breakpoint $decimal at .* line $breakloc\." \
138 "set breakpoint on long_long_func"
139 gdb_continue_to_breakpoint "long_long_func" ".*/$srcfile:$breakloc.*"
141 set test_msg "finish from long_long_func"
142 gdb_test_multiple "finish" "$test_msg" {
143 -re " long_checkpoint .*$gdb_prompt $" {
147 -re " long_long_checkpoint .*$gdb_prompt $" {
157 # Now switch to reverse
158 gdb_test "set exec-dir reverse" "" "set reverse execution"
160 # Test reverse finish from long long func
162 set breakloc [gdb_get_line_number "LONG LONG FUNC" "$srcfile"]
163 gdb_continue_to_breakpoint "long_long_func" ".*/$srcfile:$breakloc.*"
165 set test_msg "reverse finish from long_long_func"
166 gdb_test_multiple "finish" "$test_msg" {
167 -re ".* long_checkpoint.*$gdb_prompt $" {
172 # Test reverse finish from long func
174 set breakloc [gdb_get_line_number "LONG FUNC" "$srcfile"]
175 gdb_continue_to_breakpoint "long_func" ".*/$srcfile:$breakloc.*"
177 set test_msg "reverse finish from long_func"
178 gdb_test_multiple "finish" "$test_msg" {
179 -re ".* int_checkpoint.*$gdb_prompt $" {
184 # Test reverse finish from int func
186 set breakloc [gdb_get_line_number "INT FUNC" "$srcfile"]
187 gdb_continue_to_breakpoint "int_func" ".*/$srcfile:$breakloc.*"
189 set test_msg "reverse finish from int_func"
190 gdb_test_multiple "finish" "$test_msg" {
191 -re ".* short_checkpoint.*$gdb_prompt $" {
196 # Test reverse finish from short func
198 set breakloc [gdb_get_line_number "SHORT FUNC" "$srcfile"]
199 gdb_continue_to_breakpoint "short_func" ".*/$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" ".*/$srcfile:$breakloc.*"
213 set test_msg "reverse finish from char_func"
214 gdb_test_multiple "finish" "$test_msg" {
215 -re ".* void_checkpoint.*$gdb_prompt $" {
220 # Test reverse finish from void func
222 set breakloc [gdb_get_line_number "VOID FUNC" "$srcfile"]
223 gdb_continue_to_breakpoint "void_func" ".*/$srcfile:$breakloc.*"
225 set test_msg "reverse finish from void_func"
226 gdb_test_multiple "finish" "$test_msg" {
227 -re ".* call to void_func.*$gdb_prompt $" {