From patchwork Thu May 15 15:49:29 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Arnez X-Patchwork-Id: 938 Return-Path: X-Original-To: siddhesh@wilcox.dreamhost.com Delivered-To: siddhesh@wilcox.dreamhost.com Received: from homiemail-mx22.g.dreamhost.com (mx2.sub5.homie.mail.dreamhost.com [208.113.200.128]) by wilcox.dreamhost.com (Postfix) with ESMTP id 1AE433600CD for ; Thu, 15 May 2014 08:49:56 -0700 (PDT) Received: by homiemail-mx22.g.dreamhost.com (Postfix, from userid 14314964) id 71FA358DFA21; Thu, 15 May 2014 08:49:54 -0700 (PDT) X-Original-To: gdb@patchwork.siddhesh.in Delivered-To: x14314964@homiemail-mx22.g.dreamhost.com Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by homiemail-mx22.g.dreamhost.com (Postfix) with ESMTPS id C7C535943E87 for ; Thu, 15 May 2014 08:49:50 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=yZVnjSOZfS6ep3//zbJl0/8x3OYxNyW Rlp+GwkAob9EclmvBpDKySW/z4dma5xZnV7NOsO+TFiWExCjLvcvGifNGdjCbon1 7fdy5QWWluhqpwt39P1TzOuNWpJxWBKPSuFmURI1Pk4DeQMLzVHWXVVyoc6WCVTM XnqLQsKbXaKU= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=w6UQ3QRCvt0JJf3v4movc8QqOrA=; b=ZWPmI pT92XnwXBO9RSjZPwlyUuxDNBbVucE4+8v2XY47fOYJIEYG40pT0n83oBXp0E3y7 SBe7opNI6I27cAlyowMM+Y8rvZWB6/WjgRmOWkTtmAued4YNTF8UH7W08UOTsczX DqdXc28zskHl0H/k8OlkO0eyEputB8JMSmT6qs= Received: (qmail 30666 invoked by alias); 15 May 2014 15:49:43 -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 30643 invoked by uid 89); 15 May 2014 15:49:42 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.7 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: e06smtp10.uk.ibm.com Received: from e06smtp10.uk.ibm.com (HELO e06smtp10.uk.ibm.com) (195.75.94.106) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Thu, 15 May 2014 15:49:41 +0000 Received: from /spool/local by e06smtp10.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 15 May 2014 16:49:38 +0100 Received: from d06dlp02.portsmouth.uk.ibm.com (9.149.20.14) by e06smtp10.uk.ibm.com (192.168.101.140) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 15 May 2014 16:49:37 +0100 Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by d06dlp02.portsmouth.uk.ibm.com (Postfix) with ESMTP id EEDAD2190056 for ; Thu, 15 May 2014 16:49:27 +0100 (BST) Received: from d06av04.portsmouth.uk.ibm.com (d06av04.portsmouth.uk.ibm.com [9.149.37.216]) by b06cxnps4074.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id s4FFnaPh2425258 for ; Thu, 15 May 2014 15:49:36 GMT Received: from d06av04.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av04.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s4FFnaAx017492 for ; Thu, 15 May 2014 09:49:36 -0600 Received: from br87z6lw.boeblingen.de.ibm.com (dyn-9-152-212-188.boeblingen.de.ibm.com [9.152.212.188]) by d06av04.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id s4FFnZVS017450 for ; Thu, 15 May 2014 09:49:36 -0600 From: Andreas Arnez To: gdb-patches@sourceware.org Subject: [PATCH 05/11] X86: Replace regset_alloc() invocations by static regset structures. Date: Thu, 15 May 2014 17:49:29 +0200 Message-Id: <1400168975-3145-6-git-send-email-arnez@linux.vnet.ibm.com> In-Reply-To: <1400168975-3145-1-git-send-email-arnez@linux.vnet.ibm.com> References: <1400168975-3145-1-git-send-email-arnez@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 14051515-4966-0000-0000-0000000B3CF9 X-IsSubscribed: yes X-DH-Original-To: gdb@patchwork.siddhesh.in After removal of the regset_alloc invocations, the appropriate tdep fields become obsolete and are thus removed. gdb/ * amd64-tdep.c (amd64_fpregset, amd64_xstateregset): New static regset structures. (amd64_regset_from_core_section): Remove dynamic regset allocations. * amd64obsd-tdep.c (amd64obsd_combined_regset): New static regset structure. (amd64obsd_regset_from_core_section): Remove dynamic regset allocation. * i386-cygwin-tdep.c (i386_windows_regset_from_core_section): Likewise. * i386-nto-tdep.c (i386nto_supply_gregset): Adjust call to x86-common regset supply function. * i386-tdep.c (i386_collect_gregset): Make static. (i386_gregset): New global regset structure. (i386_fpregset, i386_xstateregset): New static regset structures. (i386_regset_from_core_section): Remove dynamic regset allocations. (i386_gdbarch_init): Remove initialization of tdep fields 'gregset', 'fpregset', and 'xstateregset'. * i386-tdep.h (struct gdbarch_tdep): Remove fields 'gregset', 'fpregset', and 'xstateregset'. (i386_collect_gregset): Remove prototype. (i386_gregset): New declaration. * i386obsd-tdep.c (i386obsd_aout_gregset): New static regset structure. (i386obsd_aout_regset_from_core_section): Remove dynamic regset allocation. --- gdb/amd64-tdep.c | 27 ++++++++++++--------------- gdb/amd64obsd-tdep.c | 11 ++++++----- gdb/i386-cygwin-tdep.c | 9 +-------- gdb/i386-nto-tdep.c | 8 ++------ gdb/i386-tdep.c | 46 +++++++++++++++++++++------------------------- gdb/i386-tdep.h | 14 ++------------ gdb/i386obsd-tdep.c | 12 ++++++------ 7 files changed, 50 insertions(+), 77 deletions(-) diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c index 1b9797a..10bd31b 100644 --- a/gdb/amd64-tdep.c +++ b/gdb/amd64-tdep.c @@ -2886,6 +2886,16 @@ amd64_collect_xstateregset (const struct regset *regset, amd64_collect_xsave (regcache, regnum, xstateregs, 1); } +static const struct regset amd64_fpregset = + { + NULL, amd64_supply_fpregset, amd64_collect_fpregset + }; + +static const struct regset amd64_xstateregset = + { + NULL, amd64_supply_xstateregset, amd64_collect_xstateregset + }; + /* Return the appropriate register set for the core section identified by SECT_NAME and SECT_SIZE. */ @@ -2896,23 +2906,10 @@ amd64_regset_from_core_section (struct gdbarch *gdbarch, struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); if (strcmp (sect_name, ".reg2") == 0 && sect_size == tdep->sizeof_fpregset) - { - if (tdep->fpregset == NULL) - tdep->fpregset = regset_alloc (gdbarch, amd64_supply_fpregset, - amd64_collect_fpregset); - - return tdep->fpregset; - } + return &amd64_fpregset; if (strcmp (sect_name, ".reg-xstate") == 0) - { - if (tdep->xstateregset == NULL) - tdep->xstateregset = regset_alloc (gdbarch, - amd64_supply_xstateregset, - amd64_collect_xstateregset); - - return tdep->xstateregset; - } + return &amd64_xstateregset; return i386_regset_from_core_section (gdbarch, sect_name, sect_size); } diff --git a/gdb/amd64obsd-tdep.c b/gdb/amd64obsd-tdep.c index 2cc0a0f..5a5e209 100644 --- a/gdb/amd64obsd-tdep.c +++ b/gdb/amd64obsd-tdep.c @@ -55,6 +55,11 @@ amd64obsd_supply_regset (const struct regset *regset, ((const gdb_byte *)regs) + tdep->sizeof_gregset); } +static const struct regset amd64obsd_combined_regset = + { + NULL, amd64obsd_supply_regset, NULL + }; + static const struct regset * amd64obsd_regset_from_core_section (struct gdbarch *gdbarch, const char *sect_name, size_t sect_size) @@ -66,11 +71,7 @@ amd64obsd_regset_from_core_section (struct gdbarch *gdbarch, if (strcmp (sect_name, ".reg") == 0 && sect_size >= tdep->sizeof_gregset + I387_SIZEOF_FXSAVE) - { - if (tdep->gregset == NULL) - tdep->gregset = regset_alloc (gdbarch, amd64obsd_supply_regset, NULL); - return tdep->gregset; - } + return &amd64obsd_combined_regset; return NULL; } diff --git a/gdb/i386-cygwin-tdep.c b/gdb/i386-cygwin-tdep.c index 7b7785a..a23f80e 100644 --- a/gdb/i386-cygwin-tdep.c +++ b/gdb/i386-cygwin-tdep.c @@ -96,16 +96,9 @@ static const struct regset * i386_windows_regset_from_core_section (struct gdbarch *gdbarch, const char *sect_name, size_t sect_size) { - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); - if (strcmp (sect_name, ".reg") == 0 && sect_size == I386_WINDOWS_SIZEOF_GREGSET) - { - if (tdep->gregset == NULL) - tdep->gregset = regset_alloc (gdbarch, i386_supply_gregset, - i386_collect_gregset); - return tdep->gregset; - } + return &i386_gregset; return NULL; } diff --git a/gdb/i386-nto-tdep.c b/gdb/i386-nto-tdep.c index 8d8ba10..d005914 100644 --- a/gdb/i386-nto-tdep.c +++ b/gdb/i386-nto-tdep.c @@ -82,13 +82,9 @@ i386nto_supply_gregset (struct regcache *regcache, char *gpregs) struct gdbarch *gdbarch = get_regcache_arch (regcache); struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); - if(tdep->gregset == NULL) - tdep->gregset = regset_alloc (gdbarch, i386_supply_gregset, - i386_collect_gregset); - gdb_assert (tdep->gregset_reg_offset == i386nto_gregset_reg_offset); - tdep->gregset->supply_regset (tdep->gregset, regcache, -1, - gpregs, NUM_GPREGS * 4); + i386_gregset.supply_regset (&i386_gregset, regcache, -1, + gpregs, NUM_GPREGS * 4); } static void diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c index 7d2363f..88fc31f 100644 --- a/gdb/i386-tdep.c +++ b/gdb/i386-tdep.c @@ -3744,7 +3744,7 @@ i386_supply_gregset (const struct regset *regset, struct regcache *regcache, general-purpose register set REGSET. If REGNUM is -1, do this for all registers in REGSET. */ -void +static void i386_collect_gregset (const struct regset *regset, const struct regcache *regcache, int regnum, void *gregs, size_t len) @@ -3828,6 +3828,23 @@ i386_collect_xstateregset (const struct regset *regset, i387_collect_xsave (regcache, regnum, xstateregs, 1); } +/* Register set definitions. */ + +const struct regset i386_gregset = + { + NULL, i386_supply_gregset, i386_collect_gregset + }; + +static const struct regset i386_fpregset = + { + NULL, i386_supply_fpregset, i386_collect_fpregset + }; + +static const struct regset i386_xstateregset = + { + NULL, i386_supply_xstateregset, i386_collect_xstateregset + }; + /* Return the appropriate register set for the core section identified by SECT_NAME and SECT_SIZE. */ @@ -3838,32 +3855,15 @@ i386_regset_from_core_section (struct gdbarch *gdbarch, struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); if (strcmp (sect_name, ".reg") == 0 && sect_size == tdep->sizeof_gregset) - { - if (tdep->gregset == NULL) - tdep->gregset = regset_alloc (gdbarch, i386_supply_gregset, - i386_collect_gregset); - return tdep->gregset; - } + return &i386_gregset; if ((strcmp (sect_name, ".reg2") == 0 && sect_size == tdep->sizeof_fpregset) || (strcmp (sect_name, ".reg-xfp") == 0 && sect_size == I387_SIZEOF_FXSAVE)) - { - if (tdep->fpregset == NULL) - tdep->fpregset = regset_alloc (gdbarch, i386_supply_fpregset, - i386_collect_fpregset); - return tdep->fpregset; - } + return &i386_fpregset; if (strcmp (sect_name, ".reg-xstate") == 0) - { - if (tdep->xstateregset == NULL) - tdep->xstateregset = regset_alloc (gdbarch, - i386_supply_xstateregset, - i386_collect_xstateregset); - - return tdep->xstateregset; - } + return &i386_xstateregset; return NULL; } @@ -8287,17 +8287,13 @@ i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) gdbarch = gdbarch_alloc (&info, tdep); /* General-purpose registers. */ - tdep->gregset = NULL; tdep->gregset_reg_offset = NULL; tdep->gregset_num_regs = I386_NUM_GREGS; tdep->sizeof_gregset = 0; /* Floating-point registers. */ - tdep->fpregset = NULL; tdep->sizeof_fpregset = I387_SIZEOF_FSAVE; - tdep->xstateregset = NULL; - /* The default settings include the FPU registers, the MMX registers and the SSE registers. This can be overridden for a specific ABI by adjusting the members `st0_regnum', `mm0_regnum' and diff --git a/gdb/i386-tdep.h b/gdb/i386-tdep.h index 2ada2bd..e0950a3 100644 --- a/gdb/i386-tdep.h +++ b/gdb/i386-tdep.h @@ -56,18 +56,13 @@ enum struct_return struct gdbarch_tdep { /* General-purpose registers. */ - struct regset *gregset; int *gregset_reg_offset; int gregset_num_regs; size_t sizeof_gregset; /* Floating-point registers. */ - struct regset *fpregset; size_t sizeof_fpregset; - /* XSAVE extended state. */ - struct regset *xstateregset; - /* Register number for %st(0). The register numbers for the other registers follow from this one. Set this to -1 to indicate the absence of an FPU. */ @@ -389,13 +384,8 @@ extern void i386_supply_gregset (const struct regset *regset, struct regcache *regcache, int regnum, const void *gregs, size_t len); -/* Collect register REGNUM from the register cache REGCACHE and store - it in the buffer specified by GREGS and LEN as described by the - general-purpose register set REGSET. If REGNUM is -1, do this for - all registers in REGSET. */ -extern void i386_collect_gregset (const struct regset *regset, - const struct regcache *regcache, - int regnum, void *gregs, size_t len); +/* General-purpose register set. */ +extern const struct regset i386_gregset; /* Return the appropriate register set for the core section identified by SECT_NAME and SECT_SIZE. */ diff --git a/gdb/i386obsd-tdep.c b/gdb/i386obsd-tdep.c index 7d9ba93..8f76e43 100644 --- a/gdb/i386obsd-tdep.c +++ b/gdb/i386obsd-tdep.c @@ -152,6 +152,11 @@ i386obsd_aout_supply_regset (const struct regset *regset, i387_supply_fsave (regcache, regnum, gregs + tdep->sizeof_gregset); } +static const struct regset i386obsd_aout_gregset = + { + NULL, i386obsd_aout_supply_regset, NULL + }; + static const struct regset * i386obsd_aout_regset_from_core_section (struct gdbarch *gdbarch, const char *sect_name, @@ -164,12 +169,7 @@ i386obsd_aout_regset_from_core_section (struct gdbarch *gdbarch, if (strcmp (sect_name, ".reg") == 0 && sect_size >= tdep->sizeof_gregset + I387_SIZEOF_FSAVE) - { - if (tdep->gregset == NULL) - tdep->gregset = - regset_alloc (gdbarch, i386obsd_aout_supply_regset, NULL); - return tdep->gregset; - } + return &i386obsd_aout_gregset; return NULL; }