From patchwork Mon Apr 28 09:55:40 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Arnez X-Patchwork-Id: 710 Return-Path: X-Original-To: siddhesh@wilcox.dreamhost.com Delivered-To: siddhesh@wilcox.dreamhost.com Received: from homiemail-mx21.g.dreamhost.com (peon2454.g.dreamhost.com [208.113.200.127]) by wilcox.dreamhost.com (Postfix) with ESMTP id D49BD36007C for ; Mon, 28 Apr 2014 02:55:54 -0700 (PDT) Received: by homiemail-mx21.g.dreamhost.com (Postfix, from userid 14314964) id 774B9138EB0B; Mon, 28 Apr 2014 02:55:54 -0700 (PDT) X-Original-To: gdb@patchwork.siddhesh.in Delivered-To: x14314964@homiemail-mx21.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-mx21.g.dreamhost.com (Postfix) with ESMTPS id 43482138EB0B for ; Mon, 28 Apr 2014 02:55:54 -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:cc:subject:references:date:in-reply-to :message-id:mime-version:content-type; q=dns; s=default; b=wS+zO PhKInVUIYXecJ7K5RCi/yfn1hNA81+eT+1WemkTUq6JdWeuXOPcnyxP6CaCdIdMm 5ld2hOjfCjz7IZ7sZIpxiO6z5I8HFBnYFd0CZgay7odXJX62Zl7/4hXrghvReOV6 59XjOJHSTXpabL10ESNkXqprIdiHzc1z+q7zLI= 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:cc:subject:references:date:in-reply-to :message-id:mime-version:content-type; s=default; bh=z4c2zdgA3wa eeE+KTJW4OtnPXbE=; b=ujKaGP9yZtWZqmM4Ez/u7gexXOkF0TihkRwaDnI3kxl C48l+ItDyXwCsEXbEOKn9bi8+pBWHAcR3a5u0ee028EGaDj75yjzwOdO50AZniP2 lkkHLGIigA75FY0rgoJJjTD6hdOBSTL3xJhy/qtMDvpWQkPAX6MDcP4VAuyMAPX0 = Received: (qmail 9883 invoked by alias); 28 Apr 2014 09:55:52 -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 9869 invoked by uid 89); 28 Apr 2014 09:55:52 -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: e06smtp15.uk.ibm.com Received: from e06smtp15.uk.ibm.com (HELO e06smtp15.uk.ibm.com) (195.75.94.111) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Mon, 28 Apr 2014 09:55:51 +0000 Received: from /spool/local by e06smtp15.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Apr 2014 10:55:48 +0100 Received: from d06dlp03.portsmouth.uk.ibm.com (9.149.20.15) by e06smtp15.uk.ibm.com (192.168.101.145) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Apr 2014 10:55:45 +0100 Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by d06dlp03.portsmouth.uk.ibm.com (Postfix) with ESMTP id 60CFA1B08051 for ; Mon, 28 Apr 2014 10:55:52 +0100 (BST) Received: from d06av04.portsmouth.uk.ibm.com (d06av04.portsmouth.uk.ibm.com [9.149.37.216]) by b06cxnps4075.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id s3S9tiQV49610934 for ; Mon, 28 Apr 2014 09:55:44 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 s3S9thYh012840 for ; Mon, 28 Apr 2014 03:55:44 -0600 Received: from br87z6lw.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 s3S9te5C012688; Mon, 28 Apr 2014 03:55:41 -0600 From: Andreas Arnez To: gdb-patches@sourceware.org Cc: Richard Earnshaw Subject: [RFC 14/23] AARCH64 Linux: Fill 'collect_regset' in regset structures References: <87eh0h6bkq.fsf@br87z6lw.de.ibm.com> Date: Mon, 28 Apr 2014 11:55:40 +0200 In-Reply-To: <87eh0h6bkq.fsf@br87z6lw.de.ibm.com> (Andreas Arnez's message of "Mon, 28 Apr 2014 11:35:33 +0200") Message-ID: <87mwf53hib.fsf@br87z6lw.de.ibm.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) MIME-Version: 1.0 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 14042809-0342-0000-0000-00000894C100 X-IsSubscribed: yes X-DH-Original-To: gdb@patchwork.siddhesh.in 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 28ad38b..bc9beb0 100644 --- a/gdb/aarch64-linux-nat.c +++ b/gdb/aarch64-linux-nat.c @@ -615,14 +615,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 @@ -631,7 +626,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 @@ -642,22 +639,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 @@ -666,7 +650,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 6f52c8c..8e30d74 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. +----------+ ^ @@ -185,71 +175,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;