From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24543 invoked by alias); 21 Apr 2010 20:18:31 -0000 Received: (qmail 24524 invoked by uid 22791); 21 Apr 2010 20:18:27 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=BAYES_00,NO_DNS_FOR_FROM,TW_XF,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mga09.intel.com (HELO mga09.intel.com) (134.134.136.24) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 21 Apr 2010 20:18:22 +0000 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP; 21 Apr 2010 13:17:29 -0700 X-ExtLoop1: 1 Received: from gnu-6.sc.intel.com ([10.3.194.107]) by orsmga002.jf.intel.com with ESMTP; 21 Apr 2010 13:18:03 -0700 Received: by gnu-6.sc.intel.com (Postfix, from userid 500) id 1248C812386; Wed, 21 Apr 2010 13:18:21 -0700 (PDT) Date: Wed, 21 Apr 2010 20:18:00 -0000 From: "H.J. Lu" To: GDB Subject: Re: PATCH: Fix 32bit coredump read on Linux/AVX Message-ID: <20100421201820.GA32756@intel.com> Reply-To: "H.J. Lu" References: <20100420032234.GA10544@intel.com> <20100420184339.GA18641@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20100420184339.GA18641@intel.com> User-Agent: Mutt/1.5.20 (2009-08-17) 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: 2010-04/txt/msg00700.txt.bz2 On Tue, Apr 20, 2010 at 11:43:39AM -0700, H.J. Lu wrote: > On Mon, Apr 19, 2010 at 08:22:34PM -0700, H.J. Lu wrote: > > Hi, > > > > This patch: > > > > http://sourceware.org/ml/gdb-patches/2010-04/msg00276.html > > > > breaks 32bit coredump read on Linux/AVX since we only dump .reg and > > .reg-xstate sections on AVX. But i386_linux_core_read_description > > checks .reg2 and .reg-xfp sections first. Since there are no > > .reg2 and .reg-xfp sections, NULL is returned and SSE target is used. > > This patch changes the section check order to .reg-xstate, .reg-xfp, > > .reg2. OK to install? > > > > Thanks. > > > > .reg2 section has x87 regiters on i386 and SSE registers on amd64. > Here is the updated patch to properly handle it. OK to install? > > Thanks. > > > H.J. > -- > 2010-04-20 H.J. Lu > > PR corefiles/11523 > * amd64-linux-tdep.c (amd64_linux_core_read_description): Check > XCR0 first. > > * i386-linux-tdep.c (i386_linux_core_read_xcr0): Return 0 if > there is no .reg-xstate section. > (i386_linux_core_read_description): Check XCR0 first. > This is the version I am checking in. H.J. --- 2010-04-21 H.J. Lu PR corefiles/11523 * amd64-linux-tdep.c (amd64_linux_core_read_description): Check XCR0 first. * i386-linux-tdep.c (i386_linux_core_read_xcr0): Return 0 if there is no .reg-xstate section. (i386_linux_core_read_description): Check XCR0 first. diff --git a/gdb/amd64-linux-tdep.c b/gdb/amd64-linux-tdep.c index f249d5d..7376ba7 100644 --- a/gdb/amd64-linux-tdep.c +++ b/gdb/amd64-linux-tdep.c @@ -1269,18 +1269,15 @@ amd64_linux_core_read_description (struct gdbarch *gdbarch, struct target_ops *target, bfd *abfd) { - asection *section = bfd_get_section_by_name (abfd, ".reg2"); - uint64_t xcr0; - - if (section == NULL) - return NULL; - /* Linux/x86-64. */ - xcr0 = i386_linux_core_read_xcr0 (gdbarch, target, abfd); - if ((xcr0 & I386_XSTATE_AVX_MASK) == I386_XSTATE_AVX_MASK) - return tdesc_amd64_avx_linux; - else - return tdesc_amd64_linux; + uint64_t xcr0 = i386_linux_core_read_xcr0 (gdbarch, target, abfd); + switch ((xcr0 & I386_XSTATE_AVX_MASK)) + { + case I386_XSTATE_AVX_MASK: + return tdesc_amd64_avx_linux; + default: + return tdesc_amd64_linux; + } } static void diff --git a/gdb/i386-linux-tdep.c b/gdb/i386-linux-tdep.c index 5952153..711a5d1 100644 --- a/gdb/i386-linux-tdep.c +++ b/gdb/i386-linux-tdep.c @@ -611,7 +611,7 @@ i386_linux_core_read_xcr0 (struct gdbarch *gdbarch, } } else - xcr0 = I386_XSTATE_SSE_MASK; + xcr0 = 0; return xcr0; } @@ -623,22 +623,24 @@ i386_linux_core_read_description (struct gdbarch *gdbarch, struct target_ops *target, bfd *abfd) { - asection *section = bfd_get_section_by_name (abfd, ".reg2"); - uint64_t xcr0; - - if (section == NULL) - return NULL; - - section = bfd_get_section_by_name (abfd, ".reg-xfp"); - if (section == NULL) - return tdesc_i386_mmx_linux; - /* Linux/i386. */ - xcr0 = i386_linux_core_read_xcr0 (gdbarch, target, abfd); - if ((xcr0 & I386_XSTATE_AVX_MASK) == I386_XSTATE_AVX_MASK) - return tdesc_i386_avx_linux; - else + uint64_t xcr0 = i386_linux_core_read_xcr0 (gdbarch, target, abfd); + switch ((xcr0 & I386_XSTATE_AVX_MASK)) + { + case I386_XSTATE_AVX_MASK: + return tdesc_i386_avx_linux; + case I386_XSTATE_SSE_MASK: + return tdesc_i386_linux; + case I386_XSTATE_X87_MASK: + return tdesc_i386_mmx_linux; + default: + break; + } + + if (bfd_get_section_by_name (abfd, ".reg-xfp") != NULL) return tdesc_i386_linux; + else + return tdesc_i386_mmx_linux; } static void