From patchwork Thu Jan 15 15:21:11 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Arnez X-Patchwork-Id: 4705 Received: (qmail 20817 invoked by alias); 15 Jan 2015 15:24:02 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 20797 invoked by uid 89); 15 Jan 2015 15:24:01 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL, BAYES_00, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: e06smtp17.uk.ibm.com Received: from e06smtp17.uk.ibm.com (HELO e06smtp17.uk.ibm.com) (195.75.94.113) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Thu, 15 Jan 2015 15:23:58 +0000 Received: from /spool/local by e06smtp17.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 15 Jan 2015 15:23:55 -0000 Received: from d06dlp03.portsmouth.uk.ibm.com (9.149.20.15) by e06smtp17.uk.ibm.com (192.168.101.147) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 15 Jan 2015 15:23:53 -0000 Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by d06dlp03.portsmouth.uk.ibm.com (Postfix) with ESMTP id 0529D1B08067 for ; Thu, 15 Jan 2015 15:24:30 +0000 (GMT) Received: from d06av06.portsmouth.uk.ibm.com (d06av06.portsmouth.uk.ibm.com [9.149.37.217]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t0FFNr7g54722722 for ; Thu, 15 Jan 2015 15:23:53 GMT Received: from d06av06.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av06.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t0FAK0IJ002798 for ; Thu, 15 Jan 2015 05:20:00 -0500 Received: from br87z6lw.boeblingen.de.ibm.com (dyn-9-152-212-115.boeblingen.de.ibm.com [9.152.212.115]) by d06av06.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id t0FAHxsv030532; Thu, 15 Jan 2015 05:20:00 -0500 From: Andreas Arnez To: gdb-patches@sourceware.org Cc: Pedro Alves , Jan Kratochvil , Mark Kettenis Subject: [PATCH 3/3] Warn if core file register section is larger than expected Date: Thu, 15 Jan 2015 16:21:11 +0100 Message-Id: <1421335311-4239-4-git-send-email-arnez@linux.vnet.ibm.com> In-Reply-To: <1421335311-4239-1-git-send-email-arnez@linux.vnet.ibm.com> References: <1421335311-4239-1-git-send-email-arnez@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15011515-0029-0000-0000-000002D2481B X-IsSubscribed: yes When reading a core file register section which is larger than expected, emit a warning. Assume that a register section usually has exactly the size specified by the regset section iterator. In some special cases this assumption is wrong, or at least does not match the regset supply function's logic. Thus also add a way to suppress the warning in those cases, using a new flag REGSET_VARIABLE_SIZE. gdb/ChangeLog: * regset.h (struct regset): Add flags field. (REGSET_VARIABLE_SIZE): New value for a regset's flags field. * corelow.c (get_core_register_section): Add warning if the size exceeds the requested size and the regset does not have the REGSET_VARIABLE_SIZE flag set. * alphanbsd-tdep.c (alphanbsd_gregset): Add REGSET_VARIABLE_SIZE flag. * armbsd-tdep.c (armbsd_gregset): Likewise. * hppa-hpux-tdep.c (hppa_hpux_regset): Likewise. * hppaobsd-tdep.c (hppaobsd_gregset): Likewise. * m68kbsd-tdep.c (m68kbsd_gregset): Likewise. * mipsnbsd-tdep.c (mipsnbsd_gregset): Likewise. --- gdb/alphanbsd-tdep.c | 4 +++- gdb/armbsd-tdep.c | 4 +++- gdb/corelow.c | 5 +++++ gdb/hppa-hpux-tdep.c | 4 +++- gdb/hppaobsd-tdep.c | 4 +++- gdb/m68kbsd-tdep.c | 4 +++- gdb/mipsnbsd-tdep.c | 4 +++- gdb/regset.h | 7 +++++++ 8 files changed, 30 insertions(+), 6 deletions(-) diff --git a/gdb/alphanbsd-tdep.c b/gdb/alphanbsd-tdep.c index 6b13fad..69be265 100644 --- a/gdb/alphanbsd-tdep.c +++ b/gdb/alphanbsd-tdep.c @@ -145,7 +145,9 @@ alphanbsd_supply_gregset (const struct regset *regset, static const struct regset alphanbsd_gregset = { NULL, - alphanbsd_supply_gregset + alphanbsd_supply_gregset, + NULL, + REGSET_VARIABLE_SIZE }; static const struct regset alphanbsd_fpregset = diff --git a/gdb/armbsd-tdep.c b/gdb/armbsd-tdep.c index 7923cad..c043b51 100644 --- a/gdb/armbsd-tdep.c +++ b/gdb/armbsd-tdep.c @@ -98,7 +98,9 @@ armbsd_supply_gregset (const struct regset *regset, static const struct regset armbsd_gregset = { NULL, - armbsd_supply_gregset + armbsd_supply_gregset, + NULL, + REGSET_VARIABLE_SIZE }; static const struct regset armbsd_fpregset = diff --git a/gdb/corelow.c b/gdb/corelow.c index a9eadd5..12cbcba 100644 --- a/gdb/corelow.c +++ b/gdb/corelow.c @@ -523,6 +523,11 @@ get_core_register_section (struct regcache *regcache, warning (_("Section `%s' in core file too small."), section_name); return; } + if (size != min_size && !(regset->flags & REGSET_VARIABLE_SIZE)) + { + warning (_("Unexpected size of section `%s' in core file."), + section_name); + } contents = alloca (size); if (! bfd_get_section_contents (core_bfd, section, contents, diff --git a/gdb/hppa-hpux-tdep.c b/gdb/hppa-hpux-tdep.c index 0c8575d..3c0f390 100644 --- a/gdb/hppa-hpux-tdep.c +++ b/gdb/hppa-hpux-tdep.c @@ -1367,7 +1367,9 @@ hppa_hpux_supply_save_state (const struct regset *regset, static const struct regset hppa_hpux_regset = { NULL, - hppa_hpux_supply_save_state + hppa_hpux_supply_save_state, + NULL, + REGSET_VARIABLE_SIZE }; static void diff --git a/gdb/hppaobsd-tdep.c b/gdb/hppaobsd-tdep.c index 9ec7fdf..c9bc1bf 100644 --- a/gdb/hppaobsd-tdep.c +++ b/gdb/hppaobsd-tdep.c @@ -131,7 +131,9 @@ hppaobsd_supply_fpregset (const struct regset *regset, static const struct regset hppaobsd_gregset = { NULL, - hppaobsd_supply_gregset + hppaobsd_supply_gregset, + NULL, + REGSET_VARIABLE_SIZE }; static const struct regset hppaobsd_fpregset = diff --git a/gdb/m68kbsd-tdep.c b/gdb/m68kbsd-tdep.c index b1ae4c1..ae0cecf 100644 --- a/gdb/m68kbsd-tdep.c +++ b/gdb/m68kbsd-tdep.c @@ -105,7 +105,9 @@ m68kbsd_supply_gregset (const struct regset *regset, static const struct regset m68kbsd_gregset = { NULL, - m68kbsd_supply_gregset + m68kbsd_supply_gregset, + NULL, + REGSET_VARIABLE_SIZE }; static const struct regset m68kbsd_fpregset = diff --git a/gdb/mipsnbsd-tdep.c b/gdb/mipsnbsd-tdep.c index ee68f3d..d15c88c 100644 --- a/gdb/mipsnbsd-tdep.c +++ b/gdb/mipsnbsd-tdep.c @@ -103,7 +103,9 @@ mipsnbsd_supply_gregset (const struct regset *regset, static const struct regset mipsnbsd_gregset = { NULL, - mipsnbsd_supply_gregset + mipsnbsd_supply_gregset, + NULL, + REGSET_VARIABLE_SIZE }; static const struct regset mipsnbsd_fpregset = diff --git a/gdb/regset.h b/gdb/regset.h index 3585322..d6edaa5 100644 --- a/gdb/regset.h +++ b/gdb/regset.h @@ -43,6 +43,13 @@ struct regset /* Function collecting values in a register set from a register cache. */ collect_regset_ftype *collect_regset; + + unsigned flags; }; +/* Values for a regset's 'flags' field. */ + +#define REGSET_VARIABLE_SIZE 1 /* Accept a larger regset section size + in a core file without warning. */ + #endif /* regset.h */