2009-10-19 Michael Snyder <msnyder@vmware.com>
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.reverse / finish-precsave.exp
CommitLineData
02506ff1
MS
1# Copyright 2008, 2009 Free Software Foundation, Inc.
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
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# Run until end, then save execution log.
39
40set breakloc [gdb_get_line_number "end of main" "$srcfile"]
41gdb_test "break $breakloc" \
42 "Breakpoint $decimal at .*/$srcfile, line $breakloc\." \
43 "BP at end of main"
44
45gdb_test "continue" "Breakpoint .* end of main .*" "run to end of main"
46
47gdb_test "record save finish.precsave" \
48 "Saved core file finish.precsave with execution log\." \
49 "save process recfile"
50
51gdb_test "kill" "" "Kill process, prepare to debug log file" \
52 "Kill the program being debugged\\? \\(y or n\\) " "y"
53
54gdb_test "record restore finish.precsave" \
55 "Program terminated with signal .*" \
56 "reload precord save file"
57
58# Test finish from void func
59
60set breakloc [gdb_get_line_number "VOID FUNC" "$srcfile"]
61gdb_test "break void_func" \
62 "Breakpoint $decimal at .*/$srcfile, line $breakloc\." \
63 "set breakpoint on void_func"
64gdb_continue_to_breakpoint "void_func" ".*/$srcfile:$breakloc.*"
65
66set test_msg "finish from void_func"
67gdb_test_multiple "finish" "$test_msg" {
68 -re " call to void_func .*$gdb_prompt $" {
69 send_gdb "step\n"
70 exp_continue
71 }
72 -re " void_checkpoint .*$gdb_prompt $" {
73 pass "$test_msg"
74 }
75}
76
77# Test finish from char func
78
79set breakloc [gdb_get_line_number "CHAR FUNC" "$srcfile"]
80gdb_test "break char_func" \
81 "Breakpoint $decimal at .*/$srcfile, line $breakloc\." \
82 "set breakpoint on char_func"
83gdb_continue_to_breakpoint "char_func" ".*/$srcfile:$breakloc.*"
84
85set test_msg "finish from char_func"
86gdb_test_multiple "finish" "$test_msg" {
87 -re " void_checkpoint .*$gdb_prompt $" {
88 send_gdb "step\n"
89 exp_continue
90 }
91 -re " char_checkpoint .*$gdb_prompt $" {
92 pass "$test_msg"
93 }
94}
95
96# Test finish from short func
97
98set breakloc [gdb_get_line_number "SHORT FUNC" "$srcfile"]
99gdb_test "break short_func" \
100 "Breakpoint $decimal at .* line $breakloc\." \
101 "set breakpoint on short_func"
102gdb_continue_to_breakpoint "short_func" ".*/$srcfile:$breakloc.*"
103
104set test_msg "finish from short_func"
105gdb_test_multiple "finish" "$test_msg" {
106 -re " char_checkpoint .*$gdb_prompt $" {
107 send_gdb "step\n"
108 exp_continue
109 }
110 -re " short_checkpoint .*$gdb_prompt $" {
111 pass "$test_msg"
112 }
113}
114
115# Test finish from int func
116
117set breakloc [gdb_get_line_number "INT FUNC" "$srcfile"]
118gdb_test "break int_func" \
119 "Breakpoint $decimal at .* line $breakloc\." \
120 "set breakpoint on int_func"
121gdb_continue_to_breakpoint "int_func" ".*/$srcfile:$breakloc.*"
122
123set test_msg "finish from int_func"
124gdb_test_multiple "finish" "$test_msg" {
125 -re " short_checkpoint .*$gdb_prompt $" {
126 send_gdb "step\n"
127 exp_continue
128 }
129 -re " int_checkpoint .*$gdb_prompt $" {
130 pass "$test_msg"
131 }
132}
133
134# Test finish from long func
135
136set breakloc [gdb_get_line_number "LONG FUNC" "$srcfile"]
137gdb_test "break long_func" \
138 "Breakpoint $decimal at .* line $breakloc\." \
139 "set breakpoint on long_func"
140gdb_continue_to_breakpoint "long_func" ".*/$srcfile:$breakloc.*"
141
142set test_msg "finish from long_func"
143gdb_test_multiple "finish" "$test_msg" {
144 -re " int_checkpoint .*$gdb_prompt $" {
145 send_gdb "step\n"
146 exp_continue
147 }
148 -re " long_checkpoint .*$gdb_prompt $" {
149 pass "$test_msg"
150 }
151}
152
153# Test finish from long long func
154
155set breakloc [gdb_get_line_number "LONG LONG FUNC" "$srcfile"]
156gdb_test "break long_long_func" \
157 "Breakpoint $decimal at .* line $breakloc\." \
158 "set breakpoint on long_long_func"
159gdb_continue_to_breakpoint "long_long_func" ".*/$srcfile:$breakloc.*"
160
161set test_msg "finish from long_long_func"
162gdb_test_multiple "finish" "$test_msg" {
163 -re " long_checkpoint .*$gdb_prompt $" {
164 send_gdb "step\n"
165 exp_continue
166 }
167 -re " long_long_checkpoint .*$gdb_prompt $" {
168 pass "$test_msg"
169 }
170}
171
172
173###
174###
175###
176
177# Now switch to reverse
178gdb_test "set exec-dir reverse" "" "set reverse execution"
179
180# Test reverse finish from long long func
181
182set breakloc [gdb_get_line_number "LONG LONG FUNC" "$srcfile"]
183gdb_continue_to_breakpoint "long_long_func" ".*/$srcfile:$breakloc.*"
184
185set test_msg "reverse finish from long_long_func"
186gdb_test_multiple "finish" "$test_msg" {
187 -re ".* long_checkpoint.*$gdb_prompt $" {
188 pass "$test_msg"
189 }
190}
191
192# Test reverse finish from long func
193
194set breakloc [gdb_get_line_number "LONG FUNC" "$srcfile"]
195gdb_continue_to_breakpoint "long_func" ".*/$srcfile:$breakloc.*"
196
197set test_msg "reverse finish from long_func"
198gdb_test_multiple "finish" "$test_msg" {
199 -re ".* int_checkpoint.*$gdb_prompt $" {
200 pass "$test_msg"
201 }
202}
203
204# Test reverse finish from int func
205
206set breakloc [gdb_get_line_number "INT FUNC" "$srcfile"]
207gdb_continue_to_breakpoint "int_func" ".*/$srcfile:$breakloc.*"
208
209set test_msg "reverse finish from int_func"
210gdb_test_multiple "finish" "$test_msg" {
211 -re ".* short_checkpoint.*$gdb_prompt $" {
212 pass "$test_msg"
213 }
214}
215
216# Test reverse finish from short func
217
218set breakloc [gdb_get_line_number "SHORT FUNC" "$srcfile"]
219gdb_continue_to_breakpoint "short_func" ".*/$srcfile:$breakloc.*"
220
221set test_msg "reverse finish from short_func"
222gdb_test_multiple "finish" "$test_msg" {
223 -re ".* char_checkpoint.*$gdb_prompt $" {
224 pass "$test_msg"
225 }
226}
227
228# Test reverse finish from char func
229
230set breakloc [gdb_get_line_number "CHAR FUNC" "$srcfile"]
231gdb_continue_to_breakpoint "char_func" ".*/$srcfile:$breakloc.*"
232
233set test_msg "reverse finish from char_func"
234gdb_test_multiple "finish" "$test_msg" {
235 -re ".* void_checkpoint.*$gdb_prompt $" {
236 pass "$test_msg"
237 }
238}
239
240# Test reverse finish from void func
241
242set breakloc [gdb_get_line_number "VOID FUNC" "$srcfile"]
243gdb_continue_to_breakpoint "void_func" ".*/$srcfile:$breakloc.*"
244
245set test_msg "reverse finish from void_func"
246gdb_test_multiple "finish" "$test_msg" {
247 -re ".* call to void_func.*$gdb_prompt $" {
248 pass "$test_msg"
249 }
250}
This page took 0.032078 seconds and 4 git commands to generate.