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.
This commit is contained in:
Alan Hayward
2018-06-11 10:09:16 +01:00
parent 953edf2b6c
commit 9c86188316
7 changed files with 155 additions and 73 deletions

View File

@@ -62,4 +62,19 @@ extern enum register_status regcache_raw_read_unsigned
ULONGEST regcache_raw_get_unsigned (struct regcache *regcache, int regnum);
struct reg_buffer_common
{
virtual ~reg_buffer_common () = default;
/* Get the availability status of the value of register REGNUM in this
buffer. */
virtual register_status get_register_status (int regnum) const = 0;
/* Supply register REGNUM, whose contents are stored in BUF, to REGCACHE. */
virtual void raw_supply (int regnum, const void *buf) = 0;
/* Collect register REGNUM from REGCACHE and store its contents in BUF. */
virtual void raw_collect (int regnum, void *buf) const = 0;
};
#endif /* COMMON_REGCACHE_H */