From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5483 invoked by alias); 7 Feb 2010 17:44:20 -0000 Received: (qmail 5470 invoked by uid 22791); 7 Feb 2010 17:44:18 -0000 X-SWARE-Spam-Status: No, hits=-0.8 required=5.0 tests=AWL,BAYES_00,NO_DNS_FOR_FROM X-Spam-Check-By: sourceware.org Received: from mga06.intel.com (HELO orsmga101.jf.intel.com) (134.134.136.21) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 07 Feb 2010 17:44:15 +0000 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP; 07 Feb 2010 09:40:36 -0800 X-ExtLoop1: 1 Received: from gnu-6.sc.intel.com ([10.3.194.107]) by orsmga001.jf.intel.com with ESMTP; 07 Feb 2010 09:42:04 -0800 Received: by gnu-6.sc.intel.com (Postfix, from userid 500) id 5E789812344; Sun, 7 Feb 2010 09:42:13 -0800 (PST) Date: Sun, 07 Feb 2010 17:44:00 -0000 From: "H.J. Lu" To: GDB Subject: PATCH: Check section size for valid core sections Message-ID: <20100207174213.GA10424@lucon.org> Reply-To: "H.J. Lu" MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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-02/txt/msg00181.txt.bz2 I added a new core section, .reg-xstate, to support x86 XSAVE extended state. We can read it on any machine. But we can only write it on machines with x86 XSAVE extended state. I have /* Supported register note sections. */ static struct core_regset_section amd64_linux_regset_sections[] = { { ".reg", 144, "general-purpose" }, { ".reg2", 512, "floating-point" }, { ".reg-xstate", 0, "XSAVE extended state" }, { NULL, 0 } }; I update its size with /* Update the XSAVE extended state size on Linux/x86 host. Need it for "gcore". */ i386_xstate_init (); amd64_linux_regset_sections[2].size = i386_xstate.size; If the machine suppors XSAVE, size will be non-zero. We can still read the core section since size is only used for gcore. OK to install? Thanks. H.J. --- 2010-02-07 H.J. Lu * linux-nat.c (linux_nat_do_thread_registers): Check section size instead of section name for valid core sections. diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c index 7fc9584..44a3288 100644 --- a/gdb/linux-nat.c +++ b/gdb/linux-nat.c @@ -4112,9 +4112,12 @@ linux_nat_do_thread_registers (bfd *obfd, ptid_t ptid, /* The loop below uses the new struct core_regset_section, which stores the supported section names and sizes for the core file. Note that note PRSTATUS needs to be treated specially. But the other notes are - structurally the same, so they can benefit from the new struct. */ + structurally the same, so they can benefit from the new struct. We + check section size instead of section name for valid core sections + since we can read x86 XSAVE extended state core section, but we can + write it only if x86 XSAVE extended state is available natively. */ if (core_regset_p && sect_list != NULL) - while (sect_list->sect_name != NULL) + while (sect_list->size != 0) { /* .reg was already handled above. */ if (strcmp (sect_list->sect_name, ".reg") == 0)