summaryrefslogtreecommitdiff
path: root/gdb/regcache.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/regcache.c')
-rw-r--r--gdb/regcache.c36
1 files changed, 20 insertions, 16 deletions
diff --git a/gdb/regcache.c b/gdb/regcache.c
index 6fd4f86f4b..a22a839d90 100644
--- a/gdb/regcache.c
+++ b/gdb/regcache.c
@@ -41,19 +41,17 @@
/* Per-architecture object describing the layout of a register cache.
Computed once when the architecture is created. */
-static struct gdbarch_data *regcache_descr_handle;
-
struct regcache_descr
{
/* The architecture this descriptor belongs to. */
- struct gdbarch *gdbarch;
+ struct gdbarch *gdbarch = nullptr;
/* The raw register cache. Each raw (or hard) register is supplied
by the target interface. The raw cache should not contain
redundant information - if the PC is constructed from two
registers then those registers and not the PC lives in the raw
cache. */
- long sizeof_raw_registers;
+ long sizeof_raw_registers = 0;
/* The cooked register space. Each cooked register in the range
[0..NR_RAW_REGISTERS) is direct-mapped onto the corresponding raw
@@ -61,21 +59,24 @@ struct regcache_descr
.. NR_COOKED_REGISTERS) (a.k.a. pseudo registers) are mapped onto
both raw registers and memory by the architecture methods
gdbarch_pseudo_register_read and gdbarch_pseudo_register_write. */
- int nr_cooked_registers;
- long sizeof_cooked_registers;
+ int nr_cooked_registers = 0;
+ long sizeof_cooked_registers = 0;
/* Offset and size (in 8 bit bytes), of each register in the
register cache. All registers (including those in the range
[NR_RAW_REGISTERS .. NR_COOKED_REGISTERS) are given an
offset. */
- long *register_offset;
- long *sizeof_register;
+ long *register_offset = nullptr;
+ long *sizeof_register = nullptr;
/* Cached table containing the type of each register. */
- struct type **register_type;
+ struct type **register_type = nullptr;
};
-static void *
+static const registry<gdbarch>::key<struct regcache_descr>
+ regcache_descr_handle;
+
+static struct regcache_descr *
init_regcache_descr (struct gdbarch *gdbarch)
{
int i;
@@ -83,7 +84,7 @@ init_regcache_descr (struct gdbarch *gdbarch)
gdb_assert (gdbarch != NULL);
/* Create an initial, zero filled, table. */
- descr = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct regcache_descr);
+ descr = new struct regcache_descr;
descr->gdbarch = gdbarch;
/* Total size of the register space. The raw registers are mapped
@@ -140,8 +141,14 @@ init_regcache_descr (struct gdbarch *gdbarch)
static struct regcache_descr *
regcache_descr (struct gdbarch *gdbarch)
{
- return (struct regcache_descr *) gdbarch_data (gdbarch,
- regcache_descr_handle);
+ struct regcache_descr *result = regcache_descr_handle.get (gdbarch);
+ if (result == nullptr)
+ {
+ result = init_regcache_descr (gdbarch);
+ regcache_descr_handle.set (gdbarch, result);
+ }
+
+ return result;
}
/* Utility functions returning useful register attributes stored in
@@ -2119,9 +2126,6 @@ _initialize_regcache ()
{
struct cmd_list_element *c;
- regcache_descr_handle
- = gdbarch_data_register_post_init (init_regcache_descr);
-
gdb::observers::target_changed.attach (regcache_observer_target_changed,
"regcache");
gdb::observers::thread_ptid_changed.attach (regcache_thread_ptid_changed,