From: Andreas Arnez <arnez@linux.vnet.ibm.com>
To: gdb-patches@sourceware.org
Cc: Mark Kettenis <kettenis@gnu.org>
Subject: [RFC 05/23] X86: Replace regset_alloc() invocations by static regset structures.
Date: Mon, 28 Apr 2014 09:47:00 -0000 [thread overview]
Message-ID: <87ppk14wh4.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")
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_supply_regset): Adjust call to
x86-common regset supply function, now reachable via
'i386_gregset.supply_regset'.
(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_supply_gregset, 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_supply_gregset, i386_collect_gregset): Remove prototypes.
(i386_gregset): New declaration.
* i386obsd-tdep.c (i386obsd_aout_supply_regset): Adjust call to
x86-common regset supply function.
(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 | 14 ++++++++------
gdb/i386-cygwin-tdep.c | 9 +--------
gdb/i386-nto-tdep.c | 8 ++------
gdb/i386-tdep.c | 48 ++++++++++++++++++++++--------------------------
gdb/i386-tdep.h | 21 ++-------------------
gdb/i386obsd-tdep.c | 15 ++++++++-------
7 files changed, 55 insertions(+), 87 deletions(-)
diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c
index df4a3f4..b17bc45 100644
--- a/gdb/amd64-tdep.c
+++ b/gdb/amd64-tdep.c
@@ -2884,6 +2884,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. */
@@ -2894,23 +2904,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 c5ed731..e7041c9 100644
--- a/gdb/amd64obsd-tdep.c
+++ b/gdb/amd64obsd-tdep.c
@@ -49,11 +49,17 @@ amd64obsd_supply_regset (const struct regset *regset,
gdb_assert (len >= tdep->sizeof_gregset + I387_SIZEOF_FXSAVE);
- i386_supply_gregset (regset, regcache, regnum, regs, tdep->sizeof_gregset);
+ i386_gregset.supply_regset (regset, regcache, regnum, regs,
+ tdep->sizeof_gregset);
amd64_supply_fxsave (regcache, regnum,
((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)
@@ -65,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 de783f6..bee27f8 100644
--- a/gdb/i386-tdep.c
+++ b/gdb/i386-tdep.c
@@ -3720,7 +3720,7 @@ i386_value_to_register (struct frame_info *frame, int regnum,
in the general-purpose register set REGSET to register cache
REGCACHE. If REGNUM is -1, do this for all registers in REGSET. */
-void
+static void
i386_supply_gregset (const struct regset *regset, struct regcache *regcache,
int regnum, const void *gregs, size_t len)
{
@@ -3743,7 +3743,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)
@@ -3824,6 +3824,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. */
@@ -3834,32 +3851,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;
}
@@ -8283,17 +8283,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..fd601f2 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. */
@@ -382,20 +377,8 @@ extern int i386_sigtramp_p (struct frame_info *this_frame);
extern int i386_register_reggroup_p (struct gdbarch *gdbarch, int regnum,
struct reggroup *group);
-/* Supply register REGNUM from the general-purpose register set REGSET
- to register cache REGCACHE. If REGNUM is -1, do this for all
- registers in REGSET. */
-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 bc29606..46b4719 100644
--- a/gdb/i386obsd-tdep.c
+++ b/gdb/i386obsd-tdep.c
@@ -147,10 +147,16 @@ i386obsd_aout_supply_regset (const struct regset *regset,
gdb_assert (len >= tdep->sizeof_gregset + I387_SIZEOF_FSAVE);
- i386_supply_gregset (regset, regcache, regnum, regs, tdep->sizeof_gregset);
+ i386_gregset.supply_regset (regset, regcache, regnum, regs,
+ tdep->sizeof_gregset);
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,
@@ -163,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;
}
--
1.8.4.2
next prev parent reply other threads:[~2014-04-28 9:47 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 ` Andreas Arnez [this message]
2014-04-28 15:33 ` [RFC 05/23] X86: " 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 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:54 ` [RFC 13/23] S390: Migrate to regcache_supply/collect_regset Andreas Arnez
2014-04-28 9:55 ` [RFC 14/23] AARCH64 Linux: Fill 'collect_regset' in regset structures Andreas Arnez
2014-04-28 9:56 ` [RFC 15/23] ALPHA " 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 19/23] NIOS2 Linux: Fill 'collect_regset' in regset structure Andreas Arnez
2014-04-28 9:59 ` [RFC 18/23] M32R " Andreas Arnez
2014-04-28 10:00 ` [RFC 20/23] SCORE: " Andreas Arnez
2014-04-28 10:01 ` [RFC 22/23] M68K Linux: Define regset structures Andreas Arnez
2014-04-28 10:01 ` [RFC 21/23] TILEGX Linux: Fill 'collect_regset' in regset structure Andreas Arnez
2014-04-28 10:02 ` [RFC 23/23] IA64 Linux: Define regset structures 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=87ppk14wh4.fsf@br87z6lw.de.ibm.com \
--to=arnez@linux.vnet.ibm.com \
--cc=gdb-patches@sourceware.org \
--cc=kettenis@gnu.org \
/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