1 # Copyright 2008, 2009 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] } {
30 proc test_start_of_line { line_text test_msg } {
35 send_gdb "info line\n"
37 -re "Line $decimal of .* starts at address ($hex) .*$gdb_prompt $" {
38 set line_begin $expect_out(1,string)
41 fail "Get line address in test_start_of_line"
44 send_gdb "info reg pc\n"
46 -re ".*: ($hex)\r\n*$gdb_prompt $" {
47 set stop_pc $expect_out(1,string)
50 fail"Get stop pc in test_start_of_line"
53 gdb_test "print $line_begin == $stop_pc" \
55 "test_start_of_line, $test_msg"
60 if [target_info exists gdb,use_precord] {
61 # Activate process record/replay
62 gdb_test "record" "" "Turn on process record"
63 # FIXME: command ought to acknowledge, so we can test if it succeeded.
66 # Test finish from void func
68 set breakloc [gdb_get_line_number "VOID FUNC" "$srcfile"]
69 gdb_test "break void_func" \
70 "Breakpoint $decimal at .*/$srcfile, line $breakloc\." \
71 "set breakpoint on void_func"
72 gdb_continue_to_breakpoint "void_func" ".*/$srcfile:$breakloc.*"
74 set test_msg "finish from void_func"
75 gdb_test_multiple "finish" "$test_msg" {
76 -re " call to void_func .*$gdb_prompt $" {
80 -re " void_checkpoint .*$gdb_prompt $" {
85 # Test finish from char func
87 set breakloc [gdb_get_line_number "CHAR FUNC" "$srcfile"]
88 gdb_test "break char_func" \
89 "Breakpoint $decimal at .*/$srcfile, line $breakloc\." \
90 "set breakpoint on char_func"
91 gdb_continue_to_breakpoint "char_func" ".*/$srcfile:$breakloc.*"
93 set test_msg "finish from char_func"
94 gdb_test_multiple "finish" "$test_msg" {
95 -re " void_checkpoint .*$gdb_prompt $" {
99 -re " char_checkpoint .*$gdb_prompt $" {
104 # Test finish from short func
106 set breakloc [gdb_get_line_number "SHORT FUNC" "$srcfile"]
107 gdb_test "break short_func" \
108 "Breakpoint $decimal at .* line $breakloc\." \
109 "set breakpoint on short_func"
110 gdb_continue_to_breakpoint "short_func" ".*/$srcfile:$breakloc.*"
112 set test_msg "finish from short_func"
113 gdb_test_multiple "finish" "$test_msg" {
114 -re " char_checkpoint .*$gdb_prompt $" {
118 -re " short_checkpoint .*$gdb_prompt $" {
123 # Test finish from int func
125 set breakloc [gdb_get_line_number "INT FUNC" "$srcfile"]
126 gdb_test "break int_func" \
127 "Breakpoint $decimal at .* line $breakloc\." \
128 "set breakpoint on int_func"
129 gdb_continue_to_breakpoint "int_func" ".*/$srcfile:$breakloc.*"
131 set test_msg "finish from int_func"
132 gdb_test_multiple "finish" "$test_msg" {
133 -re " short_checkpoint .*$gdb_prompt $" {
137 -re " int_checkpoint .*$gdb_prompt $" {
142 # Test finish from long func
144 set breakloc [gdb_get_line_number "LONG FUNC" "$srcfile"]
145 gdb_test "break long_func" \
146 "Breakpoint $decimal at .* line $breakloc\." \
147 "set breakpoint on long_func"
148 gdb_continue_to_breakpoint "long_func" ".*/$srcfile:$breakloc.*"
150 set test_msg "finish from long_func"
151 gdb_test_multiple "finish" "$test_msg" {
152 -re " int_checkpoint .*$gdb_prompt $" {
156 -re " long_checkpoint .*$gdb_prompt $" {
161 # Test finish from long long func
163 set breakloc [gdb_get_line_number "LONG LONG FUNC" "$srcfile"]
164 gdb_test "break long_long_func" \
165 "Breakpoint $decimal at .* line $breakloc\." \
166 "set breakpoint on long_long_func"
167 gdb_continue_to_breakpoint "long_long_func" ".*/$srcfile:$breakloc.*"
169 set test_msg "finish from long_long_func"
170 gdb_test_multiple "finish" "$test_msg" {
171 -re " long_checkpoint .*$gdb_prompt $" {
175 -re " long_long_checkpoint .*$gdb_prompt $" {
185 # Now switch to reverse
186 gdb_test "set exec-dir reverse" "" "set reverse execution"
188 # Test reverse finish from long long func
190 set breakloc [gdb_get_line_number "LONG LONG FUNC" "$srcfile"]
191 gdb_continue_to_breakpoint "long_long_func" ".*/$srcfile:$breakloc.*"
193 set test_msg "reverse finish from long_long_func"
194 gdb_test_multiple "finish" "$test_msg" {
195 -re ".* long_checkpoint.*$gdb_prompt $" {
196 test_start_of_line "long_checkpoint" "$test_msg"
200 # Test reverse finish from long func
202 set breakloc [gdb_get_line_number "LONG FUNC" "$srcfile"]
203 gdb_continue_to_breakpoint "long_func" ".*/$srcfile:$breakloc.*"
205 set test_msg "reverse finish from long_func"
206 gdb_test_multiple "finish" "$test_msg" {
207 -re ".* int_checkpoint.*$gdb_prompt $" {
208 test_start_of_line "int_checkpoint" "$test_msg"
212 # Test reverse finish from int func
214 set breakloc [gdb_get_line_number "INT FUNC" "$srcfile"]
215 gdb_continue_to_breakpoint "int_func" ".*/$srcfile:$breakloc.*"
217 set test_msg "reverse finish from int_func"
218 gdb_test_multiple "finish" "$test_msg" {
219 -re ".* short_checkpoint.*$gdb_prompt $" {
220 test_start_of_line "short_checkpoint" "$test_msg"
224 # Test reverse finish from short func
226 set breakloc [gdb_get_line_number "SHORT FUNC" "$srcfile"]
227 gdb_continue_to_breakpoint "short_func" ".*/$srcfile:$breakloc.*"
229 set test_msg "reverse finish from short_func"
230 gdb_test_multiple "finish" "$test_msg" {
231 -re ".* char_checkpoint.*$gdb_prompt $" {
232 test_start_of_line "char_checkpoint" "$test_msg"
236 # Test reverse finish from char func
238 set breakloc [gdb_get_line_number "CHAR FUNC" "$srcfile"]
239 gdb_continue_to_breakpoint "char_func" ".*/$srcfile:$breakloc.*"
241 set test_msg "reverse finish from char_func"
242 gdb_test_multiple "finish" "$test_msg" {
243 -re ".* void_checkpoint.*$gdb_prompt $" {
244 test_start_of_line "void_checkpoint" "$test_msg"
248 # Test reverse finish from void func
250 set breakloc [gdb_get_line_number "VOID FUNC" "$srcfile"]
251 gdb_continue_to_breakpoint "void_func" ".*/$srcfile:$breakloc.*"
253 set test_msg "reverse finish from void_func"
254 gdb_test_multiple "finish" "$test_msg" {
255 -re ".* call to void_func.*$gdb_prompt $" {
256 test_start_of_line "call to void_func" "$test_msg"