1 # Copyright 2008-2012 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 ![supports_reverse] {
23 standard_testfile finish-reverse.c
25 if { [prepare_for_testing $testfile.exp "$testfile" $srcfile] } {
31 if [supports_process_record] {
32 # Activate process record/replay
33 gdb_test_no_output "record" "Turn on process record"
36 # Run until end, then save execution log.
38 set breakloc [gdb_get_line_number "end of main" "$srcfile"]
39 gdb_test "break $breakloc" \
40 "Breakpoint $decimal at .*/$srcfile, line $breakloc\." \
43 gdb_test "continue" "Breakpoint .* end of main .*" "run to end of main"
45 gdb_test "record save finish.precsave" \
46 "Saved core file finish.precsave with execution log\." \
47 "save process recfile"
49 gdb_test "kill" "" "Kill process, prepare to debug log file" \
50 "Kill the program being debugged\\? \\(y or n\\) " "y"
52 gdb_test "record restore finish.precsave" \
53 "Program terminated with signal .*" \
54 "reload precord save file"
56 # Test finish from void func
58 set breakloc [gdb_get_line_number "VOID FUNC" "$srcfile"]
59 gdb_test "break void_func" \
60 "Breakpoint $decimal at .*/$srcfile, line $breakloc\." \
61 "set breakpoint on void_func"
62 gdb_continue_to_breakpoint "void_func" ".*/$srcfile:$breakloc.*"
64 set test_msg "finish from void_func"
65 gdb_test_multiple "finish" "$test_msg" {
66 -re " call to void_func .*$gdb_prompt $" {
70 -re " void_checkpoint .*$gdb_prompt $" {
75 # Test finish from char func
77 set breakloc [gdb_get_line_number "CHAR FUNC" "$srcfile"]
78 gdb_test "break char_func" \
79 "Breakpoint $decimal at .*/$srcfile, line $breakloc\." \
80 "set breakpoint on char_func"
81 gdb_continue_to_breakpoint "char_func" ".*/$srcfile:$breakloc.*"
83 set test_msg "finish from char_func"
84 gdb_test_multiple "finish" "$test_msg" {
85 -re " void_checkpoint .*$gdb_prompt $" {
89 -re " char_checkpoint .*$gdb_prompt $" {
94 # Test finish from short func
96 set breakloc [gdb_get_line_number "SHORT FUNC" "$srcfile"]
97 gdb_test "break short_func" \
98 "Breakpoint $decimal at .* line $breakloc\." \
99 "set breakpoint on short_func"
100 gdb_continue_to_breakpoint "short_func" ".*/$srcfile:$breakloc.*"
102 set test_msg "finish from short_func"
103 gdb_test_multiple "finish" "$test_msg" {
104 -re " char_checkpoint .*$gdb_prompt $" {
108 -re " short_checkpoint .*$gdb_prompt $" {
113 # Test finish from int func
115 set breakloc [gdb_get_line_number "INT FUNC" "$srcfile"]
116 gdb_test "break int_func" \
117 "Breakpoint $decimal at .* line $breakloc\." \
118 "set breakpoint on int_func"
119 gdb_continue_to_breakpoint "int_func" ".*/$srcfile:$breakloc.*"
121 set test_msg "finish from int_func"
122 gdb_test_multiple "finish" "$test_msg" {
123 -re " short_checkpoint .*$gdb_prompt $" {
127 -re " int_checkpoint .*$gdb_prompt $" {
132 # Test finish from long func
134 set breakloc [gdb_get_line_number "LONG FUNC" "$srcfile"]
135 gdb_test "break long_func" \
136 "Breakpoint $decimal at .* line $breakloc\." \
137 "set breakpoint on long_func"
138 gdb_continue_to_breakpoint "long_func" ".*/$srcfile:$breakloc.*"
140 set test_msg "finish from long_func"
141 gdb_test_multiple "finish" "$test_msg" {
142 -re " int_checkpoint .*$gdb_prompt $" {
146 -re " long_checkpoint .*$gdb_prompt $" {
151 # Test finish from long long func
153 set breakloc [gdb_get_line_number "LONG LONG FUNC" "$srcfile"]
154 gdb_test "break long_long_func" \
155 "Breakpoint $decimal at .* line $breakloc\." \
156 "set breakpoint on long_long_func"
157 gdb_continue_to_breakpoint "long_long_func" ".*/$srcfile:$breakloc.*"
159 set test_msg "finish from long_long_func"
160 gdb_test_multiple "finish" "$test_msg" {
161 -re " long_checkpoint .*$gdb_prompt $" {
165 -re " long_long_checkpoint .*$gdb_prompt $" {
175 # Now switch to reverse
176 gdb_test_no_output "set exec-dir reverse" "set reverse execution"
178 # Test reverse finish from long long func
180 set breakloc [gdb_get_line_number "LONG LONG FUNC" "$srcfile"]
181 gdb_continue_to_breakpoint "long_long_func" ".*/$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 $" {
190 # Test reverse finish from long func
192 set breakloc [gdb_get_line_number "LONG FUNC" "$srcfile"]
193 gdb_continue_to_breakpoint "long_func" ".*/$srcfile:$breakloc.*"
195 set test_msg "reverse finish from long_func"
196 gdb_test_multiple "finish" "$test_msg" {
197 -re ".* int_checkpoint.*$gdb_prompt $" {
202 # Test reverse finish from int func
204 set breakloc [gdb_get_line_number "INT FUNC" "$srcfile"]
205 gdb_continue_to_breakpoint "int_func" ".*/$srcfile:$breakloc.*"
207 set test_msg "reverse finish from int_func"
208 gdb_test_multiple "finish" "$test_msg" {
209 -re ".* short_checkpoint.*$gdb_prompt $" {
214 # Test reverse finish from short func
216 set breakloc [gdb_get_line_number "SHORT FUNC" "$srcfile"]
217 gdb_continue_to_breakpoint "short_func" ".*/$srcfile:$breakloc.*"
219 set test_msg "reverse finish from short_func"
220 gdb_test_multiple "finish" "$test_msg" {
221 -re ".* char_checkpoint.*$gdb_prompt $" {
226 # Test reverse finish from char func
228 set breakloc [gdb_get_line_number "CHAR FUNC" "$srcfile"]
229 gdb_continue_to_breakpoint "char_func" ".*/$srcfile:$breakloc.*"
231 set test_msg "reverse finish from char_func"
232 gdb_test_multiple "finish" "$test_msg" {
233 -re ".* void_checkpoint.*$gdb_prompt $" {
238 # Test reverse finish from void func
240 set breakloc [gdb_get_line_number "VOID FUNC" "$srcfile"]
241 gdb_continue_to_breakpoint "void_func" ".*/$srcfile:$breakloc.*"
243 set test_msg "reverse finish from void_func"
244 gdb_test_multiple "finish" "$test_msg" {
245 -re ".* call to void_func.*$gdb_prompt $" {