f93cfd8afa19a1ecb78ac4d1c95301df69de51fb
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.reverse / finish-precsave.exp
1 # Copyright 2008, 2009, 2010 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
19 if ![target_info exists gdb,can_reverse] {
20 return
21 }
22
23 set testfile "finish-reverse"
24 set srcfile ${testfile}.c
25
26 if { [prepare_for_testing $testfile.exp "$testfile" $srcfile] } {
27 return -1
28 }
29
30 runto main
31
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.
36 }
37
38 # Run until end, then save execution log.
39
40 set breakloc [gdb_get_line_number "end of main" "$srcfile"]
41 gdb_test "break $breakloc" \
42 "Breakpoint $decimal at .*/$srcfile, line $breakloc\." \
43 "BP at end of main"
44
45 gdb_test "continue" "Breakpoint .* end of main .*" "run to end of main"
46
47 gdb_test "record save finish.precsave" \
48 "Saved core file finish.precsave with execution log\." \
49 "save process recfile"
50
51 gdb_test "kill" "" "Kill process, prepare to debug log file" \
52 "Kill the program being debugged\\? \\(y or n\\) " "y"
53
54 gdb_test "record restore finish.precsave" \
55 "Program terminated with signal .*" \
56 "reload precord save file"
57
58 # Test finish from void func
59
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.*"
65
66 set test_msg "finish from void_func"
67 gdb_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
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.*"
84
85 set test_msg "finish from char_func"
86 gdb_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
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.*"
103
104 set test_msg "finish from short_func"
105 gdb_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
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.*"
122
123 set test_msg "finish from int_func"
124 gdb_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
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.*"
141
142 set test_msg "finish from long_func"
143 gdb_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
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.*"
160
161 set test_msg "finish from long_long_func"
162 gdb_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
178 gdb_test "set exec-dir reverse" "" "set reverse execution"
179
180 # Test reverse finish from long long func
181
182 set breakloc [gdb_get_line_number "LONG LONG FUNC" "$srcfile"]
183 gdb_continue_to_breakpoint "long_long_func" ".*/$srcfile:$breakloc.*"
184
185 set test_msg "reverse finish from long_long_func"
186 gdb_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
194 set breakloc [gdb_get_line_number "LONG FUNC" "$srcfile"]
195 gdb_continue_to_breakpoint "long_func" ".*/$srcfile:$breakloc.*"
196
197 set test_msg "reverse finish from long_func"
198 gdb_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
206 set breakloc [gdb_get_line_number "INT FUNC" "$srcfile"]
207 gdb_continue_to_breakpoint "int_func" ".*/$srcfile:$breakloc.*"
208
209 set test_msg "reverse finish from int_func"
210 gdb_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
218 set breakloc [gdb_get_line_number "SHORT FUNC" "$srcfile"]
219 gdb_continue_to_breakpoint "short_func" ".*/$srcfile:$breakloc.*"
220
221 set test_msg "reverse finish from short_func"
222 gdb_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
230 set breakloc [gdb_get_line_number "CHAR FUNC" "$srcfile"]
231 gdb_continue_to_breakpoint "char_func" ".*/$srcfile:$breakloc.*"
232
233 set test_msg "reverse finish from char_func"
234 gdb_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
242 set breakloc [gdb_get_line_number "VOID FUNC" "$srcfile"]
243 gdb_continue_to_breakpoint "void_func" ".*/$srcfile:$breakloc.*"
244
245 set test_msg "reverse finish from void_func"
246 gdb_test_multiple "finish" "$test_msg" {
247 -re ".* call to void_func.*$gdb_prompt $" {
248 pass "$test_msg"
249 }
250 }
This page took 0.034221 seconds and 3 git commands to generate.