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