+typedef gdb::function_view<register_status (int regnum, gdb_byte *buf)>
+ register_read_ftype;
+
+/* A (register_number, register_value) pair. */
+
+typedef struct cached_reg
+{
+ int num;
+ gdb_byte *data;
+} cached_reg_t;
+
+/* Buffer of registers. */
+
+class reg_buffer : public reg_buffer_common
+{
+public:
+ reg_buffer (gdbarch *gdbarch, bool has_pseudo);
+
+ DISABLE_COPY_AND_ASSIGN (reg_buffer);
+
+ /* Return regcache's architecture. */
+ gdbarch *arch () const;
+
+ /* See gdbsupport/common-regcache.h. */
+ enum register_status get_register_status (int regnum) const override;
+
+ /* See gdbsupport/common-regcache.h. */
+ void raw_collect (int regnum, void *buf) const override;
+
+ /* Collect register REGNUM from REGCACHE. Store collected value as an integer
+ at address ADDR, in target endian, with length ADDR_LEN and sign IS_SIGNED.
+ If ADDR_LEN is greater than the register size, then the integer will be
+ sign or zero extended. If ADDR_LEN is smaller than the register size, then
+ the most significant bytes of the integer will be truncated. */
+ void raw_collect_integer (int regnum, gdb_byte *addr, int addr_len,
+ bool is_signed) const;
+
+ /* Collect register REGNUM from REGCACHE, starting at OFFSET in register,
+ reading only LEN. */
+ void raw_collect_part (int regnum, int offset, int len, gdb_byte *out) const;
+
+ /* See gdbsupport/common-regcache.h. */
+ void raw_supply (int regnum, const void *buf) override;
+
+ void raw_supply (int regnum, const reg_buffer &src)
+ {
+ raw_supply (regnum, src.register_buffer (regnum));
+ }
+
+ /* Supply register REGNUM to REGCACHE. Value to supply is an integer stored
+ at address ADDR, in target endian, with length ADDR_LEN and sign IS_SIGNED.
+ If the register size is greater than ADDR_LEN, then the integer will be
+ sign or zero extended. If the register size is smaller than the integer,
+ then the most significant bytes of the integer will be truncated. */
+ void raw_supply_integer (int regnum, const gdb_byte *addr, int addr_len,
+ bool is_signed);
+
+ /* Supply register REGNUM with zeroed value to REGCACHE. This is not the same
+ as calling raw_supply with NULL (which will set the state to
+ unavailable). */
+ void raw_supply_zeroed (int regnum);
+
+ /* Supply register REGNUM to REGCACHE, starting at OFFSET in register, writing
+ only LEN, without editing the rest of the register. */
+ void raw_supply_part (int regnum, int offset, int len, const gdb_byte *in);
+
+ void invalidate (int regnum);
+
+ virtual ~reg_buffer () = default;
+
+ /* See gdbsupport/common-regcache.h. */
+ bool raw_compare (int regnum, const void *buf, int offset) const override;
+
+protected:
+ /* Assert on the range of REGNUM. */
+ void assert_regnum (int regnum) const;
+
+ int num_raw_registers () const;
+
+ gdb_byte *register_buffer (int regnum) const;
+
+ /* Save a register cache. The set of registers saved into the
+ regcache determined by the save_reggroup. COOKED_READ returns
+ zero iff the register's value can't be returned. */
+ void save (register_read_ftype cooked_read);
+
+ struct regcache_descr *m_descr;
+
+ bool m_has_pseudo;
+ /* The register buffers. */
+ std::unique_ptr<gdb_byte[]> m_registers;
+ /* Register cache status. */
+ std::unique_ptr<register_status[]> m_register_status;
+
+ friend class regcache;
+ friend class detached_regcache;
+};
+
+/* An abstract class which only has methods doing read. */