From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1651 invoked by alias); 7 Jul 2014 09:57:02 -0000 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 Received: (qmail 1629 invoked by uid 89); 7 Jul 2014 09:57:01 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-oa0-f50.google.com Received: from mail-oa0-f50.google.com (HELO mail-oa0-f50.google.com) (209.85.219.50) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Mon, 07 Jul 2014 09:56:57 +0000 Received: by mail-oa0-f50.google.com with SMTP id n16so4311697oag.23 for ; Mon, 07 Jul 2014 02:56:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type; bh=es1sxuu5LHWkMBeKGN9crcMCskTNKY/RncTeAwvnvFM=; b=a51FKwDPAH2NwJyLnXmBqXfko1FnigvNoXKp8vnFwkuX9kGLGj21TYTFCOfKVotSeS jq9bBVwJpSCCLAlVK7/Qs0HEAHUYisBLhFCqOipo7U7f6mobKP08NJCn9cLcMHY31DrQ JuJfM99j2y1XTt5LTqOAqeSPHZIiFgj7kb+hlroDmzzxiy768KcJ8i6i/VlEXJ+Khw5A e/DEDTs1m1xczFa5pPVeFSwqLp0dZlC8s2PrWM6YEveheSnovhq0dTpbx4FDChA87Wh+ M/Ua4v3Em1iDdGYSayNar7Y8S8Ud9JxAtYFcy5HqG+yG/d0KDfPGiwHn3aNOm6kCl2xY ED8A== X-Gm-Message-State: ALoCoQnTZcUlaG+IrQs/rmzqGUPR/slO1pMLJIuLsI2mywCySb3P8PseawOMr1cS17Ku9qP44uwg X-Received: by 10.60.123.66 with SMTP id ly2mr29803679oeb.19.1404727015564; Mon, 07 Jul 2014 02:56:55 -0700 (PDT) MIME-Version: 1.0 Received: by 10.182.22.11 with HTTP; Mon, 7 Jul 2014 02:56:35 -0700 (PDT) In-Reply-To: <1403714949-28133-5-git-send-email-arnez@linux.vnet.ibm.com> References: <1403714949-28133-1-git-send-email-arnez@linux.vnet.ibm.com> <1403714949-28133-5-git-send-email-arnez@linux.vnet.ibm.com> From: Omair Javaid Date: Mon, 07 Jul 2014 09:57:00 -0000 Message-ID: Subject: Re: [PATCH v2 04/13] AARCH64 Linux: Fill 'collect_regset' in regset structures. To: Andreas Arnez Cc: "gdb-patches@sourceware.org" , Richard Earnshaw Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes X-SW-Source: 2014-07/txt/msg00108.txt.bz2 On 25 June 2014 21:49, Andreas Arnez wrote: > In order to provide 'collect_regset' support, the generic function > regcache_collect_regset is exploited. Since this requires writing > appropriate register maps, these can be used for supply_regset as > well. > > gdb/ > * aarch64-linux-nat.c (fill_gregset, fill_fpregset): Replace logic > by call to regcache_collect_regset. > (supply_gregset, supply_fpregset): Call regcache_supply_regset > instead of aarch64_linux_supply_gregset/_fpregset. > * aarch64-linux-tdep.c (AARCH64_LINUX_SIZEOF_GREGSET) > (AARCH64_LINUX_SIZEOF_FPREGSET): Delete macros here, move to > header file instead. > (aarch64_linux_supply_gregset, supply_gregset_from_core) > (aarch64_linux_suply_fpregset, supply_fpregset_from_core): Delete > functions. Move logic to ... > (aarch64_linux_gregmap, aarch64_linux_fpregmap): ... these new > register maps. > (aarch64_linux_gregset, aarch64_linux_fpregset): Make global, > refer to new register maps, replace *_regset_from_core by > regcache_supply_regset, and also use regcache_collect_regset. > * aarch64-linux-tdep.h: Include "regset.h". > (aarch64_linux_supply_gregset, aarch64_linux_supply_fpregset): > Delete prototypes. > (AARCH64_LINUX_SIZEOF_GREGSET, AARCH64_LINUX_SIZEOF_FPREGSET): New > macros, moved from C source file. > (aarch64_linux_gregset, aarch64_linux_fpregset): New global > variable declarations. > --- > gdb/aarch64-linux-nat.c | 38 +++++++------------- > gdb/aarch64-linux-tdep.c | 90 +++++++++++++----------------------------------- > gdb/aarch64-linux-tdep.h | 18 +++++++--- > 3 files changed, 48 insertions(+), 98 deletions(-) > > diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c > index 877e702..4ae789b 100644 > --- a/gdb/aarch64-linux-nat.c > +++ b/gdb/aarch64-linux-nat.c > @@ -616,14 +616,9 @@ void > fill_gregset (const struct regcache *regcache, > gdb_gregset_t *gregsetp, int regno) > { > - gdb_byte *gregs_buf = (gdb_byte *) gregsetp; > - int i; > - > - for (i = AARCH64_X0_REGNUM; i <= AARCH64_CPSR_REGNUM; i++) > - if (regno == -1 || regno == i) > - regcache_raw_collect (regcache, i, > - gregs_buf + X_REGISTER_SIZE > - * (i - AARCH64_X0_REGNUM)); > + regcache_collect_regset (&aarch64_linux_gregset, regcache, > + regno, (gdb_byte *) gregsetp, > + AARCH64_LINUX_SIZEOF_GREGSET); > } > > /* Fill GDB's register array with the general-purpose register values > @@ -632,7 +627,9 @@ fill_gregset (const struct regcache *regcache, > void > supply_gregset (struct regcache *regcache, const gdb_gregset_t *gregsetp) > { > - aarch64_linux_supply_gregset (regcache, (const gdb_byte *) gregsetp); > + regcache_supply_regset (&aarch64_linux_gregset, regcache, -1, > + (const gdb_byte *) gregsetp, > + AARCH64_LINUX_SIZEOF_GREGSET); > } > > /* Fill register REGNO (if it is a floating-point register) in > @@ -643,22 +640,9 @@ void > fill_fpregset (const struct regcache *regcache, > gdb_fpregset_t *fpregsetp, int regno) > { > - gdb_byte *fpregs_buf = (gdb_byte *) fpregsetp; > - int i; > - > - for (i = AARCH64_V0_REGNUM; i <= AARCH64_V31_REGNUM; i++) > - if (regno == -1 || regno == i) > - regcache_raw_collect (regcache, i, > - fpregs_buf + V_REGISTER_SIZE > - * (i - AARCH64_V0_REGNUM)); > - > - if (regno == -1 || regno == AARCH64_FPSR_REGNUM) > - regcache_raw_collect (regcache, AARCH64_FPSR_REGNUM, > - fpregs_buf + V_REGISTER_SIZE * 32); > - > - if (regno == -1 || regno == AARCH64_FPCR_REGNUM) > - regcache_raw_collect (regcache, AARCH64_FPCR_REGNUM, > - fpregs_buf + V_REGISTER_SIZE * 32 + 4); > + regcache_collect_regset (&aarch64_linux_fpregset, regcache, > + regno, (gdb_byte *) fpregsetp, > + AARCH64_LINUX_SIZEOF_FPREGSET); > } > > /* Fill GDB's register array with the floating-point register values > @@ -667,7 +651,9 @@ fill_fpregset (const struct regcache *regcache, > void > supply_fpregset (struct regcache *regcache, const gdb_fpregset_t *fpregsetp) > { > - aarch64_linux_supply_fpregset (regcache, (const gdb_byte *) fpregsetp); > + regcache_supply_regset (&aarch64_linux_fpregset, regcache, -1, > + (const gdb_byte *) fpregsetp, > + AARCH64_LINUX_SIZEOF_FPREGSET); > } > > /* Called when resuming a thread. > diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c > index 30ed73f..b3eaa95 100644 > --- a/gdb/aarch64-linux-tdep.c > +++ b/gdb/aarch64-linux-tdep.c > @@ -41,16 +41,6 @@ > #include "user-regs.h" > #include > > -/* The general-purpose regset consists of 31 X registers, plus SP, PC, > - and PSTATE registers, as defined in the AArch64 port of the Linux > - kernel. */ > -#define AARCH64_LINUX_SIZEOF_GREGSET (34 * X_REGISTER_SIZE) > - > -/* The fp regset consists of 32 V registers, plus FPCR and FPSR which > - are 4 bytes wide each, and the whole structure is padded to 128 bit > - alignment. */ > -#define AARCH64_LINUX_SIZEOF_FPREGSET (33 * V_REGISTER_SIZE) > - > /* Signal frame handling. > > +------------+ ^ > @@ -190,71 +180,37 @@ static const struct tramp_frame aarch64_linux_rt_sigframe = > aarch64_linux_sigframe_init > }; > > -/* Fill GDB's register array with the general-purpose register values > - in the buffer pointed by GREGS_BUF. */ > - > -void > -aarch64_linux_supply_gregset (struct regcache *regcache, > - const gdb_byte *gregs_buf) > -{ > - int regno; > - > - for (regno = AARCH64_X0_REGNUM; regno <= AARCH64_CPSR_REGNUM; regno++) > - regcache_raw_supply (regcache, regno, > - gregs_buf + X_REGISTER_SIZE > - * (regno - AARCH64_X0_REGNUM)); > -} > - > -/* The "supply_regset" function for the general-purpose register set. */ > - > -static void > -supply_gregset_from_core (const struct regset *regset, > - struct regcache *regcache, > - int regnum, const void *regbuf, size_t len) > -{ > - aarch64_linux_supply_gregset (regcache, (const gdb_byte *) regbuf); > -} > - > -/* Fill GDB's register array with the floating-point register values > - in the buffer pointed by FPREGS_BUF. */ > +/* Register maps. */ > > -void > -aarch64_linux_supply_fpregset (struct regcache *regcache, > - const gdb_byte *fpregs_buf) > -{ > - int regno; > - > - for (regno = AARCH64_V0_REGNUM; regno <= AARCH64_V31_REGNUM; regno++) > - regcache_raw_supply (regcache, regno, > - fpregs_buf + V_REGISTER_SIZE > - * (regno - AARCH64_V0_REGNUM)); > - > - regcache_raw_supply (regcache, AARCH64_FPSR_REGNUM, > - fpregs_buf + V_REGISTER_SIZE * 32); > - regcache_raw_supply (regcache, AARCH64_FPCR_REGNUM, > - fpregs_buf + V_REGISTER_SIZE * 32 + 4); > -} > - > -/* The "supply_regset" function for the floating-point register set. */ > +static const struct regcache_map_entry aarch64_linux_gregmap[] = > + { > + { 31, AARCH64_X0_REGNUM }, /* x0 ... x30 */ > + { 1, AARCH64_SP_REGNUM }, > + { 1, AARCH64_PC_REGNUM }, > + { 1, AARCH64_CPSR_REGNUM }, > + { 0 } > + }; > > -static void > -supply_fpregset_from_core (const struct regset *regset, > - struct regcache *regcache, > - int regnum, const void *regbuf, size_t len) > -{ > - aarch64_linux_supply_fpregset (regcache, (const gdb_byte *) regbuf); > -} > +static const struct regcache_map_entry aarch64_linux_fpregmap[] = > + { > + { 32, AARCH64_V0_REGNUM }, /* v0 ... v31 */ > + { 1, AARCH64_FPSR_REGNUM }, > + { 1, AARCH64_FPCR_REGNUM }, > + { 0 } > + }; > > -/* Register set definitions. */ > +/* Register set definitions. */ > > -static const struct regset aarch64_linux_gregset = > +const struct regset aarch64_linux_gregset = > { > - NULL, supply_gregset_from_core, NULL > + aarch64_linux_gregmap, > + regcache_supply_regset, regcache_collect_regset > }; > > -static const struct regset aarch64_linux_fpregset = > +const struct regset aarch64_linux_fpregset = > { > - NULL, supply_fpregset_from_core, NULL > + aarch64_linux_fpregmap, > + regcache_supply_regset, regcache_collect_regset > }; > > /* Implement the "regset_from_core_section" gdbarch method. */ > diff --git a/gdb/aarch64-linux-tdep.h b/gdb/aarch64-linux-tdep.h > index 48c7092..2e1de60 100644 > --- a/gdb/aarch64-linux-tdep.h > +++ b/gdb/aarch64-linux-tdep.h > @@ -18,9 +18,17 @@ > You should have received a copy of the GNU General Public License > along with this program. If not, see . */ > > -struct regcache; > +#include "regset.h" > > -extern void aarch64_linux_supply_gregset (struct regcache *regcache, > - const gdb_byte *gregs_buf); > -extern void aarch64_linux_supply_fpregset (struct regcache *regcache, > - const gdb_byte *fpregs_buf); > +/* The general-purpose regset consists of 31 X registers, plus SP, PC, > + and PSTATE registers, as defined in the AArch64 port of the Linux > + kernel. */ > +#define AARCH64_LINUX_SIZEOF_GREGSET (34 * X_REGISTER_SIZE) > + > +/* The fp regset consists of 32 V registers, plus FPCR and FPSR which > + are 4 bytes wide each, and the whole structure is padded to 128 bit > + alignment. */ > +#define AARCH64_LINUX_SIZEOF_FPREGSET (33 * V_REGISTER_SIZE) > + > +extern const struct regset aarch64_linux_gregset; > +extern const struct regset aarch64_linux_fpregset; > -- > 1.8.4.2 > Looks good to me.