1 # Copyright 2009-2019 Free Software Foundation, Inc.
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.
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.
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/>.
16 # This file is part of the gdb testsuite.
19 # This test tests some i386 general instructions with a precord dumpfile.
22 # This test suitable only for process record-replay
23 if ![supports_process_record] {
28 if ![istarget "i?86-*linux*"] then {
29 verbose "Skipping i386 reverse tests."
33 standard_testfile i386-reverse.c
34 set precsave [standard_output_file i386.precsave]
36 # some targets have leading underscores on assembly symbols.
37 set additional_flags [gdb_target_symbol_prefix_flags]
39 if {[prepare_for_testing "failed to prepare" $testfile $srcfile \
40 [list debug $additional_flags]]} {
44 set end_of_main [gdb_get_line_number " end of main "]
45 set end_of_inc_dec_tests [gdb_get_line_number " end inc_dec_tests "]
49 if [supports_process_record] {
50 # Activate process record/replay
51 gdb_test_no_output "record" "turn on process record"
57 gdb_test "break $end_of_main" \
58 "Breakpoint $decimal at .*$srcfile, line $end_of_main\." \
59 "breakpoint at end of main"
61 gdb_test "continue" "Breakpoint .* end of main .*" "run to end of main"
63 gdb_test "record save $precsave" \
64 "Saved core file $precsave with execution log\." \
65 "save process recfile"
67 gdb_test "kill" "" "kill process, prepare to debug log file" \
68 "Kill the program being debugged\\? \\(y or n\\) " "y"
70 gdb_test "record restore $precsave" \
71 "Restored records from core file .*" \
72 "reload precord save file"
74 gdb_test "step" "inc .eax.*" "step to inc eax 1st time"
75 send_gdb "info reg eax\n"
77 -re "eax *($hex)\[ \t\]+.*$gdb_prompt " {
78 set preinc_eax $expect_out(1,string)
82 gdb_test "step" "inc .ecx.*" "step to inc ecx 1st time"
83 send_gdb "info reg ecx\n"
85 -re "ecx *($hex)\[ \t\]+.*$gdb_prompt " {
86 set preinc_ecx $expect_out(1,string)
90 gdb_test "step" "inc .edx.*" "step to inc edx 1st time"
91 send_gdb "info reg edx\n"
93 -re "edx *($hex)\[ \t\]+.*$gdb_prompt " {
94 set preinc_edx $expect_out(1,string)
98 gdb_test "step" "inc .ebx.*" "step to inc ebx 1st time"
99 send_gdb "info reg ebx\n"
101 -re "ebx *($hex)\[ \t\]+.*$gdb_prompt " {
102 set preinc_ebx $expect_out(1,string)
106 gdb_test "step" "inc .esp.*" "step to inc esp 1st time"
107 send_gdb "info reg esp\n"
109 -re "esp *($hex)\[ \t\]+.*$gdb_prompt " {
110 set preinc_esp $expect_out(1,string)
114 gdb_test "step" "inc .ebp.*" "step to inc ebp 1st time"
115 send_gdb "info reg ebp\n"
117 -re "ebp *($hex)\[ \t\]+.*$gdb_prompt " {
118 set preinc_ebp $expect_out(1,string)
122 gdb_test "step" "inc .esi.*" "step to inc esi 1st time"
123 send_gdb "info reg esi\n"
125 -re "esi *($hex)\[ \t\]+.*$gdb_prompt " {
126 set preinc_esi $expect_out(1,string)
130 gdb_test "step" "inc .edi.*" "step to inc edi 1st time"
131 send_gdb "info reg edi\n"
133 -re "edi *($hex)\[ \t\]+.*$gdb_prompt " {
134 set preinc_edi $expect_out(1,string)
138 gdb_test "step" "dec .eax.*" "step to dec eax 1st time"
139 send_gdb "info reg eax\n"
141 -re "eax *($hex)\[ \t\]+.*$gdb_prompt " {
142 set predec_eax $expect_out(1,string)
146 gdb_test "step" "dec .ecx.*" "step to dec ecx 1st time"
147 send_gdb "info reg ecx\n"
149 -re "ecx *($hex)\[ \t\]+.*$gdb_prompt " {
150 set predec_ecx $expect_out(1,string)
154 gdb_test "step" "dec .edx.*" "step to dec edx 1st time"
155 send_gdb "info reg edx\n"
157 -re "edx *($hex)\[ \t\]+.*$gdb_prompt " {
158 set predec_edx $expect_out(1,string)
162 gdb_test "step" "dec .ebx.*" "step to dec ebx 1st time"
163 send_gdb "info reg ebx\n"
165 -re "ebx *($hex)\[ \t\]+.*$gdb_prompt " {
166 set predec_ebx $expect_out(1,string)
170 gdb_test "step" "dec .esp.*" "step to dec esp 1st time"
171 send_gdb "info reg esp\n"
173 -re "esp *($hex)\[ \t\]+.*$gdb_prompt " {
174 set predec_esp $expect_out(1,string)
178 gdb_test "step" "dec .ebp.*" "step to dec ebp 1st time"
179 send_gdb "info reg ebp\n"
181 -re "ebp *($hex)\[ \t\]+.*$gdb_prompt " {
182 set predec_ebp $expect_out(1,string)
186 gdb_test "step" "dec .esi.*" "step to dec esi 1st time"
187 send_gdb "info reg esi\n"
189 -re "esi *($hex)\[ \t\]+.*$gdb_prompt " {
190 set predec_esi $expect_out(1,string)
194 gdb_test "step" "dec .edi.*" "step to dec edi 1st time"
195 send_gdb "info reg edi\n"
197 -re "edi *($hex)\[ \t\]+.*$gdb_prompt " {
198 set predec_edi $expect_out(1,string)
202 # gdb_test "step" "end inc_dec_tests .*" "step to end inc_dec_tests 1st time"
204 gdb_test "break $end_of_main" \
205 "Breakpoint $decimal at .* line $end_of_main\." \
206 "set breakpoint at end of main"
208 gdb_test "continue" \
210 "continue to end of main"
212 gdb_test "break $end_of_inc_dec_tests" \
213 "Breakpoint $decimal at .* line $end_of_inc_dec_tests\." \
214 "set breakpoint at end of inc_dec_tests"
216 gdb_test "reverse-continue" \
217 " end inc_dec_tests .*" \
218 "reverse to inc_dec_tests"
221 # Now reverse step, and check register values.
224 gdb_test "info reg edi" "edi *$preinc_edi\[ \t\]+.*" "edi before reverse-dec"
225 gdb_test "reverse-step" "dec .edi.*" "reverse-step to dec edi"
226 gdb_test "info reg edi" "edi *$predec_edi\[ \t\]+.*" "edi after reverse-dec"
228 gdb_test "info reg esi" "esi *$preinc_esi\[ \t\]+.*" "esi before reverse-dec"
229 gdb_test "reverse-step" "dec .esi.*" "reverse-step to dec esi"
230 gdb_test "info reg esi" "esi *$predec_esi\[ \t\]+.*" "esi after reverse-dec"
232 gdb_test "info reg ebp" "ebp *$preinc_ebp\[ \t\]+.*" "ebp before reverse-dec"
233 gdb_test "reverse-step" "dec .ebp.*" "reverse-step to dec ebp"
234 gdb_test "info reg ebp" "ebp *$predec_ebp\[ \t\]+.*" "ebp after reverse-dec"
236 gdb_test "info reg esp" "esp *$preinc_esp\[ \t\]+.*" "esp before reverse-dec"
237 gdb_test "reverse-step" "dec .esp.*" "reverse-step to dec esp"
238 gdb_test "info reg esp" "esp *$predec_esp\[ \t\]+.*" "esp after reverse-dec"
240 gdb_test "info reg ebx" "ebx *$preinc_ebx\[ \t\]+.*" "ebx before reverse-dec"
241 gdb_test "reverse-step" "dec .ebx.*" "reverse-step to dec ebx"
242 gdb_test "info reg ebx" "ebx *$predec_ebx\[ \t\]+.*" "ebx after reverse-dec"
244 gdb_test "info reg edx" "edx *$preinc_edx\[ \t\]+.*" "edx before reverse-dec"
245 gdb_test "reverse-step" "dec .edx.*" "reverse-step to dec edx"
246 gdb_test "info reg edx" "edx *$predec_edx\[ \t\]+.*" "edx after reverse-dec"
248 gdb_test "info reg ecx" "ecx *$preinc_ecx\[ \t\]+.*" "ecx before reverse-dec"
249 gdb_test "reverse-step" "dec .ecx.*" "reverse-step to dec ecx"
250 gdb_test "info reg ecx" "ecx *$predec_ecx\[ \t\]+.*" "ecx after reverse-dec"
252 gdb_test "info reg eax" "eax *$preinc_eax\[ \t\]+.*" "eax before reverse-dec"
253 gdb_test "reverse-step" "dec .eax.*" "reverse-step to dec eax"
254 gdb_test "info reg eax" "eax *$predec_eax\[ \t\]+.*" "eax after reverse-dec"
256 gdb_test "info reg edi" "edi *$predec_edi\[ \t\]+.*" "edi before reverse-inc"
257 gdb_test "reverse-step" "inc .edi.*" "reverse-step to inc edi"
258 gdb_test "info reg edi" "edi *$preinc_edi\[ \t\]+.*" "edi after reverse-inc"
260 gdb_test "info reg esi" "esi *$predec_esi\[ \t\]+.*" "esi before reverse-inc"
261 gdb_test "reverse-step" "inc .esi.*" "reverse-step to inc esi"
262 gdb_test "info reg esi" "esi *$preinc_esi\[ \t\]+.*" "esi after reverse-inc"
264 gdb_test "info reg ebp" "ebp *$predec_ebp\[ \t\]+.*" "ebp before reverse-inc"
265 gdb_test "reverse-step" "inc .ebp.*" "reverse-step to inc ebp"
266 gdb_test "info reg ebp" "ebp *$preinc_ebp\[ \t\]+.*" "ebp after reverse-inc"
268 gdb_test "info reg esp" "esp *$predec_esp\[ \t\]+.*" "esp before reverse-inc"
269 gdb_test "reverse-step" "inc .esp.*" "reverse-step to inc esp"
270 gdb_test "info reg esp" "esp *$preinc_esp\[ \t\]+.*" "esp after reverse-inc"
272 gdb_test "info reg ebx" "ebx *$predec_ebx\[ \t\]+.*" "ebx before reverse-inc"
273 gdb_test "reverse-step" "inc .ebx.*" "reverse-step to inc ebx"
274 gdb_test "info reg ebx" "ebx *$preinc_ebx\[ \t\]+.*" "ebx after reverse-inc"
276 gdb_test "info reg edx" "edx *$predec_edx\[ \t\]+.*" "edx before reverse-inc"
277 gdb_test "reverse-step" "inc .edx.*" "reverse-step to inc edx"
278 gdb_test "info reg edx" "edx *$preinc_edx\[ \t\]+.*" "edx after reverse-inc"
280 gdb_test "info reg ecx" "ecx *$predec_ecx\[ \t\]+.*" "ecx before reverse-inc"
281 gdb_test "reverse-step" "inc .ecx.*" "reverse-step to inc ecx"
282 gdb_test "info reg ecx" "ecx *$preinc_ecx\[ \t\]+.*" "ecx after reverse-inc"
284 gdb_test "info reg eax" "eax *$predec_eax\[ \t\]+.*" "eax before reverse-inc"
285 gdb_test "reverse-step" "inc .eax.*" "reverse-step to inc eax"
286 gdb_test "info reg eax" "eax *$preinc_eax\[ \t\]+.*" "eax after reverse-inc"