From: Michael Snyder <msnyder@vmware.com>
To: Hui Zhu <teawater@gmail.com>
Cc: gdb-patches ml <gdb-patches@sourceware.org>
Subject: Re: Bug in i386_process_record?
Date: Mon, 10 Aug 2009 22:12:00 -0000 [thread overview]
Message-ID: <4A8097B4.2080709@vmware.com> (raw)
In-Reply-To: <daef60380908100150k7693a835x544c3a8be033d144@mail.gmail.com>
Yes, this seems to be better. It records only 4 bytes each time
it is called.
But there seems to be still an off-by-one error? With the test
program that I provided, we call memset with an argument of
1024, but we actually record 1025 bytes... this code gets hit
257 times, with the last time recording only 1 byte.
Hui Zhu wrote:
> On Fri, Aug 7, 2009 at 11:39, Michael Snyder<msnyder@vmware.com> wrote:
>> Hi Hui,
>>
>> While experimenting with your dump/load commands, I think I discovered
>> a bug in i386_process_record, in the handling of the "string ops"
>> and the "rep" prefix. Looks like we are saving the same data over
>> and over in the log.
>>
>> This was made using the attached sample program.
>>
>> (gdb) break main
>> Breakpoint 1 at 0x80483c4: file memrange-reverse.c, line 29.
>> (gdb) run
>> Starting program:
>> Breakpoint 1, main ()
>> 29 memset (blob1, 'a', sizeof (blob1));
>> (gdb) record
>> (gdb) next
>> 30 blob1[sizeof (blob1) - 1] = '\0';
>> (gdb) record dump
>> Saving recording to file 'rec.27255'
>> Writing 4-byte magic cookie RECORD_FILE_MAGIC (0x26070920)
>> [...]
>> Writing register 7 val 0x0000000008049684 (1 plus 8 plus 16 bytes)
>> Writing memory 0x08049680 (1 plus 8 plus 8 bytes plus 1024 bytes)
>> Writing register 1 val 0x00000000000000ff (1 plus 8 plus 16 bytes)
>> Writing register 8 val 0x0000000000587be7 (1 plus 8 plus 16 bytes)
>> Writing record_end (1 byte)
>> Writing register 7 val 0x0000000008049688 (1 plus 8 plus 16 bytes)
>> Writing memory 0x08049684 (1 plus 8 plus 8 bytes plus 1020 bytes)
>> Writing register 1 val 0x00000000000000fe (1 plus 8 plus 16 bytes)
>> Writing register 8 val 0x0000000000587be7 (1 plus 8 plus 16 bytes)
>> Writing record_end (1 byte)
>> Writing register 7 val 0x000000000804968c (1 plus 8 plus 16 bytes)
>> Writing memory 0x08049688 (1 plus 8 plus 8 bytes plus 1016 bytes)
>> Writing register 1 val 0x00000000000000fd (1 plus 8 plus 16 bytes)
>> Writing register 8 val 0x0000000000587be7 (1 plus 8 plus 16 bytes)
>> Writing record_end (1 byte)
>> Writing register 7 val 0x0000000008049690 (1 plus 8 plus 16 bytes)
>> Writing memory 0x0804968c (1 plus 8 plus 8 bytes plus 1012 bytes)
>> Writing register 1 val 0x00000000000000fc (1 plus 8 plus 16 bytes)
>> Writing register 8 val 0x0000000000587be7 (1 plus 8 plus 16 bytes)
>> Writing record_end (1 byte)
>> Writing register 7 val 0x0000000008049694 (1 plus 8 plus 16 bytes)
>> Writing memory 0x08049690 (1 plus 8 plus 8 bytes plus 1008 bytes)
>> Writing register 1 val 0x00000000000000fb (1 plus 8 plus 16 bytes)
>> Writing register 8 val 0x0000000000587be7 (1 plus 8 plus 16 bytes)
>> Writing record_end (1 byte)
>> Writing register 7 val 0x0000000008049698 (1 plus 8 plus 16 bytes)
>> Writing memory 0x08049694 (1 plus 8 plus 8 bytes plus 1004 bytes)
>> Writing register 1 val 0x00000000000000fa (1 plus 8 plus 16 bytes)
>> Writing register 8 val 0x0000000000587be7 (1 plus 8 plus 16 bytes)
>> Writing record_end (1 byte)
>> Writing register 7 val 0x000000000804969c (1 plus 8 plus 16 bytes)
>> Writing memory 0x08049698 (1 plus 8 plus 8 bytes plus 1000 bytes)
>> Writing register 1 val 0x00000000000000f9 (1 plus 8 plus 16 bytes)
>> Writing register 8 val 0x0000000000587be7 (1 plus 8 plus 16 bytes)
>> Writing record_end (1 byte)
>> Writing register 7 val 0x00000000080496a0 (1 plus 8 plus 16 bytes)
>> Writing memory 0x0804969c (1 plus 8 plus 8 bytes plus 996 bytes)
>> Writing register 1 val 0x00000000000000f8 (1 plus 8 plus 16 bytes)
>> Writing register 8 val 0x0000000000587be7 (1 plus 8 plus 16 bytes)
>> [...]
>>
>> Altogether there were 256 duplicate entries, each one is
>> four bytes shorter than the previous one.
>>
>>
>
> Hi Michael,
>
> I reproduce about issue. This is because "i386_process_record" record
> rep string insn is not right.
> I make a patch for it.
>
> Please help me review it.
>
> Thanks,
> Hui
>
> 2009-08-10 Hui Zhu <teawater@gmail.com>
>
> * record.c (i386_process_record): Remove some error code.
>
> ---
> i386-tdep.c | 27 ++++-----------------------
> 1 file changed, 4 insertions(+), 23 deletions(-)
>
> --- a/i386-tdep.c
> +++ b/i386-tdep.c
> @@ -4448,9 +4448,8 @@ reswitch:
> regcache_raw_read_unsigned (ir.regcache,
> ir.regmap[X86_RECORD_REDI_REGNUM],
> &tmpulongest);
> - if (!ir.aflag)
> + if (ir.aflag)
> {
> - tmpulongest &= 0xffff;
> /* addr += ((uint32_t) read_register (I386_ES_REGNUM)) << 4; */
> if (record_debug)
> printf_unfiltered (_("Process record ignores the memory change "
> @@ -4460,27 +4459,9 @@ reswitch:
> paddress (gdbarch, ir.addr));
> }
> if (prefixes & (PREFIX_REPZ | PREFIX_REPNZ))
> - {
> - ULONGEST count, eflags;
> - regcache_raw_read_unsigned (ir.regcache,
> - ir.regmap[X86_RECORD_REDI_REGNUM],
> - &count);
> - if (!ir.aflag)
> - count &= 0xffff;
> - regcache_raw_read_unsigned (ir.regcache,
> - ir.regmap[X86_RECORD_EFLAGS_REGNUM],
> - &eflags);
> - if ((eflags >> 10) & 0x1)
> - tmpulongest -= (count - 1) * (1 << ir.ot);
> - if (record_arch_list_add_mem (tmpulongest, count * (1 << ir.ot)))
> - return -1;
> - I386_RECORD_ARCH_LIST_ADD_REG (X86_RECORD_RECX_REGNUM);
> - }
> - else
> - {
> - if (record_arch_list_add_mem (tmpulongest, 1 << ir.ot))
> - return -1;
> - }
> + I386_RECORD_ARCH_LIST_ADD_REG (X86_RECORD_RECX_REGNUM);
> + if (record_arch_list_add_mem (tmpulongest, 1 << ir.ot))
> + return -1;
> if (opcode == 0xa4 || opcode == 0xa5)
> I386_RECORD_ARCH_LIST_ADD_REG (X86_RECORD_RESI_REGNUM);
> I386_RECORD_ARCH_LIST_ADD_REG (X86_RECORD_REDI_REGNUM);
next prev parent reply other threads:[~2009-08-10 21:59 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <4A7BA1DE.6010103@vmware.com>
2009-08-10 9:33 ` Hui Zhu
2009-08-10 22:12 ` Michael Snyder [this message]
2009-08-11 6:20 ` Hui Zhu
2009-08-11 18:31 ` Hui Zhu
2009-08-16 16:12 ` Hui Zhu
2009-08-18 5:35 ` Michael Snyder
2009-08-18 11:52 ` Hui Zhu
2009-08-21 3:23 ` Hui Zhu
2009-08-23 3:15 ` Michael Snyder
2009-08-23 3:33 ` Hui Zhu
2009-08-23 4:13 ` Michael Snyder
2009-08-23 9:04 ` Hui Zhu
2009-08-23 17:37 ` Hui Zhu
2009-08-23 18:23 ` Michael Snyder
2009-08-23 18:32 ` Eli Zaretskii
2009-08-23 23:53 ` Hui Zhu
2009-08-23 23:56 ` Daniel Jacobowitz
2009-08-24 0:01 ` Hui Zhu
2009-08-24 7:46 ` Eli Zaretskii
2009-08-24 3:15 ` Hui Zhu
2009-08-24 19:20 ` Eli Zaretskii
2009-08-25 5:04 ` Hui Zhu
2009-08-25 18:45 ` Eli Zaretskii
2009-08-26 3:19 ` Hui Zhu
2009-08-26 3:27 ` Eli Zaretskii
2009-08-26 7:20 ` Hui Zhu
2009-08-26 17:37 ` Eli Zaretskii
2009-08-27 0:05 ` Michael Snyder
2009-08-27 0:32 ` Michael Snyder
2009-08-27 1:50 ` Hui Zhu
2009-08-27 15:35 ` Hui Zhu
2009-08-28 1:44 ` Michael Snyder
2009-08-28 2:14 ` Hui Zhu
2009-08-28 6:16 ` Michael Snyder
2009-08-28 8:46 ` Hui Zhu
2009-08-30 1:12 ` Michael Snyder
2009-08-27 1:44 ` Hui Zhu
2009-08-29 6:51 ` Hui Zhu
2009-08-24 20:31 ` Eli Zaretskii
2009-08-25 6:53 ` Hui Zhu
2009-08-23 18:24 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4A8097B4.2080709@vmware.com \
--to=msnyder@vmware.com \
--cc=gdb-patches@sourceware.org \
--cc=teawater@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox