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
# Run until end, then save execution log.
40
set breakloc [gdb_get_line_number "end of main" "$srcfile"]
41
gdb_test "break $breakloc" \
42
"Breakpoint $decimal at .*/$srcfile, line $breakloc\." \
45
gdb_test "continue" "Breakpoint .* end of main .*" "run to end of main"
47
gdb_test "record save finish.precsave" \
48
"Saved core file finish.precsave with execution log\." \
49
"save process recfile"
51
gdb_test "kill" "" "Kill process, prepare to debug log file" \
52
"Kill the program being debugged\\? \\(y or n\\) " "y"
54
gdb_test "record restore finish.precsave" \
55
"Program terminated with signal .*" \
56
"reload precord save file"
58
# Test finish from void func
60
set breakloc [gdb_get_line_number "VOID FUNC" "$srcfile"]
61
gdb_test "break void_func" \
62
"Breakpoint $decimal at .*/$srcfile, line $breakloc\." \
63
"set breakpoint on void_func"
64
gdb_continue_to_breakpoint "void_func" ".*/$srcfile:$breakloc.*"
66
set test_msg "finish from void_func"
67
gdb_test_multiple "finish" "$test_msg" {
68
-re " call to void_func .*$gdb_prompt $" {
72
-re " void_checkpoint .*$gdb_prompt $" {
77
# Test finish from char func
79
set breakloc [gdb_get_line_number "CHAR FUNC" "$srcfile"]
80
gdb_test "break char_func" \
81
"Breakpoint $decimal at .*/$srcfile, line $breakloc\." \
82
"set breakpoint on char_func"
83
gdb_continue_to_breakpoint "char_func" ".*/$srcfile:$breakloc.*"
85
set test_msg "finish from char_func"
86
gdb_test_multiple "finish" "$test_msg" {
87
-re " void_checkpoint .*$gdb_prompt $" {
91
-re " char_checkpoint .*$gdb_prompt $" {
96
# Test finish from short func
98
set breakloc [gdb_get_line_number "SHORT FUNC" "$srcfile"]
99
gdb_test "break short_func" \
100
"Breakpoint $decimal at .* line $breakloc\." \
101
"set breakpoint on short_func"
102
gdb_continue_to_breakpoint "short_func" ".*/$srcfile:$breakloc.*"
104
set test_msg "finish from short_func"
105
gdb_test_multiple "finish" "$test_msg" {
106
-re " char_checkpoint .*$gdb_prompt $" {
110
-re " short_checkpoint .*$gdb_prompt $" {
115
# Test finish from int func
117
set breakloc [gdb_get_line_number "INT FUNC" "$srcfile"]
118
gdb_test "break int_func" \
119
"Breakpoint $decimal at .* line $breakloc\." \
120
"set breakpoint on int_func"
121
gdb_continue_to_breakpoint "int_func" ".*/$srcfile:$breakloc.*"
123
set test_msg "finish from int_func"
124
gdb_test_multiple "finish" "$test_msg" {
125
-re " short_checkpoint .*$gdb_prompt $" {
129
-re " int_checkpoint .*$gdb_prompt $" {
134
# Test finish from long func
136
set breakloc [gdb_get_line_number "LONG FUNC" "$srcfile"]
137
gdb_test "break long_func" \
138
"Breakpoint $decimal at .* line $breakloc\." \
139
"set breakpoint on long_func"
140
gdb_continue_to_breakpoint "long_func" ".*/$srcfile:$breakloc.*"
142
set test_msg "finish from long_func"
143
gdb_test_multiple "finish" "$test_msg" {
144
-re " int_checkpoint .*$gdb_prompt $" {
148
-re " long_checkpoint .*$gdb_prompt $" {
153
# Test finish from long long func
155
set breakloc [gdb_get_line_number "LONG LONG FUNC" "$srcfile"]
156
gdb_test "break long_long_func" \
157
"Breakpoint $decimal at .* line $breakloc\." \
158
"set breakpoint on long_long_func"
159
gdb_continue_to_breakpoint "long_long_func" ".*/$srcfile:$breakloc.*"
161
set test_msg "finish from long_long_func"
162
gdb_test_multiple "finish" "$test_msg" {
163
-re " long_checkpoint .*$gdb_prompt $" {
167
-re " long_long_checkpoint .*$gdb_prompt $" {
177
# Now switch to reverse
178
gdb_test "set exec-dir reverse" "" "set reverse execution"
180
# Test reverse finish from long long func
182
set breakloc [gdb_get_line_number "LONG LONG FUNC" "$srcfile"]
183
gdb_continue_to_breakpoint "long_long_func" ".*/$srcfile:$breakloc.*"
185
set test_msg "reverse finish from long_long_func"
186
gdb_test_multiple "finish" "$test_msg" {
187
-re ".* long_checkpoint.*$gdb_prompt $" {
192
# Test reverse finish from long func
194
set breakloc [gdb_get_line_number "LONG FUNC" "$srcfile"]
195
gdb_continue_to_breakpoint "long_func" ".*/$srcfile:$breakloc.*"
197
set test_msg "reverse finish from long_func"
198
gdb_test_multiple "finish" "$test_msg" {
199
-re ".* int_checkpoint.*$gdb_prompt $" {
204
# Test reverse finish from int func
206
set breakloc [gdb_get_line_number "INT FUNC" "$srcfile"]
207
gdb_continue_to_breakpoint "int_func" ".*/$srcfile:$breakloc.*"
209
set test_msg "reverse finish from int_func"
210
gdb_test_multiple "finish" "$test_msg" {
211
-re ".* short_checkpoint.*$gdb_prompt $" {
216
# Test reverse finish from short func
218
set breakloc [gdb_get_line_number "SHORT FUNC" "$srcfile"]
219
gdb_continue_to_breakpoint "short_func" ".*/$srcfile:$breakloc.*"
221
set test_msg "reverse finish from short_func"
222
gdb_test_multiple "finish" "$test_msg" {
223
-re ".* char_checkpoint.*$gdb_prompt $" {
228
# Test reverse finish from char func
230
set breakloc [gdb_get_line_number "CHAR FUNC" "$srcfile"]
231
gdb_continue_to_breakpoint "char_func" ".*/$srcfile:$breakloc.*"
233
set test_msg "reverse finish from char_func"
234
gdb_test_multiple "finish" "$test_msg" {
235
-re ".* void_checkpoint.*$gdb_prompt $" {
240
# Test reverse finish from void func
242
set breakloc [gdb_get_line_number "VOID FUNC" "$srcfile"]
243
gdb_continue_to_breakpoint "void_func" ".*/$srcfile:$breakloc.*"
245
set test_msg "reverse finish from void_func"
246
gdb_test_multiple "finish" "$test_msg" {
247
-re ".* call to void_func.*$gdb_prompt $" {