From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19507 invoked by alias); 10 Aug 2009 08:51:10 -0000 Received: (qmail 19499 invoked by uid 22791); 10 Aug 2009 08:51:09 -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 wf-out-1314.google.com (HELO wf-out-1314.google.com) (209.85.200.171) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 10 Aug 2009 08:51:00 +0000 Received: by wf-out-1314.google.com with SMTP id 23so1080821wfg.24 for ; Mon, 10 Aug 2009 01:50:58 -0700 (PDT) MIME-Version: 1.0 Received: by 10.142.225.18 with SMTP id x18mr506941wfg.264.1249894258345; Mon, 10 Aug 2009 01:50:58 -0700 (PDT) In-Reply-To: <4A7BA1DE.6010103@vmware.com> References: <4A7BA1DE.6010103@vmware.com> From: Hui Zhu Date: Mon, 10 Aug 2009 09:33:00 -0000 Message-ID: Subject: Re: Bug in i386_process_record? To: Michael Snyder Cc: gdb-patches ml Content-Type: multipart/mixed; boundary=000e0cd313204686890470c5afb8 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/msg00139.txt.bz2 --000e0cd313204686890470c5afb8 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-length: 5732 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 =A0Breakpoint 1 at 0x80483c4: file memrange-reverse.c, line 29. > =A0(gdb) run > =A0 =A0Starting program: > =A0 =A0Breakpoint 1, main () > =A0 =A029 =A0 =A0 =A0 =A0memset (blob1, 'a', sizeof (blob1)); > =A0(gdb) record > =A0(gdb) next > =A0 =A030 =A0 =A0 =A0 =A0blob1[sizeof (blob1) - 1] =3D '\0'; > =A0(gdb) record dump > =A0 =A0Saving recording to file 'rec.27255' > =A0 =A0Writing 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. 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 * 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 &=3D 0xffff; /* addr +=3D ((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 &=3D 0xffff; - regcache_raw_read_unsigned (ir.regcache, - ir.regmap[X86_RECORD_EFLAGS_REGNUM], - &eflags); - if ((eflags >> 10) & 0x1) - tmpulongest -=3D (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 =3D=3D 0xa4 || opcode =3D=3D 0xa5) I386_RECORD_ARCH_LIST_ADD_REG (X86_RECORD_RESI_REGNUM); I386_RECORD_ARCH_LIST_ADD_REG (X86_RECORD_REDI_REGNUM); --000e0cd313204686890470c5afb8 Content-Type: text/plain; charset=US-ASCII; name="prec-fix-x86-strinsn.txt" Content-Disposition: attachment; filename="prec-fix-x86-strinsn.txt" Content-Transfer-Encoding: base64 X-Attachment-Id: f_fy6yv6661 Content-length: 2628 LS0tCiBpMzg2LXRkZXAuYyB8ICAgMjcgKysrKy0tLS0tLS0tLS0tLS0tLS0t LS0tLS0tCiAxIGZpbGUgY2hhbmdlZCwgNCBpbnNlcnRpb25zKCspLCAyMyBk ZWxldGlvbnMoLSkKCi0tLSBhL2kzODYtdGRlcC5jCisrKyBiL2kzODYtdGRl cC5jCkBAIC00NDQ4LDkgKzQ0NDgsOCBAQCByZXN3aXRjaDoKICAgICAgIHJl Z2NhY2hlX3Jhd19yZWFkX3Vuc2lnbmVkIChpci5yZWdjYWNoZSwKICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpci5yZWdtYXBbWDg2X1JF Q09SRF9SRURJX1JFR05VTV0sCiAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgJnRtcHVsb25nZXN0KTsKLSAgICAgIGlmICghaXIuYWZsYWcp CisgICAgICBpZiAoaXIuYWZsYWcpCiAgICAgICAgIHsKLSAgICAgICAgICB0 bXB1bG9uZ2VzdCAmPSAweGZmZmY7CiAgICAgICAgICAgLyogYWRkciArPSAo KHVpbnQzMl90KSByZWFkX3JlZ2lzdGVyIChJMzg2X0VTX1JFR05VTSkpIDw8 IDQ7ICovCiAgICAgICAgICAgaWYgKHJlY29yZF9kZWJ1ZykKICAgICAgICAg ICAgIHByaW50Zl91bmZpbHRlcmVkIChfKCJQcm9jZXNzIHJlY29yZCBpZ25v cmVzIHRoZSBtZW1vcnkgY2hhbmdlICIKQEAgLTQ0NjAsMjcgKzQ0NTksOSBA QCByZXN3aXRjaDoKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBw YWRkcmVzcyAoZ2RiYXJjaCwgaXIuYWRkcikpOwogICAgICAgICB9CiAgICAg ICBpZiAocHJlZml4ZXMgJiAoUFJFRklYX1JFUFogfCBQUkVGSVhfUkVQTlop KQotICAgICAgICB7Ci0gICAgICAgICAgVUxPTkdFU1QgY291bnQsIGVmbGFn czsKLSAgICAgICAgICByZWdjYWNoZV9yYXdfcmVhZF91bnNpZ25lZCAoaXIu cmVnY2FjaGUsCi0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgIGlyLnJlZ21hcFtYODZfUkVDT1JEX1JFRElfUkVHTlVNXSwKLSAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgJmNvdW50KTsKLSAg ICAgICAgICBpZiAoIWlyLmFmbGFnKQotICAgICAgICAgICAgY291bnQgJj0g MHhmZmZmOwotICAgICAgICAgIHJlZ2NhY2hlX3Jhd19yZWFkX3Vuc2lnbmVk IChpci5yZWdjYWNoZSwKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgaXIucmVnbWFwW1g4Nl9SRUNPUkRfRUZMQUdTX1JFR05VTV0s Ci0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICZlZmxh Z3MpOwotICAgICAgICAgIGlmICgoZWZsYWdzID4+IDEwKSAmIDB4MSkKLSAg ICAgICAgICAgIHRtcHVsb25nZXN0IC09IChjb3VudCAtIDEpICogKDEgPDwg aXIub3QpOwotICAgICAgICAgIGlmIChyZWNvcmRfYXJjaF9saXN0X2FkZF9t ZW0gKHRtcHVsb25nZXN0LCBjb3VudCAqICgxIDw8IGlyLm90KSkpCi0gICAg ICAgICAgICByZXR1cm4gLTE7Ci0gICAgICAgICAgSTM4Nl9SRUNPUkRfQVJD SF9MSVNUX0FERF9SRUcgKFg4Nl9SRUNPUkRfUkVDWF9SRUdOVU0pOwotICAg ICAgICB9Ci0gICAgICBlbHNlCi0gICAgICAgIHsKLSAgICAgICAgICBpZiAo cmVjb3JkX2FyY2hfbGlzdF9hZGRfbWVtICh0bXB1bG9uZ2VzdCwgMSA8PCBp ci5vdCkpCi0gICAgICAgICAgICByZXR1cm4gLTE7Ci0gICAgICAgIH0KKyAg ICAgICAgSTM4Nl9SRUNPUkRfQVJDSF9MSVNUX0FERF9SRUcgKFg4Nl9SRUNP UkRfUkVDWF9SRUdOVU0pOworICAgICAgaWYgKHJlY29yZF9hcmNoX2xpc3Rf YWRkX21lbSAodG1wdWxvbmdlc3QsIDEgPDwgaXIub3QpKQorICAgICAgICBy ZXR1cm4gLTE7CiAgICAgICBpZiAob3Bjb2RlID09IDB4YTQgfHwgb3Bjb2Rl ID09IDB4YTUpCiAgICAgICAgIEkzODZfUkVDT1JEX0FSQ0hfTElTVF9BRERf UkVHIChYODZfUkVDT1JEX1JFU0lfUkVHTlVNKTsKICAgICAgIEkzODZfUkVD T1JEX0FSQ0hfTElTVF9BRERfUkVHIChYODZfUkVDT1JEX1JFRElfUkVHTlVN KTsK --000e0cd313204686890470c5afb8--