Use partial register read/writes in transfer_regset

This avoids assert failures when the register is bigger than the
slot size. This happens on Aarch64 when truncating Z registers
into an fpsimd structure. This can be triggered by running
gdb command "generate-core-file".

Also, when the register is smaller then the slot size, then
zero pad when writing to the slot, and truncate when writing
to the regcache. This happens on Aarch64 with the CPSR register.

Continue to ensure registers are invalidated when both buffers
are null.

gdb/
	* regcache.c (readable_regcache::read_part): Fix asserts.
	(reg_buffer::raw_collect_part): New function.
	(regcache::write_part): Fix asserts.
	(reg_buffer::raw_supply_part): New function.
	(regcache::transfer_regset_register): New helper function.
	(regcache::transfer_regset): Call new functions.
	(regcache_supply_regset): Use gdb_byte*.
	(regcache::supply_regset): Likewise.
	(regcache_collect_regset): Likewise.
	(regcache::collect_regset): Likewise.
	* regcache.h (reg_buffer::raw_collect_part): New declaration.
	(reg_buffer::raw_supply_part): Likewise.
	(regcache::transfer_regset_register): Likewise.
	(regcache::transfer_regset): Use gdb_byte*.
This commit is contained in:
Alan Hayward
2018-06-20 18:19:05 +01:00
parent 514cd3a0f5
commit 8e7767e3f7
3 changed files with 142 additions and 25 deletions

View File

@@ -166,6 +166,10 @@ public:
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 common/common-regcache.h. */
void raw_supply (int regnum, const void *buf) override;
@@ -187,6 +191,10 @@ public:
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;
@@ -358,10 +366,18 @@ protected:
private:
/* Helper function for transfer_regset. Copies across a single register. */
void transfer_regset_register (struct regcache *out_regcache, int regnum,
const gdb_byte *in_buf, gdb_byte *out_buf,
int slot_size, int offs) const;
/* Transfer a single or all registers belonging to a certain register
set to or from a buffer. This is the main worker function for
regcache_supply_regset and regcache_collect_regset. */
void transfer_regset (const struct regset *regset,
struct regcache *out_regcache,
int regnum, const void *in_buf,
void *out_buf, size_t size) const;
int regnum, const gdb_byte *in_buf,
gdb_byte *out_buf, size_t size) const;
/* Perform a partial register transfer using a read, modify, write
operation. */