From: Andreas Arnez <arnez@linux.vnet.ibm.com>
To: gdb-patches@sourceware.org
Cc: Richard Earnshaw <rearnsha@arm.com>
Subject: [RFC 14/23] AARCH64 Linux: Fill 'collect_regset' in regset structures
Date: Mon, 28 Apr 2014 09:55:00 -0000 [thread overview]
Message-ID: <87mwf53hib.fsf@br87z6lw.de.ibm.com> (raw)
In-Reply-To: <87eh0h6bkq.fsf@br87z6lw.de.ibm.com> (Andreas Arnez's message of "Mon, 28 Apr 2014 11:35:33 +0200")
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 <ctype.h>
-/* 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 <http://www.gnu.org/licenses/>. */
-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
next prev parent reply other threads:[~2014-04-28 9:55 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-28 9:35 [RFC 00/23] Regset rework preparations Andreas Arnez
2014-04-28 9:39 ` [RFC 01/23] Constify regset structures Andreas Arnez
2014-05-05 9:45 ` Mark Kettenis
2014-04-28 9:40 ` [RFC 02/23] Remove 'arch' field from regset structure Andreas Arnez
2014-05-05 9:32 ` Mark Kettenis
2014-05-05 13:35 ` Andreas Arnez
2014-04-28 9:44 ` [RFC 03/23] AARCH64: Replace regset_alloc() invocations by static regset structures Andreas Arnez
2014-04-28 9:46 ` [RFC 04/23] ARM: " Andreas Arnez
2014-04-28 9:47 ` [RFC 05/23] X86: " Andreas Arnez
2014-04-28 15:33 ` Mark Kettenis
2014-04-29 8:58 ` Andreas Arnez
2014-04-28 9:48 ` [RFC 06/23] MIPS: " Andreas Arnez
2014-04-28 9:49 ` [RFC 07/23] MN10300: " Andreas Arnez
2014-04-28 9:50 ` [RFC 08/23] SCORE: Replace regset_alloc() invocation by a static regset structure Andreas Arnez
2014-04-28 9:51 ` [RFC 09/23] SPARC: Rename register maps from "*regset" to "*regmap" Andreas Arnez
2014-05-05 9:50 ` Mark Kettenis
2014-04-28 9:52 ` [RFC 10/23] SPARC: Replace regset_alloc() invocations by static regset structures Andreas Arnez
2014-05-05 9:52 ` Mark Kettenis
2014-04-28 9:53 ` [RFC 11/23] Drop regset_alloc() Andreas Arnez
2014-05-05 9:53 ` Mark Kettenis
2014-04-28 9:54 ` [RFC 13/23] S390: Migrate to regcache_supply/collect_regset Andreas Arnez
2014-04-28 9:54 ` [RFC 12/23] regcache: Add functions suitable for regset_supply/collect Andreas Arnez
2014-05-05 10:02 ` Mark Kettenis
2014-05-05 15:34 ` Andreas Arnez
2014-04-28 9:55 ` Andreas Arnez [this message]
2014-04-28 9:56 ` [RFC 15/23] ALPHA Linux: Fill 'collect_regset' in regset structures Andreas Arnez
2014-04-28 9:57 ` [RFC 16/23] FRV " Andreas Arnez
2014-04-28 9:58 ` [RFC 17/23] HPPA " Andreas Arnez
2014-04-28 9:59 ` [RFC 18/23] M32R Linux: Fill 'collect_regset' in regset structure Andreas Arnez
2014-04-28 9:59 ` [RFC 19/23] NIOS2 " Andreas Arnez
2014-04-28 10:00 ` [RFC 20/23] SCORE: " Andreas Arnez
2014-04-28 10:01 ` [RFC 21/23] TILEGX Linux: " Andreas Arnez
2014-04-28 10:01 ` [RFC 22/23] M68K Linux: Define regset structures Andreas Arnez
2014-04-28 10:02 ` [RFC 23/23] IA64 " Andreas Arnez
2014-04-28 15:29 ` [RFC 00/23] Regset rework preparations Maciej W. Rozycki
2014-04-28 15:38 ` Andreas Arnez
2014-05-08 10:31 ` Andreas Arnez
2014-05-05 8:09 ` [ping] " Andreas Arnez
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87mwf53hib.fsf@br87z6lw.de.ibm.com \
--to=arnez@linux.vnet.ibm.com \
--cc=gdb-patches@sourceware.org \
--cc=rearnsha@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox