From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30300 invoked by alias); 26 Aug 2009 23:45:02 -0000 Received: (qmail 30150 invoked by uid 22791); 26 Aug 2009 23:45:00 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_22,J_CHICKENPOX_25 X-Spam-Check-By: sourceware.org Received: from smtp-outbound-2.vmware.com (HELO smtp-outbound-2.vmware.com) (65.115.85.73) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 26 Aug 2009 23:44:54 +0000 Received: from mailhost3.vmware.com (mailhost3.vmware.com [10.16.27.45]) by smtp-outbound-2.vmware.com (Postfix) with ESMTP id 1C25A7; Wed, 26 Aug 2009 16:44:53 -0700 (PDT) Received: from [10.20.94.141] (msnyder-server.eng.vmware.com [10.20.94.141]) by mailhost3.vmware.com (Postfix) with ESMTP id 11711CD902; Wed, 26 Aug 2009 16:44:53 -0700 (PDT) Message-ID: <4A95C927.8020607@vmware.com> Date: Thu, 27 Aug 2009 00:05:00 -0000 From: Michael Snyder User-Agent: Thunderbird 1.5.0.12 (X11/20080411) MIME-Version: 1.0 To: Hui Zhu CC: Eli Zaretskii , "gdb-patches@sourceware.org" Subject: Re: Bug in i386_process_record? References: <4A7BA1DE.6010103@vmware.com> <4A90C08A.8000107@vmware.com> <837hwufkxr.fsf@gnu.org> <83eir1dnqw.fsf@gnu.org> <8363cbenvt.fsf@gnu.org> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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/msg00463.txt.bz2 Hui Zhu wrote: > On Wed, Aug 26, 2009 at 02:42, Eli Zaretskii wrote: >>> From: Hui Zhu >>> Date: Tue, 25 Aug 2009 13:02:44 +0800 >>> Cc: msnyder@vmware.com, gdb-patches@sourceware.org >>> >>> It seems that the segment (It is not the section) registers in x86 >>> protect mode is just help MMU to get the physical address. It's >>> transparent for the user level program. >> It's transparent if $es and $ds have the same value (which they >> usually do, AFAIK). >> >>> What do you think about remove this warning from this patch? >> I would indeed do that, if we find that $es and $ds have the same >> values. Assuming that someone who knows Linux better than I do >> confirms that these two registers hold the same selector when a normal >> application is running in user mode. >> > > Thanks for remind me. We cannot get the value of each segment > register, but we can get each segment register point to. So if the > value of segment registers, it's means that the value of them is same. > > I add some code about it: > regcache_raw_read_unsigned (ir.regcache, > ir.regmap[X86_RECORD_ES_REGNUM], > &es); > regcache_raw_read_unsigned (ir.regcache, > ir.regmap[X86_RECORD_DS_REGNUM], > &ds); > if (ir.aflag && (es != ds)) > { > > After that, we will not get the warning because the es is same with ds > in user level. > > What do you think about it? I think it is the best version I have seen so far. And it seems to follow the conclusions of the discussion. And I've tested it, and it seems to work. I would say wait until end-of-business Friday, and if there are no more comments, check it in! Michael > 2009-08-26 Hui Zhu > > * i386-tdep.c (i386_process_record): Fix the error of string > ops instructions's handler. > --- > i386-tdep.c | 69 ++++++++++++++++++++++++++++-------------------------------- > 1 file changed, 33 insertions(+), 36 deletions(-) > > --- a/i386-tdep.c > +++ b/i386-tdep.c > @@ -4441,50 +4441,47 @@ reswitch: > /* insS */ > case 0x6c: > case 0x6d: > - if ((opcode & 1) == 0) > - ir.ot = OT_BYTE; > - else > - ir.ot = ir.dflag + OT_WORD; > regcache_raw_read_unsigned (ir.regcache, > - ir.regmap[X86_RECORD_REDI_REGNUM], > + ir.regmap[X86_RECORD_RECX_REGNUM], > &tmpulongest); > - 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 " > - "of instruction at address 0x%s because " > - "it can't get the value of the segment " > - "register.\n"), > - paddress (gdbarch, ir.addr)); > - } > - if (prefixes & (PREFIX_REPZ | PREFIX_REPNZ)) > + if (tmpulongest) > { > - ULONGEST count, eflags; > + ULONGEST es, ds; > + > + if ((opcode & 1) == 0) > + ir.ot = OT_BYTE; > + else > + ir.ot = ir.dflag + OT_WORD; > regcache_raw_read_unsigned (ir.regcache, > ir.regmap[X86_RECORD_REDI_REGNUM], > - &count); > - if (!ir.aflag) > - count &= 0xffff; > + &tmpulongest); > + > 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 > - { > + ir.regmap[X86_RECORD_ES_REGNUM], > + &es); > + regcache_raw_read_unsigned (ir.regcache, > + ir.regmap[X86_RECORD_DS_REGNUM], > + &ds); > + if (ir.aflag && (es != ds)) > + { > + /* addr += ((uint32_t) read_register (I386_ES_REGNUM)) << 4; */ > + if (record_debug) > + printf_unfiltered (_("Process record ignores the memory " > + "change of instruction at address 0x%s " > + "because it can't get the value of the " > + "ES segment register.\n"), > + paddress (gdbarch, ir.addr)); > + } > + > + if (prefixes & (PREFIX_REPZ | PREFIX_REPNZ)) > + 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); > - I386_RECORD_ARCH_LIST_ADD_REG (X86_RECORD_EFLAGS_REGNUM); > + 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); > + I386_RECORD_ARCH_LIST_ADD_REG (X86_RECORD_EFLAGS_REGNUM); > + } > break; > > /* cmpsS */