Re: [PATCH] Removal of uses of MAX_REGISTER_SIZE

Pedro Alves
2017-01-27T12:11:20Z

On 01/24/2017 10:31 AM, Alan Hayward wrote:
> aarch64_pseudo_write (struct gdbarch *gdbarch, struct regcache *regcache,
> int regnum, const gdb_byte *buf)
> {
> - gdb_byte reg_buf[MAX_REGISTER_SIZE];
> + gdb_byte *reg_buf = (gdb_byte *) alloca (register_size (gdbarch, regnum));
>
> /* Ensure the register buffer is zero, we want gdb writes of the
> various 'scalar' pseudo registers to behavior like architectural
> writes, register width bytes are written the remainder are set to
> zero. */
> - memset (reg_buf, 0, sizeof (reg_buf));
> + memset (reg_buf, 0, sizeof (register_size (gdbarch, regnum)));

OK, I scrolled a bit further down to the third hunk. This sizeof is
clearly broken. There may be more instances of this.

Makes me wonder whether this is the right approach. :-/
(No, I don't have a formed opinion for what that would be.)

Thanks,
Pedro Alves