From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4274 invoked by alias); 10 Aug 2009 23:49:38 -0000 Received: (qmail 4264 invoked by uid 22791); 10 Aug 2009 23:49:37 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL,BAYES_00,SARE_MSGID_LONG40,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mail-pz0-f197.google.com (HELO mail-pz0-f197.google.com) (209.85.222.197) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 10 Aug 2009 23:49:29 +0000 Received: by pzk35 with SMTP id 35so3291875pzk.24 for ; Mon, 10 Aug 2009 16:49:27 -0700 (PDT) MIME-Version: 1.0 Received: by 10.142.180.8 with SMTP id c8mr31198wff.115.1249948167092; Mon, 10 Aug 2009 16:49:27 -0700 (PDT) In-Reply-To: <4A8097B4.2080709@vmware.com> References: <4A7BA1DE.6010103@vmware.com> <4A8097B4.2080709@vmware.com> From: Hui Zhu Date: Tue, 11 Aug 2009 06:20:00 -0000 Message-ID: Subject: Re: Bug in i386_process_record? To: Michael Snyder Cc: gdb-patches ml Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2009-08/txt/msg00159.txt.bz2 Oops, I will try to find it out. Thanks, Hui On Tue, Aug 11, 2009 at 05:57, Michael Snyder wrote: > Yes, this seems to be better. =A0It records only 4 bytes each time > it is called. > > But there seems to be still an off-by-one error? =A0With 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 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. =A0Looks like we are saving the same data over >>> and over in the log. >>> >>> This was made using the attached sample program. >>> >>> =A0(gdb) break main >>> =A0 Breakpoint 1 at 0x80483c4: file memrange-reverse.c, line 29. >>> =A0(gdb) run >>> =A0 Starting program: >>> =A0 Breakpoint 1, main () >>> =A0 29 =A0 =A0 =A0 =A0memset (blob1, 'a', sizeof (blob1)); >>> =A0(gdb) record >>> =A0(gdb) next >>> =A0 30 =A0 =A0 =A0 =A0blob1[sizeof (blob1) - 1] =3D '\0'; >>> =A0(gdb) record dump >>> =A0 Saving recording to file 'rec.27255' >>> =A0 Writing 4-byte magic cookie RECORD_FILE_MAGIC (0x26070920) >>> =A0[...] >>> =A0Writing register 7 val 0x0000000008049684 (1 plus 8 plus 16 bytes) >>> =A0Writing memory 0x08049680 (1 plus 8 plus 8 bytes plus 1024 bytes) >>> =A0Writing register 1 val 0x00000000000000ff (1 plus 8 plus 16 bytes) >>> =A0Writing register 8 val 0x0000000000587be7 (1 plus 8 plus 16 bytes) >>> =A0Writing record_end (1 byte) >>> =A0Writing register 7 val 0x0000000008049688 (1 plus 8 plus 16 bytes) >>> =A0Writing memory 0x08049684 (1 plus 8 plus 8 bytes plus 1020 bytes) >>> =A0Writing register 1 val 0x00000000000000fe (1 plus 8 plus 16 bytes) >>> =A0Writing register 8 val 0x0000000000587be7 (1 plus 8 plus 16 bytes) >>> =A0Writing record_end (1 byte) >>> =A0Writing register 7 val 0x000000000804968c (1 plus 8 plus 16 bytes) >>> =A0Writing memory 0x08049688 (1 plus 8 plus 8 bytes plus 1016 bytes) >>> =A0Writing register 1 val 0x00000000000000fd (1 plus 8 plus 16 bytes) >>> =A0Writing register 8 val 0x0000000000587be7 (1 plus 8 plus 16 bytes) >>> =A0Writing record_end (1 byte) >>> =A0Writing register 7 val 0x0000000008049690 (1 plus 8 plus 16 bytes) >>> =A0Writing memory 0x0804968c (1 plus 8 plus 8 bytes plus 1012 bytes) >>> =A0Writing register 1 val 0x00000000000000fc (1 plus 8 plus 16 bytes) >>> =A0Writing register 8 val 0x0000000000587be7 (1 plus 8 plus 16 bytes) >>> =A0Writing record_end (1 byte) >>> =A0Writing register 7 val 0x0000000008049694 (1 plus 8 plus 16 bytes) >>> =A0Writing memory 0x08049690 (1 plus 8 plus 8 bytes plus 1008 bytes) >>> =A0Writing register 1 val 0x00000000000000fb (1 plus 8 plus 16 bytes) >>> =A0Writing register 8 val 0x0000000000587be7 (1 plus 8 plus 16 bytes) >>> =A0Writing record_end (1 byte) >>> =A0Writing register 7 val 0x0000000008049698 (1 plus 8 plus 16 bytes) >>> =A0Writing memory 0x08049694 (1 plus 8 plus 8 bytes plus 1004 bytes) >>> =A0Writing register 1 val 0x00000000000000fa (1 plus 8 plus 16 bytes) >>> =A0Writing register 8 val 0x0000000000587be7 (1 plus 8 plus 16 bytes) >>> =A0Writing record_end (1 byte) >>> =A0Writing register 7 val 0x000000000804969c (1 plus 8 plus 16 bytes) >>> =A0Writing memory 0x08049698 (1 plus 8 plus 8 bytes plus 1000 bytes) >>> =A0Writing register 1 val 0x00000000000000f9 (1 plus 8 plus 16 bytes) >>> =A0Writing register 8 val 0x0000000000587be7 (1 plus 8 plus 16 bytes) >>> =A0Writing record_end (1 byte) >>> =A0Writing register 7 val 0x00000000080496a0 (1 plus 8 plus 16 bytes) >>> =A0Writing memory 0x0804969c (1 plus 8 plus 8 bytes plus 996 bytes) >>> =A0Writing register 1 val 0x00000000000000f8 (1 plus 8 plus 16 bytes) >>> =A0Writing register 8 val 0x0000000000587be7 (1 plus 8 plus 16 bytes) >>> =A0[...] >>> >>> Altogether there were 256 duplicate entries, each one is >>> four bytes shorter than the previous one. >>> >>> >> >> Hi Michael, >> >> I reproduce about issue. =A0This 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 =A0Hui Zhu =A0 >> >> =A0 =A0 =A0 =A0* record.c (i386_process_record): Remove some error code. >> >> --- >> =A0i386-tdep.c | =A0 27 ++++----------------------- >> =A01 file changed, 4 insertions(+), 23 deletions(-) >> >> --- a/i386-tdep.c >> +++ b/i386-tdep.c >> @@ -4448,9 +4448,8 @@ reswitch: >> =A0 =A0 =A0 regcache_raw_read_unsigned (ir.regcache, >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ir.r= egmap[X86_RECORD_REDI_REGNUM], >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 &tmp= ulongest); >> - =A0 =A0 =A0if (!ir.aflag) >> + =A0 =A0 =A0if (ir.aflag) >> =A0 =A0 =A0 =A0 { >> - =A0 =A0 =A0 =A0 =A0tmpulongest &=3D 0xffff; >> =A0 =A0 =A0 =A0 =A0 /* addr +=3D ((uint32_t) read_register (I386_ES_REGN= UM)) << 4; */ >> =A0 =A0 =A0 =A0 =A0 if (record_debug) >> =A0 =A0 =A0 =A0 =A0 =A0 printf_unfiltered (_("Process record ignores the= memory change >> " >> @@ -4460,27 +4459,9 @@ reswitch: >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0paddress = (gdbarch, ir.addr)); >> =A0 =A0 =A0 =A0 } >> =A0 =A0 =A0 if (prefixes & (PREFIX_REPZ | PREFIX_REPNZ)) >> - =A0 =A0 =A0 =A0{ >> - =A0 =A0 =A0 =A0 =A0ULONGEST count, eflags; >> - =A0 =A0 =A0 =A0 =A0regcache_raw_read_unsigned (ir.regcache, >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0ir.regmap[X86_RECORD_REDI_REGNUM], >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0&count); >> - =A0 =A0 =A0 =A0 =A0if (!ir.aflag) >> - =A0 =A0 =A0 =A0 =A0 =A0count &=3D 0xffff; >> - =A0 =A0 =A0 =A0 =A0regcache_raw_read_unsigned (ir.regcache, >> - >> =A0ir.regmap[X86_RECORD_EFLAGS_REGNUM], >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0&eflags); >> - =A0 =A0 =A0 =A0 =A0if ((eflags >> 10) & 0x1) >> - =A0 =A0 =A0 =A0 =A0 =A0tmpulongest -=3D (count - 1) * (1 << ir.ot); >> - =A0 =A0 =A0 =A0 =A0if (record_arch_list_add_mem (tmpulongest, count * = (1 << >> ir.ot))) >> - =A0 =A0 =A0 =A0 =A0 =A0return -1; >> - =A0 =A0 =A0 =A0 =A0I386_RECORD_ARCH_LIST_ADD_REG (X86_RECORD_RECX_REGN= UM); >> - =A0 =A0 =A0 =A0} >> - =A0 =A0 =A0else >> - =A0 =A0 =A0 =A0{ >> - =A0 =A0 =A0 =A0 =A0if (record_arch_list_add_mem (tmpulongest, 1 << ir.= ot)) >> - =A0 =A0 =A0 =A0 =A0 =A0return -1; >> - =A0 =A0 =A0 =A0} >> + =A0 =A0 =A0 =A0I386_RECORD_ARCH_LIST_ADD_REG (X86_RECORD_RECX_REGNUM); >> + =A0 =A0 =A0if (record_arch_list_add_mem (tmpulongest, 1 << ir.ot)) >> + =A0 =A0 =A0 =A0return -1; >> =A0 =A0 =A0 if (opcode =3D=3D 0xa4 || opcode =3D=3D 0xa5) >> =A0 =A0 =A0 =A0 I386_RECORD_ARCH_LIST_ADD_REG (X86_RECORD_RESI_REGNUM); >> =A0 =A0 =A0 I386_RECORD_ARCH_LIST_ADD_REG (X86_RECORD_REDI_REGNUM); > >