OSDN Git Service

Update copyright year in most headers.
[pf3gnuchains/pf3gnuchains3x.git] / gdb / testsuite / gdb.reverse / finish-reverse.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 # Test finish from void func
39
40 set breakloc [gdb_get_line_number "VOID FUNC" "$srcfile"]
41 gdb_test "break void_func" \
42     "Breakpoint $decimal at .*/$srcfile, line $breakloc\." \
43     "set breakpoint on void_func"
44 gdb_continue_to_breakpoint "void_func" ".*/$srcfile:$breakloc.*"
45
46 set test_msg "finish from void_func"
47 gdb_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
59 set breakloc [gdb_get_line_number "CHAR FUNC" "$srcfile"]
60 gdb_test "break char_func" \
61     "Breakpoint $decimal at .*/$srcfile, line $breakloc\." \
62     "set breakpoint on char_func"
63 gdb_continue_to_breakpoint "char_func" ".*/$srcfile:$breakloc.*"
64
65 set test_msg "finish from char_func"
66 gdb_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
78 set breakloc [gdb_get_line_number "SHORT FUNC" "$srcfile"]
79 gdb_test "break short_func" \
80     "Breakpoint $decimal at .* line $breakloc\." \
81     "set breakpoint on short_func"
82 gdb_continue_to_breakpoint "short_func" ".*/$srcfile:$breakloc.*"
83
84 set test_msg "finish from short_func"
85 gdb_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
97 set breakloc [gdb_get_line_number "INT FUNC" "$srcfile"]
98 gdb_test "break int_func" \
99     "Breakpoint $decimal at .* line $breakloc\." \
100     "set breakpoint on int_func"
101 gdb_continue_to_breakpoint "int_func" ".*/$srcfile:$breakloc.*"
102
103 set test_msg "finish from int_func"
104 gdb_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
116 set breakloc [gdb_get_line_number "LONG FUNC" "$srcfile"]
117 gdb_test "break long_func" \
118     "Breakpoint $decimal at .* line $breakloc\." \
119     "set breakpoint on long_func"
120 gdb_continue_to_breakpoint "long_func" ".*/$srcfile:$breakloc.*"
121
122 set test_msg "finish from long_func"
123 gdb_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
135 set breakloc [gdb_get_line_number "LONG LONG FUNC" "$srcfile"]
136 gdb_test "break long_long_func" \
137     "Breakpoint $decimal at .* line $breakloc\." \
138     "set breakpoint on long_long_func"
139 gdb_continue_to_breakpoint "long_long_func" ".*/$srcfile:$breakloc.*"
140
141 set test_msg "finish from long_long_func"
142 gdb_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
158 gdb_test "set exec-dir reverse" "" "set reverse execution"
159
160 # Test reverse finish from long long func
161
162 set breakloc [gdb_get_line_number "LONG LONG FUNC" "$srcfile"]
163 gdb_continue_to_breakpoint "long_long_func" ".*/$srcfile:$breakloc.*"
164
165 set test_msg "reverse finish from long_long_func"
166 gdb_test_multiple "finish" "$test_msg" {
167     -re ".* long_checkpoint.*$gdb_prompt $" {
168         pass "$test_msg"
169     }
170 }
171
172 # Test reverse finish from long func
173
174 set breakloc [gdb_get_line_number "LONG FUNC" "$srcfile"]
175 gdb_continue_to_breakpoint "long_func" ".*/$srcfile:$breakloc.*"
176
177 set test_msg "reverse finish from long_func"
178 gdb_test_multiple "finish" "$test_msg" {
179     -re ".* int_checkpoint.*$gdb_prompt $" {
180         pass "$test_msg"
181     }
182 }
183
184 # Test reverse finish from int func
185
186 set breakloc [gdb_get_line_number "INT FUNC" "$srcfile"]
187 gdb_continue_to_breakpoint "int_func" ".*/$srcfile:$breakloc.*"
188
189 set test_msg "reverse finish from int_func"
190 gdb_test_multiple "finish" "$test_msg" {
191     -re ".* short_checkpoint.*$gdb_prompt $" {
192         pass "$test_msg"
193     }
194 }
195
196 # Test reverse finish from short func
197
198 set breakloc [gdb_get_line_number "SHORT FUNC" "$srcfile"]
199 gdb_continue_to_breakpoint "short_func" ".*/$srcfile:$breakloc.*"
200
201 set test_msg "reverse finish from short_func"
202 gdb_test_multiple "finish" "$test_msg" {
203     -re ".* char_checkpoint.*$gdb_prompt $" {
204         pass "$test_msg"
205     }
206 }
207
208 # Test reverse finish from char func
209
210 set breakloc [gdb_get_line_number "CHAR FUNC" "$srcfile"]
211 gdb_continue_to_breakpoint "char_func" ".*/$srcfile:$breakloc.*"
212
213 set test_msg "reverse finish from char_func"
214 gdb_test_multiple "finish" "$test_msg" {
215     -re ".* void_checkpoint.*$gdb_prompt $" {
216         pass "$test_msg"
217     }
218 }
219
220 # Test reverse finish from void func
221
222 set breakloc [gdb_get_line_number "VOID FUNC" "$srcfile"]
223 gdb_continue_to_breakpoint "void_func" ".*/$srcfile:$breakloc.*"
224
225 set test_msg "reverse finish from void_func"
226 gdb_test_multiple "finish" "$test_msg" {
227     -re ".* call to void_func.*$gdb_prompt $" {
228         pass "$test_msg"
229     }
230 }