aboutsummaryrefslogtreecommitdiff
path: root/gdb/regcache.h
diff options
context:
space:
mode:
authorAlan Hayward <alan.hayward@arm.com>2018-06-11 10:09:16 +0100
committerAlan Hayward <alan.hayward@arm.com>2018-06-11 10:09:16 +0100
commit9c861883169cb9eec4581ab6db3a1b711e79ee10 (patch)
tree24530802092757d9aaf0e0f93e0e7cae3507aa8d /gdb/regcache.h
parent953edf2b6cfe765ca7176c414e9f63aa62bdb09c (diff)
downloadgdb-9c861883169cb9eec4581ab6db3a1b711e79ee10.zip
gdb-9c861883169cb9eec4581ab6db3a1b711e79ee10.tar.gz
gdb-9c861883169cb9eec4581ab6db3a1b711e79ee10.tar.bz2
Add reg_buffer_common
A purely virtual class containing functions from gdb/regcache.h Both the gdb regcache structures and gdbserver regcache inherit directly from reg_buffer_common. This will allow for common functions which require the use of a regcache. gdb/ * common/common-regcache.h (reg_buffer_common): New structure. * regcache.c (reg_buffer::invalidate): Move from detached_regcache. (reg_buffer::raw_supply): Likewise. (reg_buffer::raw_supply_integer): Likewise. (reg_buffer::raw_supply_zeroed): Likewise. (reg_buffer::raw_collect): Likewise. (reg_buffer::raw_collect_integer): Likewise. * regcache.h (reg_buffer::invalidate): Move from detached_regcache. (reg_buffer::raw_supply): Likewise. (reg_buffer::raw_supply_integer): Likewise. (reg_buffer::raw_supply_zeroed): Likewise. (reg_buffer::raw_collect): Likewise. (reg_buffer::raw_collect_integer): Likewise. gdbserver/ * regcache.c (new_register_cache): Use new. (free_register_cache): Use delete. (register_data): Use const. (supply_register): Move body inside regcache. (regcache::raw_supply): New override function. (collect_register): Move body inside regcache. (regcache::raw_collect): New override function. (regcache::get_register_status): New override function. * regcache.h (struct regcache): Inherit from reg_buffer_common.
Diffstat (limited to 'gdb/regcache.h')
-rw-r--r--gdb/regcache.h62
1 files changed, 37 insertions, 25 deletions
diff --git a/gdb/regcache.h b/gdb/regcache.h
index 2f460a0..3b72986 100644
--- a/gdb/regcache.h
+++ b/gdb/regcache.h
@@ -139,7 +139,7 @@ typedef struct cached_reg
/* Buffer of registers. */
-class reg_buffer
+class reg_buffer : public reg_buffer_common
{
public:
reg_buffer (gdbarch *gdbarch, bool has_pseudo);
@@ -149,9 +149,42 @@ public:
/* Return regcache's architecture. */
gdbarch *arch () const;
- /* Get the availability status of the value of register REGNUM in this
- buffer. */
- enum register_status get_register_status (int regnum) const;
+ /* See common/common-regcache.h. */
+ enum register_status get_register_status (int regnum) const override;
+
+ /* See common/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;
+
+ /* See common/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);
+
+ void invalidate (int regnum);
virtual ~reg_buffer () = default;
@@ -231,24 +264,9 @@ public:
: readable_regcache (gdbarch, has_pseudo)
{}
- /* Supply register REGNUM, whose contents are stored in BUF, to REGCACHE. */
- void raw_supply (int regnum, const void *buf);
-
- void raw_supply (int regnum, const reg_buffer &src)
- {
- raw_supply (regnum, src.register_buffer (regnum));
- }
-
void raw_update (int regnum) override
{}
- void raw_supply_integer (int regnum, const gdb_byte *addr, int addr_len,
- bool is_signed);
-
- void raw_supply_zeroed (int regnum);
-
- void invalidate (int regnum);
-
DISABLE_COPY_AND_ASSIGN (detached_regcache);
};
@@ -289,12 +307,6 @@ public:
void raw_update (int regnum) override;
- /* Collect register REGNUM from REGCACHE and store its contents in BUF. */
- void raw_collect (int regnum, void *buf) const;
-
- void raw_collect_integer (int regnum, gdb_byte *addr, int addr_len,
- bool is_signed) const;
-
/* Partial transfer of raw registers. Perform read, modify, write style
operations. */
void raw_write_part (int regnum, int offset, int len, const gdb_byte *buf);