Re: Bug in i386_process_record?

Hui Zhu
2009-08-28T06:44:12Z

[-- Attachment #1: Type: text/plain, Size: 4367 bytes --]

On Fri, Aug 28, 2009 at 11:06, Michael Snyder<msnyder@vmware.com> wrote:
> Hui Zhu wrote:
>>
>> On Fri, Aug 28, 2009 at 09:35, Michael Snyder<msnyder@vmware.com> wrote:
>>>
>>> Hui Zhu wrote:
>>>>
>>>> On Thu, Aug 27, 2009 at 09:43, Hui Zhu<teawater@gmail.com> wrote:
>>>>>
>>>>> On Thu, Aug 27, 2009 at 08:28, Michael Snyder<msnyder@vmware.com>
>>>>> wrote:
>>>>>>
>>>>>> Do you think you could add some new tests to i386-reverse.exp,
>>>>>> to verify the string instructions?
>>>>>>
>>>>>> Thanks,
>>>>>> Michael
>>>>>>
>>>>> OK. I will do it.
>>>>>
>>>>> Thanks,
>>>>> Hui
>>>>>
>>>> Hi Michael,
>>>>
>>>> I make a patch to add the test for string insn.
>>>>
>>>> Please help me review it.
>>>
>>> Good start -- but you need to write some expect script to go with it!
>>> ;-)
>>
>> Hi Michael,
>>
>> This patch can make inferior without string_insn_patch get fail in:
>> gdb_test "continue" \
>>    " end of main .*" \
>>    "continue to end of main"
>> Prec will get error in asm volatile("rep\n" line when continue.
>>
>> Do you think I need make string_insn test  divide with inc_test in
>> expect script?
>
> My intention when I wrote the i386-reverse test was
> that it should be extended with more tests over time.
>
> In fact, I had this one in mind.   ;-)
>
> Don't worry about "without string_insn_patch", since you will
> check it in tomorrow.  You will check in this test later than
> that, so nobody will get this test unles they already have the
> string_insn_patch.

OK.

I make a new version patch that divide the inc_test and
string_insn_test. Please help me review it.

Thanks,
Hui

2009-08-28 Hui Zhu <teawater@gmail.com>

* gdb.reverse/i386-reverse.c (string_insn_tests): New function.
(main): Call "string_insn_tests".
* gdb.reverse/i386-reverse.exp: Add test for string insn.

---
testsuite/gdb.reverse/i386-reverse.c | 16 ++++++++++++++++
testsuite/gdb.reverse/i386-reverse.exp | 27 +++++++++++++++++----------
2 files changed, 33 insertions(+), 10 deletions(-)

--- a/testsuite/gdb.reverse/i386-reverse.c
+++ b/testsuite/gdb.reverse/i386-reverse.c
@@ -38,9 +38,25 @@ inc_dec_tests (void)
asm ("dec %edi");
} /* end inc_dec_tests */

+void
+string_insn_tests (void)
+{
+ register char x asm("ax");
+ char *dstp = (char *) 1;
+ int d0;
+ int len = 0;
+
+ asm volatile("rep\n"
+ "stosb" /* %0, %2, %3 */ :
+ "=D" (dstp), "=c" (d0) :
+ "0" (dstp), "1" (len), "a" (x) :
+ "memory");
+} /* end string_insn_tests */
+
int
main ()
{
inc_dec_tests ();
+ string_insn_tests ();
return 0; /* end of main */
}
--- a/testsuite/gdb.reverse/i386-reverse.exp
+++ b/testsuite/gdb.reverse/i386-reverse.exp
@@ -53,6 +53,7 @@ if { [gdb_compile "${srcdir}/${subdir}/$

set end_of_main [gdb_get_line_number " end of main "]
set end_of_inc_dec_tests [gdb_get_line_number " end inc_dec_tests "]
+set string_insn_tests [gdb_get_line_number " end string_insn_tests "]

# Get things started.

@@ -201,21 +202,13 @@ gdb_expect {

# gdb_test "step" "end inc_dec_tests .*" "step to end inc_dec_tests 1st time"

-gdb_test "break $end_of_main" \
- "Breakpoint $decimal at .* line $end_of_main\." \
- "set breakpoint at end of main"
-
-gdb_test "continue" \
- " end of main .*" \
- "continue to end of main"
-
gdb_test "break $end_of_inc_dec_tests" \
"Breakpoint $decimal at .* line $end_of_inc_dec_tests\." \
"set breakpoint at end of inc_dec_tests"

-gdb_test "reverse-continue" \
+gdb_test "continue" \
" end inc_dec_tests .*" \
- "reverse to inc_dec_tests"
+ "continue to inc_dec_tests"

#
# Now reverse step, and check register values.
@@ -285,4 +278,18 @@ gdb_test "info reg eax" "eax *$predec_ea
gdb_test "reverse-step" "inc .eax.*" "reverse-step to inc eax"
gdb_test "info reg eax" "eax *$preinc_eax\t.*" "eax after reverse-inc"

+gdb_test "continue" \
+ " end inc_dec_tests .*" \
+ "continue to inc_dec_tests"

+#
+# Test string instruction.
+#
+
+gdb_test "break $string_insn_tests" \
+ "Breakpoint $decimal at .* line $string_insn_tests\." \
+ "set breakpoint at end of string_insn_tests"
+
+gdb_test "continue" \
+ " end string_insn_tests .*" \
+ "continue to inc_dec_tests"

[-- Attachment #2: prec-testsuite-string-insn.txt --]
[-- Type: text/plain, Size: 2418 bytes --]

---
testsuite/gdb.reverse/i386-reverse.c | 16 ++++++++++++++++
testsuite/gdb.reverse/i386-reverse.exp | 27 +++++++++++++++++----------
2 files changed, 33 insertions(+), 10 deletions(-)

--- a/testsuite/gdb.reverse/i386-reverse.c
+++ b/testsuite/gdb.reverse/i386-reverse.c
@@ -38,9 +38,25 @@ inc_dec_tests (void)
asm ("dec %edi");
} /* end inc_dec_tests */

+void
+string_insn_tests (void)
+{
+ register char x asm("ax");
+ char *dstp = (char *) 1;
+ int d0;
+ int len = 0;
+
+ asm volatile("rep\n"
+ "stosb" /* %0, %2, %3 */ :
+ "=D" (dstp), "=c" (d0) :
+ "0" (dstp), "1" (len), "a" (x) :
+ "memory");
+} /* end string_insn_tests */
+
int
main ()
{
inc_dec_tests ();
+ string_insn_tests ();
return 0; /* end of main */
}
--- a/testsuite/gdb.reverse/i386-reverse.exp
+++ b/testsuite/gdb.reverse/i386-reverse.exp
@@ -53,6 +53,7 @@ if { [gdb_compile "${srcdir}/${subdir}/$

set end_of_main [gdb_get_line_number " end of main "]
set end_of_inc_dec_tests [gdb_get_line_number " end inc_dec_tests "]
+set string_insn_tests [gdb_get_line_number " end string_insn_tests "]

# Get things started.

@@ -201,21 +202,13 @@ gdb_expect {

# gdb_test "step" "end inc_dec_tests .*" "step to end inc_dec_tests 1st time"

-gdb_test "break $end_of_main" \
- "Breakpoint $decimal at .* line $end_of_main\." \
- "set breakpoint at end of main"
-
-gdb_test "continue" \
- " end of main .*" \
- "continue to end of main"
-
gdb_test "break $end_of_inc_dec_tests" \
"Breakpoint $decimal at .* line $end_of_inc_dec_tests\." \
"set breakpoint at end of inc_dec_tests"

-gdb_test "reverse-continue" \
+gdb_test "continue" \
" end inc_dec_tests .*" \
- "reverse to inc_dec_tests"
+ "continue to inc_dec_tests"

#
# Now reverse step, and check register values.
@@ -285,4 +278,18 @@ gdb_test "info reg eax" "eax *$predec_ea
gdb_test "reverse-step" "inc .eax.*" "reverse-step to inc eax"
gdb_test "info reg eax" "eax *$preinc_eax\t.*" "eax after reverse-inc"

+gdb_test "continue" \
+ " end inc_dec_tests .*" \
+ "continue to inc_dec_tests"

+#
+# Test string instruction.
+#
+
+gdb_test "break $string_insn_tests" \
+ "Breakpoint $decimal at .* line $string_insn_tests\." \
+ "set breakpoint at end of string_insn_tests"
+
+gdb_test "continue" \
+ " end string_insn_tests .*" \
+ "continue to inc_dec_tests"