aboutsummaryrefslogtreecommitdiff
path: root/gdb/regcache.c
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2022-11-22 14:21:13 -0800
committerJohn Baldwin <jhb@FreeBSD.org>2022-11-22 14:33:17 -0800
commit0ee9f16cf9ff849fda1555033ae0ce78d028bf86 (patch)
tree5acef3fe6a904ea2b1a2c1d6460b296948d84912 /gdb/regcache.c
parent04ad71937f28561ad5a2bbbc7e8f0af21e1019f8 (diff)
downloadgdb-0ee9f16cf9ff849fda1555033ae0ce78d028bf86.zip
gdb-0ee9f16cf9ff849fda1555033ae0ce78d028bf86.tar.gz
gdb-0ee9f16cf9ff849fda1555033ae0ce78d028bf86.tar.bz2
regcache: Add collect/supply_regset variants that accept a register base.
Some register sets described by an array of regcache_map_entry structures do not have fixed register numbers in their associated architecture but do describe a block of registers whose numbers are at fixed offsets relative to some base register value. An example of this are the TLS register sets for the ARM and AArch64 architectures. Currently OS-specific architectures create register maps and register sets dynamically using the register base number. However, this requires duplicating the code to create the register map and register set. To reduce duplication, add variants of the collect_regset and supply_regset regcache methods which accept a base register number. For valid register map entries (i.e. not REGCACHE_MAP_SKIP), add this base register number to the value from the map entry to determine the final register number. Approved-By: Simon Marchi <simon.marchi@efficios.com>
Diffstat (limited to 'gdb/regcache.c')
-rw-r--r--gdb/regcache.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/gdb/regcache.c b/gdb/regcache.c
index 650e5bb..02d6bdc 100644
--- a/gdb/regcache.c
+++ b/gdb/regcache.c
@@ -1185,7 +1185,7 @@ regcache::transfer_regset_register (struct regcache *out_regcache, int regnum,
/* See regcache.h. */
void
-regcache::transfer_regset (const struct regset *regset,
+regcache::transfer_regset (const struct regset *regset, int regbase,
struct regcache *out_regcache,
int regnum, const gdb_byte *in_buf,
gdb_byte *out_buf, size_t size) const
@@ -1200,6 +1200,9 @@ regcache::transfer_regset (const struct regset *regset,
int regno = map->regno;
int slot_size = map->size;
+ if (regno != REGCACHE_MAP_SKIP)
+ regno += regbase;
+
if (slot_size == 0 && regno != REGCACHE_MAP_SKIP)
slot_size = m_descr->sizeof_register[regno];
@@ -1243,11 +1246,14 @@ regcache_supply_regset (const struct regset *regset,
regcache->supply_regset (regset, regnum, (const gdb_byte *) buf, size);
}
+/* See regcache.h. */
+
void
-regcache::supply_regset (const struct regset *regset,
+regcache::supply_regset (const struct regset *regset, int regbase,
int regnum, const void *buf, size_t size)
{
- transfer_regset (regset, this, regnum, (const gdb_byte *) buf, nullptr, size);
+ transfer_regset (regset, regbase, this, regnum, (const gdb_byte *) buf,
+ nullptr, size);
}
/* Collect register REGNUM from REGCACHE to BUF, using the register
@@ -1262,15 +1268,16 @@ regcache_collect_regset (const struct regset *regset,
regcache->collect_regset (regset, regnum, (gdb_byte *) buf, size);
}
+/* See regcache.h */
+
void
-regcache::collect_regset (const struct regset *regset,
+regcache::collect_regset (const struct regset *regset, int regbase,
int regnum, void *buf, size_t size) const
{
- transfer_regset (regset, nullptr, regnum, nullptr, (gdb_byte *) buf, size);
+ transfer_regset (regset, regbase, nullptr, regnum, nullptr, (gdb_byte *) buf,
+ size);
}
-/* See regcache.h */
-
bool
regcache_map_supplies (const struct regcache_map_entry *map, int regnum,
struct gdbarch *gdbarch, size_t size)