1 |
227 |
jeremybenn |
# Copyright 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 .
|
15 |
|
|
|
16 |
|
|
# This file is part of the gdb testsuite.
|
17 |
|
|
|
18 |
|
|
#
|
19 |
|
|
# This test tests some i386 general instructions with a precord dumpfile.
|
20 |
|
|
#
|
21 |
|
|
|
22 |
|
|
# This test suitable only for process record-replay
|
23 |
|
|
if ![target_info exists gdb,use_precord] {
|
24 |
|
|
return
|
25 |
|
|
}
|
26 |
|
|
|
27 |
|
|
if $tracelevel {
|
28 |
|
|
strace $tracelevel
|
29 |
|
|
}
|
30 |
|
|
|
31 |
|
|
set prms_id 0
|
32 |
|
|
set bug_id 0
|
33 |
|
|
|
34 |
|
|
if ![istarget "i?86-*linux*"] then {
|
35 |
|
|
verbose "Skipping i386 reverse tests."
|
36 |
|
|
return
|
37 |
|
|
}
|
38 |
|
|
|
39 |
|
|
set testfile "i386-reverse"
|
40 |
|
|
set srcfile ${testfile}.c
|
41 |
|
|
set binfile ${objdir}/${subdir}/${testfile}
|
42 |
|
|
|
43 |
|
|
# some targets have leading underscores on assembly symbols.
|
44 |
|
|
# TODO: detect this automatically
|
45 |
|
|
set additional_flags ""
|
46 |
|
|
if [istarget "i?86-*-cygwin*"] then {
|
47 |
|
|
set additional_flags "additional_flags=-DSYMBOL_PREFIX=\"_\""
|
48 |
|
|
}
|
49 |
|
|
|
50 |
|
|
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug $additional_flags]] != "" } {
|
51 |
|
|
untested i386-reverse
|
52 |
|
|
return -1
|
53 |
|
|
}
|
54 |
|
|
|
55 |
|
|
set end_of_main [gdb_get_line_number " end of main "]
|
56 |
|
|
set end_of_inc_dec_tests [gdb_get_line_number " end inc_dec_tests "]
|
57 |
|
|
|
58 |
|
|
# Get things started.
|
59 |
|
|
|
60 |
|
|
gdb_exit
|
61 |
|
|
gdb_start
|
62 |
|
|
gdb_reinitialize_dir $srcdir/$subdir
|
63 |
|
|
gdb_load ${binfile}
|
64 |
|
|
runto main
|
65 |
|
|
|
66 |
|
|
if [target_info exists gdb,use_precord] {
|
67 |
|
|
# Activate process record/replay
|
68 |
|
|
gdb_test "record" "" "Turn on process record"
|
69 |
|
|
# FIXME: command ought to acknowledge, so we can test if it succeeded.
|
70 |
|
|
}
|
71 |
|
|
|
72 |
|
|
global hex
|
73 |
|
|
global decimal
|
74 |
|
|
|
75 |
|
|
gdb_test "break $end_of_main" \
|
76 |
|
|
"Breakpoint $decimal at .*/$srcfile, line $end_of_main\." \
|
77 |
|
|
"BP at end of main"
|
78 |
|
|
|
79 |
|
|
gdb_test "continue" "Breakpoint .* end of main .*" "run to end of main"
|
80 |
|
|
|
81 |
|
|
gdb_test "record save i386.precsave" \
|
82 |
|
|
"Saved core file i386.precsave with execution log\." \
|
83 |
|
|
"save process recfile"
|
84 |
|
|
|
85 |
|
|
gdb_test "kill" "" "Kill process, prepare to debug log file" \
|
86 |
|
|
"Kill the program being debugged\\? \\(y or n\\) " "y"
|
87 |
|
|
|
88 |
|
|
gdb_test "record restore i386.precsave" \
|
89 |
|
|
"Program terminated with signal .*" \
|
90 |
|
|
"reload precord save file"
|
91 |
|
|
|
92 |
|
|
gdb_test "step" "inc .eax.*" "step to inc eax 1st time"
|
93 |
|
|
send_gdb "info reg eax\n"
|
94 |
|
|
gdb_expect {
|
95 |
|
|
-re "eax *($hex)\t.*$gdb_prompt " {
|
96 |
|
|
set preinc_eax $expect_out(1,string)
|
97 |
|
|
}
|
98 |
|
|
}
|
99 |
|
|
|
100 |
|
|
gdb_test "step" "inc .ecx.*" "step to inc ecx 1st time"
|
101 |
|
|
send_gdb "info reg ecx\n"
|
102 |
|
|
gdb_expect {
|
103 |
|
|
-re "ecx *($hex)\t.*$gdb_prompt " {
|
104 |
|
|
set preinc_ecx $expect_out(1,string)
|
105 |
|
|
}
|
106 |
|
|
}
|
107 |
|
|
|
108 |
|
|
gdb_test "step" "inc .edx.*" "step to inc edx 1st time"
|
109 |
|
|
send_gdb "info reg edx\n"
|
110 |
|
|
gdb_expect {
|
111 |
|
|
-re "edx *($hex)\t.*$gdb_prompt " {
|
112 |
|
|
set preinc_edx $expect_out(1,string)
|
113 |
|
|
}
|
114 |
|
|
}
|
115 |
|
|
|
116 |
|
|
gdb_test "step" "inc .ebx.*" "step to inc ebx 1st time"
|
117 |
|
|
send_gdb "info reg ebx\n"
|
118 |
|
|
gdb_expect {
|
119 |
|
|
-re "ebx *($hex)\t.*$gdb_prompt " {
|
120 |
|
|
set preinc_ebx $expect_out(1,string)
|
121 |
|
|
}
|
122 |
|
|
}
|
123 |
|
|
|
124 |
|
|
gdb_test "step" "inc .esp.*" "step to inc esp 1st time"
|
125 |
|
|
send_gdb "info reg esp\n"
|
126 |
|
|
gdb_expect {
|
127 |
|
|
-re "esp *($hex)\t.*$gdb_prompt " {
|
128 |
|
|
set preinc_esp $expect_out(1,string)
|
129 |
|
|
}
|
130 |
|
|
}
|
131 |
|
|
|
132 |
|
|
gdb_test "step" "inc .ebp.*" "step to inc ebp 1st time"
|
133 |
|
|
send_gdb "info reg ebp\n"
|
134 |
|
|
gdb_expect {
|
135 |
|
|
-re "ebp *($hex)\t.*$gdb_prompt " {
|
136 |
|
|
set preinc_ebp $expect_out(1,string)
|
137 |
|
|
}
|
138 |
|
|
}
|
139 |
|
|
|
140 |
|
|
gdb_test "step" "inc .esi.*" "step to inc esi 1st time"
|
141 |
|
|
send_gdb "info reg esi\n"
|
142 |
|
|
gdb_expect {
|
143 |
|
|
-re "esi *($hex)\t.*$gdb_prompt " {
|
144 |
|
|
set preinc_esi $expect_out(1,string)
|
145 |
|
|
}
|
146 |
|
|
}
|
147 |
|
|
|
148 |
|
|
gdb_test "step" "inc .edi.*" "step to inc edi 1st time"
|
149 |
|
|
send_gdb "info reg edi\n"
|
150 |
|
|
gdb_expect {
|
151 |
|
|
-re "edi *($hex)\t.*$gdb_prompt " {
|
152 |
|
|
set preinc_edi $expect_out(1,string)
|
153 |
|
|
}
|
154 |
|
|
}
|
155 |
|
|
|
156 |
|
|
gdb_test "step" "dec .eax.*" "step to dec eax 1st time"
|
157 |
|
|
send_gdb "info reg eax\n"
|
158 |
|
|
gdb_expect {
|
159 |
|
|
-re "eax *($hex)\t.*$gdb_prompt " {
|
160 |
|
|
set predec_eax $expect_out(1,string)
|
161 |
|
|
}
|
162 |
|
|
}
|
163 |
|
|
|
164 |
|
|
gdb_test "step" "dec .ecx.*" "step to dec ecx 1st time"
|
165 |
|
|
send_gdb "info reg ecx\n"
|
166 |
|
|
gdb_expect {
|
167 |
|
|
-re "ecx *($hex)\t.*$gdb_prompt " {
|
168 |
|
|
set predec_ecx $expect_out(1,string)
|
169 |
|
|
}
|
170 |
|
|
}
|
171 |
|
|
|
172 |
|
|
gdb_test "step" "dec .edx.*" "step to dec edx 1st time"
|
173 |
|
|
send_gdb "info reg edx\n"
|
174 |
|
|
gdb_expect {
|
175 |
|
|
-re "edx *($hex)\t.*$gdb_prompt " {
|
176 |
|
|
set predec_edx $expect_out(1,string)
|
177 |
|
|
}
|
178 |
|
|
}
|
179 |
|
|
|
180 |
|
|
gdb_test "step" "dec .ebx.*" "step to dec ebx 1st time"
|
181 |
|
|
send_gdb "info reg ebx\n"
|
182 |
|
|
gdb_expect {
|
183 |
|
|
-re "ebx *($hex)\t.*$gdb_prompt " {
|
184 |
|
|
set predec_ebx $expect_out(1,string)
|
185 |
|
|
}
|
186 |
|
|
}
|
187 |
|
|
|
188 |
|
|
gdb_test "step" "dec .esp.*" "step to dec esp 1st time"
|
189 |
|
|
send_gdb "info reg esp\n"
|
190 |
|
|
gdb_expect {
|
191 |
|
|
-re "esp *($hex)\t.*$gdb_prompt " {
|
192 |
|
|
set predec_esp $expect_out(1,string)
|
193 |
|
|
}
|
194 |
|
|
}
|
195 |
|
|
|
196 |
|
|
gdb_test "step" "dec .ebp.*" "step to dec ebp 1st time"
|
197 |
|
|
send_gdb "info reg ebp\n"
|
198 |
|
|
gdb_expect {
|
199 |
|
|
-re "ebp *($hex)\t.*$gdb_prompt " {
|
200 |
|
|
set predec_ebp $expect_out(1,string)
|
201 |
|
|
}
|
202 |
|
|
}
|
203 |
|
|
|
204 |
|
|
gdb_test "step" "dec .esi.*" "step to dec esi 1st time"
|
205 |
|
|
send_gdb "info reg esi\n"
|
206 |
|
|
gdb_expect {
|
207 |
|
|
-re "esi *($hex)\t.*$gdb_prompt " {
|
208 |
|
|
set predec_esi $expect_out(1,string)
|
209 |
|
|
}
|
210 |
|
|
}
|
211 |
|
|
|
212 |
|
|
gdb_test "step" "dec .edi.*" "step to dec edi 1st time"
|
213 |
|
|
send_gdb "info reg edi\n"
|
214 |
|
|
gdb_expect {
|
215 |
|
|
-re "edi *($hex)\t.*$gdb_prompt " {
|
216 |
|
|
set predec_edi $expect_out(1,string)
|
217 |
|
|
}
|
218 |
|
|
}
|
219 |
|
|
|
220 |
|
|
# gdb_test "step" "end inc_dec_tests .*" "step to end inc_dec_tests 1st time"
|
221 |
|
|
|
222 |
|
|
gdb_test "break $end_of_main" \
|
223 |
|
|
"Breakpoint $decimal at .* line $end_of_main\." \
|
224 |
|
|
"set breakpoint at end of main"
|
225 |
|
|
|
226 |
|
|
gdb_test "continue" \
|
227 |
|
|
" end of main .*" \
|
228 |
|
|
"continue to end of main"
|
229 |
|
|
|
230 |
|
|
gdb_test "break $end_of_inc_dec_tests" \
|
231 |
|
|
"Breakpoint $decimal at .* line $end_of_inc_dec_tests\." \
|
232 |
|
|
"set breakpoint at end of inc_dec_tests"
|
233 |
|
|
|
234 |
|
|
gdb_test "reverse-continue" \
|
235 |
|
|
" end inc_dec_tests .*" \
|
236 |
|
|
"reverse to inc_dec_tests"
|
237 |
|
|
|
238 |
|
|
#
|
239 |
|
|
# Now reverse step, and check register values.
|
240 |
|
|
#
|
241 |
|
|
|
242 |
|
|
gdb_test "info reg edi" "edi *$preinc_edi\t.*" "edi before reverse-dec"
|
243 |
|
|
gdb_test "reverse-step" "dec .edi.*" "reverse-step to dec edi"
|
244 |
|
|
gdb_test "info reg edi" "edi *$predec_edi\t.*" "edi after reverse-dec"
|
245 |
|
|
|
246 |
|
|
gdb_test "info reg esi" "esi *$preinc_esi\t.*" "esi before reverse-dec"
|
247 |
|
|
gdb_test "reverse-step" "dec .esi.*" "reverse-step to dec esi"
|
248 |
|
|
gdb_test "info reg esi" "esi *$predec_esi\t.*" "esi after reverse-dec"
|
249 |
|
|
|
250 |
|
|
gdb_test "info reg ebp" "ebp *$preinc_ebp\t.*" "ebp before reverse-dec"
|
251 |
|
|
gdb_test "reverse-step" "dec .ebp.*" "reverse-step to dec ebp"
|
252 |
|
|
gdb_test "info reg ebp" "ebp *$predec_ebp\t.*" "ebp after reverse-dec"
|
253 |
|
|
|
254 |
|
|
gdb_test "info reg esp" "esp *$preinc_esp\t.*" "esp before reverse-dec"
|
255 |
|
|
gdb_test "reverse-step" "dec .esp.*" "reverse-step to dec esp"
|
256 |
|
|
gdb_test "info reg esp" "esp *$predec_esp\t.*" "esp after reverse-dec"
|
257 |
|
|
|
258 |
|
|
gdb_test "info reg ebx" "ebx *$preinc_ebx\t.*" "ebx before reverse-dec"
|
259 |
|
|
gdb_test "reverse-step" "dec .ebx.*" "reverse-step to dec ebx"
|
260 |
|
|
gdb_test "info reg ebx" "ebx *$predec_ebx\t.*" "ebx after reverse-dec"
|
261 |
|
|
|
262 |
|
|
gdb_test "info reg edx" "edx *$preinc_edx\t.*" "edx before reverse-dec"
|
263 |
|
|
gdb_test "reverse-step" "dec .edx.*" "reverse-step to dec edx"
|
264 |
|
|
gdb_test "info reg edx" "edx *$predec_edx\t.*" "edx after reverse-dec"
|
265 |
|
|
|
266 |
|
|
gdb_test "info reg ecx" "ecx *$preinc_ecx\t.*" "ecx before reverse-dec"
|
267 |
|
|
gdb_test "reverse-step" "dec .ecx.*" "reverse-step to dec ecx"
|
268 |
|
|
gdb_test "info reg ecx" "ecx *$predec_ecx\t.*" "ecx after reverse-dec"
|
269 |
|
|
|
270 |
|
|
gdb_test "info reg eax" "eax *$preinc_eax\t.*" "eax before reverse-dec"
|
271 |
|
|
gdb_test "reverse-step" "dec .eax.*" "reverse-step to dec eax"
|
272 |
|
|
gdb_test "info reg eax" "eax *$predec_eax\t.*" "eax after reverse-dec"
|
273 |
|
|
|
274 |
|
|
gdb_test "info reg edi" "edi *$predec_edi\t.*" "edi before reverse-inc"
|
275 |
|
|
gdb_test "reverse-step" "inc .edi.*" "reverse-step to inc edi"
|
276 |
|
|
gdb_test "info reg edi" "edi *$preinc_edi\t.*" "edi after reverse-inc"
|
277 |
|
|
|
278 |
|
|
gdb_test "info reg esi" "esi *$predec_esi\t.*" "esi before reverse-inc"
|
279 |
|
|
gdb_test "reverse-step" "inc .esi.*" "reverse-step to inc esi"
|
280 |
|
|
gdb_test "info reg esi" "esi *$preinc_esi\t.*" "esi after reverse-inc"
|
281 |
|
|
|
282 |
|
|
gdb_test "info reg ebp" "ebp *$predec_ebp\t.*" "ebp before reverse-inc"
|
283 |
|
|
gdb_test "reverse-step" "inc .ebp.*" "reverse-step to inc ebp"
|
284 |
|
|
gdb_test "info reg ebp" "ebp *$preinc_ebp\t.*" "ebp after reverse-inc"
|
285 |
|
|
|
286 |
|
|
gdb_test "info reg esp" "esp *$predec_esp\t.*" "esp before reverse-inc"
|
287 |
|
|
gdb_test "reverse-step" "inc .esp.*" "reverse-step to inc esp"
|
288 |
|
|
gdb_test "info reg esp" "esp *$preinc_esp\t.*" "esp after reverse-inc"
|
289 |
|
|
|
290 |
|
|
gdb_test "info reg ebx" "ebx *$predec_ebx\t.*" "ebx before reverse-inc"
|
291 |
|
|
gdb_test "reverse-step" "inc .ebx.*" "reverse-step to inc ebx"
|
292 |
|
|
gdb_test "info reg ebx" "ebx *$preinc_ebx\t.*" "ebx after reverse-inc"
|
293 |
|
|
|
294 |
|
|
gdb_test "info reg edx" "edx *$predec_edx\t.*" "edx before reverse-inc"
|
295 |
|
|
gdb_test "reverse-step" "inc .edx.*" "reverse-step to inc edx"
|
296 |
|
|
gdb_test "info reg edx" "edx *$preinc_edx\t.*" "edx after reverse-inc"
|
297 |
|
|
|
298 |
|
|
gdb_test "info reg ecx" "ecx *$predec_ecx\t.*" "ecx before reverse-inc"
|
299 |
|
|
gdb_test "reverse-step" "inc .ecx.*" "reverse-step to inc ecx"
|
300 |
|
|
gdb_test "info reg ecx" "ecx *$preinc_ecx\t.*" "ecx after reverse-inc"
|
301 |
|
|
|
302 |
|
|
gdb_test "info reg eax" "eax *$predec_eax\t.*" "eax before reverse-inc"
|
303 |
|
|
gdb_test "reverse-step" "inc .eax.*" "reverse-step to inc eax"
|
304 |
|
|
gdb_test "info reg eax" "eax *$preinc_eax\t.*" "eax after reverse-inc"
|
305 |
|
|
|
306 |
|
|
|