+/* See regcache.h. */
+
+void
+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);
+
+ /* Use part versions and reg_size to prevent possible buffer overflows when
+ accessing the regcache. */
+
+ if (out_buf != nullptr)
+ {
+ raw_collect_part (regnum, 0, reg_size, out_buf + offs);
+
+ /* Ensure any additional space is cleared. */
+ if (slot_size > reg_size)
+ memset (out_buf + offs + reg_size, 0, slot_size - reg_size);
+ }
+ else if (in_buf != nullptr)
+ out_regcache->raw_supply_part (regnum, 0, reg_size, in_buf + offs);
+ else
+ {
+ /* Invalidate the register. */
+ out_regcache->raw_supply (regnum, nullptr);
+ }
+}
+
+/* See regcache.h. */
+