Update copyright year in most headers.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.reverse / finish-reverse.exp
CommitLineData
4c38e0a4 1# Copyright 2008, 2009, 2010 Free Software Foundation, Inc.
28d41a99
MS
2
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.
7#
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.
12#
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/>.
15
16# This file is part of the GDB testsuite. It tests 'finish' with
17# reverse debugging.
18
19if ![target_info exists gdb,can_reverse] {
20 return
21}
22
23set testfile "finish-reverse"
24set srcfile ${testfile}.c
25
26if { [prepare_for_testing $testfile.exp "$testfile" $srcfile] } {
27 return -1
28}
29
28d41a99
MS
30runto main
31
32if [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.
36}
37
38# Test finish from void func
39
40set breakloc [gdb_get_line_number "VOID FUNC" "$srcfile"]
41gdb_test "break void_func" \
42 "Breakpoint $decimal at .*/$srcfile, line $breakloc\." \
43 "set breakpoint on void_func"
44gdb_continue_to_breakpoint "void_func" ".*/$srcfile:$breakloc.*"
45
46set test_msg "finish from void_func"
47gdb_test_multiple "finish" "$test_msg" {
48 -re " call to void_func .*$gdb_prompt $" {
49 send_gdb "step\n"
50 exp_continue
51 }
52 -re " void_checkpoint .*$gdb_prompt $" {
53 pass "$test_msg"
54 }
55}
56
57# Test finish from char func
58
59set breakloc [gdb_get_line_number "CHAR FUNC" "$srcfile"]
60gdb_test "break char_func" \
61 "Breakpoint $decimal at .*/$srcfile, line $breakloc\." \
62 "set breakpoint on char_func"
63gdb_continue_to_breakpoint "char_func" ".*/$srcfile:$breakloc.*"
64
65set test_msg "finish from char_func"
66gdb_test_multiple "finish" "$test_msg" {
67 -re " void_checkpoint .*$gdb_prompt $" {
68 send_gdb "step\n"
69 exp_continue
70 }
71 -re " char_checkpoint .*$gdb_prompt $" {
72 pass "$test_msg"
73 }
74}
75
76# Test finish from short func
77
78set breakloc [gdb_get_line_number "SHORT FUNC" "$srcfile"]
79gdb_test "break short_func" \
80 "Breakpoint $decimal at .* line $breakloc\." \
81 "set breakpoint on short_func"
82gdb_continue_to_breakpoint "short_func" ".*/$srcfile:$breakloc.*"
83
84set test_msg "finish from short_func"
85gdb_test_multiple "finish" "$test_msg" {
86 -re " char_checkpoint .*$gdb_prompt $" {
87 send_gdb "step\n"
88 exp_continue
89 }
90 -re " short_checkpoint .*$gdb_prompt $" {
91 pass "$test_msg"
92 }
93}
94
95# Test finish from int func
96
97set breakloc [gdb_get_line_number "INT FUNC" "$srcfile"]
98gdb_test "break int_func" \
99 "Breakpoint $decimal at .* line $breakloc\." \
100 "set breakpoint on int_func"
101gdb_continue_to_breakpoint "int_func" ".*/$srcfile:$breakloc.*"
102
103set test_msg "finish from int_func"
104gdb_test_multiple "finish" "$test_msg" {
105 -re " short_checkpoint .*$gdb_prompt $" {
106 send_gdb "step\n"
107 exp_continue
108 }
109 -re " int_checkpoint .*$gdb_prompt $" {
110 pass "$test_msg"
111 }
112}
113
114# Test finish from long func
115
116set breakloc [gdb_get_line_number "LONG FUNC" "$srcfile"]
117gdb_test "break long_func" \
118 "Breakpoint $decimal at .* line $breakloc\." \
119 "set breakpoint on long_func"
120gdb_continue_to_breakpoint "long_func" ".*/$srcfile:$breakloc.*"
121
122set test_msg "finish from long_func"
123gdb_test_multiple "finish" "$test_msg" {
124 -re " int_checkpoint .*$gdb_prompt $" {
125 send_gdb "step\n"
126 exp_continue
127 }
128 -re " long_checkpoint .*$gdb_prompt $" {
129 pass "$test_msg"
130 }
131}
132
133# Test finish from long long func
134
135set breakloc [gdb_get_line_number "LONG LONG FUNC" "$srcfile"]
136gdb_test "break long_long_func" \
137 "Breakpoint $decimal at .* line $breakloc\." \
138 "set breakpoint on long_long_func"
139gdb_continue_to_breakpoint "long_long_func" ".*/$srcfile:$breakloc.*"
140
141set test_msg "finish from long_long_func"
142gdb_test_multiple "finish" "$test_msg" {
143 -re " long_checkpoint .*$gdb_prompt $" {
144 send_gdb "step\n"
145 exp_continue
146 }
147 -re " long_long_checkpoint .*$gdb_prompt $" {
148 pass "$test_msg"
149 }
150}
151
152
153###
154###
155###
156
157# Now switch to reverse
158gdb_test "set exec-dir reverse" "" "set reverse execution"
159
160# Test reverse finish from long long func
161
162set breakloc [gdb_get_line_number "LONG LONG FUNC" "$srcfile"]
163gdb_continue_to_breakpoint "long_long_func" ".*/$srcfile:$breakloc.*"
164
165set test_msg "reverse finish from long_long_func"
166gdb_test_multiple "finish" "$test_msg" {
167 -re ".* long_checkpoint.*$gdb_prompt $" {
dcd5da87 168 pass "$test_msg"
28d41a99
MS
169 }
170}
171
172# Test reverse finish from long func
173
174set breakloc [gdb_get_line_number "LONG FUNC" "$srcfile"]
175gdb_continue_to_breakpoint "long_func" ".*/$srcfile:$breakloc.*"
176
177set test_msg "reverse finish from long_func"
178gdb_test_multiple "finish" "$test_msg" {
179 -re ".* int_checkpoint.*$gdb_prompt $" {
dcd5da87 180 pass "$test_msg"
28d41a99
MS
181 }
182}
183
184# Test reverse finish from int func
185
186set breakloc [gdb_get_line_number "INT FUNC" "$srcfile"]
187gdb_continue_to_breakpoint "int_func" ".*/$srcfile:$breakloc.*"
188
189set test_msg "reverse finish from int_func"
190gdb_test_multiple "finish" "$test_msg" {
191 -re ".* short_checkpoint.*$gdb_prompt $" {
dcd5da87 192 pass "$test_msg"
28d41a99
MS
193 }
194}
195
196# Test reverse finish from short func
197
198set breakloc [gdb_get_line_number "SHORT FUNC" "$srcfile"]
199gdb_continue_to_breakpoint "short_func" ".*/$srcfile:$breakloc.*"
200
201set test_msg "reverse finish from short_func"
202gdb_test_multiple "finish" "$test_msg" {
203 -re ".* char_checkpoint.*$gdb_prompt $" {
dcd5da87 204 pass "$test_msg"
28d41a99
MS
205 }
206}
207
208# Test reverse finish from char func
209
210set breakloc [gdb_get_line_number "CHAR FUNC" "$srcfile"]
211gdb_continue_to_breakpoint "char_func" ".*/$srcfile:$breakloc.*"
212
213set test_msg "reverse finish from char_func"
214gdb_test_multiple "finish" "$test_msg" {
215 -re ".* void_checkpoint.*$gdb_prompt $" {
dcd5da87 216 pass "$test_msg"
28d41a99
MS
217 }
218}
219
220# Test reverse finish from void func
221
222set breakloc [gdb_get_line_number "VOID FUNC" "$srcfile"]
223gdb_continue_to_breakpoint "void_func" ".*/$srcfile:$breakloc.*"
224
225set test_msg "reverse finish from void_func"
226gdb_test_multiple "finish" "$test_msg" {
227 -re ".* call to void_func.*$gdb_prompt $" {
dcd5da87 228 pass "$test_msg"
28d41a99
MS
229 }
230}
This page took 0.088098 seconds and 4 git commands to generate.