From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 611 invoked by alias); 24 Aug 2009 00:01:02 -0000 Received: (qmail 32669 invoked by uid 22791); 24 Aug 2009 00:01:00 -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-f198.google.com (HELO mail-pz0-f198.google.com) (209.85.222.198) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 24 Aug 2009 00:00:51 +0000 Received: by pzk36 with SMTP id 36so708739pzk.12 for ; Sun, 23 Aug 2009 17:00:49 -0700 (PDT) MIME-Version: 1.0 Received: by 10.142.75.16 with SMTP id x16mr271009wfa.155.1251072049665; Sun, 23 Aug 2009 17:00:49 -0700 (PDT) In-Reply-To: References: <4A7BA1DE.6010103@vmware.com> <4A8A2ACD.9000208@vmware.com> <4A90B261.2030602@vmware.com> <4A90C08A.8000107@vmware.com> <837hwufkxr.fsf@gnu.org> From: Hui Zhu Date: Mon, 24 Aug 2009 03:15:00 -0000 Message-ID: Subject: Re: Bug in i386_process_record? To: Eli Zaretskii , msnyder@vmware.com Cc: gdb-patches@sourceware.org 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/msg00378.txt.bz2 On Mon, Aug 24, 2009 at 07:42, Hui Zhu wrote: > If I am right, this is from the old memory manager -- segment manager. > =A0X86 is a old arch and support it. > > Now, most of OS include Linux, they don't use this MM, they use page > manager that X86 support it too (X86 is crazy). =A0So they set the value > of segment reg to 0. > > For the gdb, the value of segment reg is not the really value. > cs =A0 =A0 =A0 =A0 =A0 =A0 0x73 =A0 =A0 115 > ss =A0 =A0 =A0 =A0 =A0 =A0 0x7b =A0 =A0 123 > ds =A0 =A0 =A0 =A0 =A0 =A0 0x7b =A0 =A0 123 > es =A0 =A0 =A0 =A0 =A0 =A0 0x7b =A0 =A0 123 > fs =A0 =A0 =A0 =A0 =A0 =A0 0x0 =A0 =A0 =A00 > gs =A0 =A0 =A0 =A0 =A0 =A0 0x33 =A0 =A0 51 > I have tried some insn that use segment reg such as string ops insn. > I found that the value of this segment reg cannot affect anything. > > And prec just support Linux now. =A0I have move > "set_gdbarch_process_record (gdbarch, i386_process_record);" to > i386-linux-tdep.c. > > This patch doesn't add any more thing, just fix the bug. =A0And this bug > seems affect a lot of program (for example, Oza's fp example). =A0I > suggest let it in first. =A0After that, we can find a good way to handle > the segment reg better. > > What do you think about it? > > Thanks, > Hui > > On Mon, Aug 24, 2009 at 02:24, Eli Zaretskii wrote: >> >> > From: Hui Zhu >> > Date: Sun, 23 Aug 2009 12:29:33 +0800 >> > Cc: gdb-patches ml >> > >> > read_register (I386_ES_REGNUM) >> > This value is not the value of ES. =A0This is number of TLB. >> >> On what OS? > Please let me show a example for it. cat memrange-reverse.c /* This testcase is part of GDB, the GNU debugger. Copyright 2009 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #include #define SIZE_BLOB1 1024 #define SIZE_BLOB2 256 char blob1[SIZE_BLOB1], blob2[SIZE_BLOB2]; int main () { int i; memset (blob1, 'a', sizeof (blob1)); blob1[sizeof (blob1) - 1] =3D '\0'; memset (blob2, 'b', sizeof (blob2)); blob2[sizeof (blob2) - 1] =3D '\0'; for (i =3D 2; i < 8; i++) { memcpy (blob1 + (sizeof (blob1) / i), blob2, sizeof (blob2)); } return 0; /* end of main */ } gcc -g memrange-reverse.c gdb ./a.out GNU gdb (GDB) 6.8.50.20090807-cvs Copyright (C) 2009 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "i686-pc-linux-gnu". For bug reporting instructions, please see: ... (gdb) start Temporary breakpoint 1 at 0x80483b5: file memrange-reverse.c, line 29. Starting program: /home/teawater/Desktop/a.out Temporary breakpoint 1, main () at memrange-reverse.c:29 29 memset (blob1, 'a', sizeof (blob1)); (gdb) x blob1 0x8049660 : 0x00000000 #This address is what we really want to set. (gdb) b *0xb7eec4e7 Breakpoint 2 at 0xb7eec4e7 (gdb) set disassemble-next-line on (gdb) c Continuing. Breakpoint 2, 0xb7eec4e7 in memset () from /lib/tls/i686/cmov/libc.so.6 0xb7eec4e7 : f3 ab rep stos %eax,%es:(%edi) #This is the code that will set the blob1 (gdb) disassemble Dump of assembler code for function memset: 0xb7eec4b0 : cld 0xb7eec4b1 : push %edi 0xb7eec4b2 : mov 0x8(%esp),%edx 0xb7eec4b6 : mov 0x10(%esp),%ecx 0xb7eec4ba : movzbl 0xc(%esp),%eax 0xb7eec4bf : jecxz 0xb7eec4ed 0xb7eec4c1 : mov %edx,%edi 0xb7eec4c3 : and $0x3,%edx 0xb7eec4c6 : je 0xb7eec4d9 0xb7eec4c8 : jp 0xb7eec4ce 0xb7eec4ca : stos %al,%es:(%edi) 0xb7eec4cb : dec %ecx 0xb7eec4cc : je 0xb7eec4ed 0xb7eec4ce : stos %al,%es:(%edi) 0xb7eec4cf : dec %ecx 0xb7eec4d0 : je 0xb7eec4ed 0xb7eec4d2 : xor $0x1,%edx 0xb7eec4d5 : jne 0xb7eec4d9 0xb7eec4d7 : stos %al,%es:(%edi) 0xb7eec4d8 : dec %ecx 0xb7eec4d9 : mov %ecx,%edx 0xb7eec4db : shr $0x2,%ecx 0xb7eec4de : and $0x3,%edx 0xb7eec4e1 : imul $0x1010101,%eax,%eax 0xb7eec4e7 : rep stos %eax,%es:(%edi) 0xb7eec4e9 : mov %edx,%ecx 0xb7eec4eb : rep stos %al,%es:(%edi) 0xb7eec4ed : mov 0x8(%esp),%eax 0xb7eec4f1 : pop %edi 0xb7eec4f2 : ret End of assembler dump. (gdb) info reg $edi edi 0x8049660 134518368 (gdb) info reg $es es 0x7b 123 #rep stos %eax,%es:(%edi) $edi + 0 =3D 0x8049660 blob1 $edi + $es !=3D 0x8049660 blob1 Thanks, Hui