@@ -1565,7 +1565,7 @@ i387_collect_xsave (const struct regcache *regcache, int regnum,
byte_order, I387_FCTRL_INIT_VAL);
else
memset (FXSAVE_ADDR (tdep, regs, i), 0,
- regcache_register_size (regcache, i));
+ regcache->register_size (i));
}
}
}
@@ -1888,7 +1888,7 @@ i387_collect_xsave (const struct regcache *regcache, int regnum,
int regsize;
regcache->raw_collect (i, raw);
- regsize = regcache_register_size (regcache, i);
+ regsize = regcache->register_size (i);
p = FXSAVE_ADDR (tdep, regs, i);
if (memcmp (raw, p, regsize))
{
@@ -166,7 +166,7 @@ aarch64_point_is_aligned (ptid_t ptid, int is_watchpoint, CORE_ADDR addr,
/* Set alignment to 2 only if the current process is 32-bit,
since thumb instruction can be 2-byte aligned. Otherwise, set
alignment to AARCH64_HBP_ALIGNMENT. */
- if (regcache_register_size (regcache, 0) == 8)
+ if (regcache->register_size (0) == 8)
alignment = AARCH64_HBP_ALIGNMENT;
else
alignment = 2;
@@ -110,7 +110,7 @@ class register_dump_reg_buffer : public register_dump, reg_buffer
{
if (regnum < gdbarch_num_regs (m_gdbarch) || m_has_pseudo)
{
- auto size = register_size (m_gdbarch, regnum);
+ auto size = register_size (regnum);
if (size == 0)
return;
@@ -179,10 +179,9 @@ register_size (struct gdbarch *gdbarch, int regnum)
/* See gdbsupport/common-regcache.h. */
int
-regcache_register_size (const reg_buffer_common *regcache, int n)
+reg_buffer::register_size (int regnum) const
{
- return register_size
- (gdb::checked_static_cast<const struct regcache *> (regcache)->arch (), n);
+ return ::register_size (this->arch (), regnum);
}
reg_buffer::reg_buffer (gdbarch *gdbarch, bool has_pseudo)
@@ -939,7 +938,7 @@ register_status
readable_regcache::read_part (int regnum, int offset,
gdb::array_view<gdb_byte> dst, bool is_raw)
{
- int reg_size = register_size (arch (), regnum);
+ int reg_size = register_size (regnum);
gdb_assert (offset >= 0);
gdb_assert (offset + dst.size () <= reg_size);
@@ -983,7 +982,7 @@ void
reg_buffer::raw_collect_part (int regnum, int offset,
gdb::array_view<gdb_byte> dst) const
{
- int reg_size = register_size (arch (), regnum);
+ int reg_size = register_size (regnum);
gdb_assert (offset >= 0);
gdb_assert (offset + dst.size () <= reg_size);
@@ -1013,7 +1012,7 @@ register_status
regcache::write_part (int regnum, int offset,
gdb::array_view<const gdb_byte> src, bool is_raw)
{
- int reg_size = register_size (arch (), regnum);
+ int reg_size = register_size (regnum);
gdb_assert (offset >= 0);
gdb_assert (offset + src.size () <= reg_size);
@@ -1065,7 +1064,7 @@ void
reg_buffer::raw_supply_part (int regnum, int offset,
gdb::array_view<const gdb_byte> src)
{
- int reg_size = register_size (arch (), regnum);
+ int reg_size = register_size (regnum);
gdb_assert (offset >= 0);
gdb_assert (offset + src.size () <= reg_size);
@@ -1226,8 +1225,7 @@ regcache::transfer_regset_register (struct regcache *out_regcache, int regnum,
const gdb_byte *in_buf, gdb_byte *out_buf,
int slot_size, int offs) const
{
- struct gdbarch *gdbarch = arch ();
- int reg_size = std::min (register_size (gdbarch, regnum), slot_size);
+ int reg_size = std::min (register_size (regnum), slot_size);
/* Use part versions and reg_size to prevent possible buffer overflows when
accessing the regcache. */
@@ -1244,7 +1242,7 @@ regcache::transfer_regset_register (struct regcache *out_regcache, int regnum,
else if (in_buf != nullptr)
{
/* Zero-extend the register value if the slot is smaller than the register. */
- if (slot_size < register_size (gdbarch, regnum))
+ if (slot_size < register_size (regnum))
out_regcache->raw_supply_zeroed (regnum);
out_regcache->raw_supply_part (regnum, 0,
gdb::make_array_view (in_buf + offs,
@@ -256,6 +256,9 @@ class reg_buffer : public reg_buffer_common
/* See gdbsupport/common-regcache.h. */
bool raw_compare (int regnum, const void *buf, int offset) const override;
+ /* See gdbsupport/common-regcache.h. */
+ int register_size (int regnum) const override;
+
protected:
/* Assert on the range of REGNUM. */
void assert_regnum (int regnum) const;
@@ -308,10 +308,9 @@ register_size (const struct target_desc *tdesc, int n)
/* See gdbsupport/common-regcache.h. */
int
-regcache_register_size (const reg_buffer_common *regcache, int n)
+regcache::register_size (int regnum) const
{
- return register_size
- (gdb::checked_static_cast<const struct regcache *> (regcache)->tdesc, n);
+ return ::register_size (tdesc, regnum);
}
static gdb::array_view<gdb_byte>
@@ -49,6 +49,9 @@ struct regcache : public reg_buffer_common
/* See gdbsupport/common-regcache.h. */
enum register_status get_register_status (int regnum) const override;
+ /* See gdbsupport/common-regcache.h. */
+ int register_size (int regnum) const override;
+
/* See gdbsupport/common-regcache.h. */
void raw_supply (int regnum, gdb::array_view<const gdb_byte> src) override;
@@ -48,11 +48,6 @@ enum register_status : signed char
extern reg_buffer_common *get_thread_regcache_for_ptid (ptid_t ptid);
-/* Return the size of register numbered N in REGCACHE. This function
- must be provided by the client. */
-
-extern int regcache_register_size (const reg_buffer_common *regcache, int n);
-
/* Read the PC register. This function must be provided by the
client. */
@@ -78,6 +73,9 @@ struct reg_buffer_common
buffer. */
virtual register_status get_register_status (int regnum) const = 0;
+ /* Return the size of register numbered REGNUM in this buffer. */
+ virtual int register_size (int regnum) const = 0;
+
/* Supply register REGNUM, whose contents are stored in SRC, to this register
buffer. */
virtual void raw_supply (int regnum, gdb::array_view<const gdb_byte> src)
@@ -91,9 +89,7 @@ struct reg_buffer_common
void raw_supply (int regnum, const gdb_byte *src)
{
- raw_supply (regnum,
- gdb::make_array_view (src,
- regcache_register_size (this, regnum)));
+ raw_supply (regnum, gdb::make_array_view (src, register_size (regnum)));
}
/* Collect register REGNUM from this register buffer and store its contents in
@@ -109,9 +105,7 @@ struct reg_buffer_common
void raw_collect (int regnum, gdb_byte *dst)
{
- raw_collect (regnum,
- gdb::make_array_view (dst,
- regcache_register_size (this, regnum)));
+ raw_collect (regnum, gdb::make_array_view (dst, register_size (regnum)));
}
/* Compare the contents of the register stored in the regcache (ignoring the