This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] Removal of uses of MAX_REGISTER_SIZE
- From: Pedro Alves <palves at redhat dot com>
- To: Alan Hayward <Alan dot Hayward at arm dot com>
- Cc: "gdb-patches at sourceware dot org" <gdb-patches at sourceware dot org>, nd <nd at arm dot com>
- Date: Wed, 1 Feb 2017 15:49:13 +0000
- Subject: Re: [PATCH] Removal of uses of MAX_REGISTER_SIZE
- Authentication-results: sourceware.org; auth=none
- References: <7CF07197-4FED-4970-BB4B-2FE828E29A63@arm.com> <45e3a5e1-a9aa-1bc0-5d08-526b89fc458e@redhat.com> <DF6DC192-18EE-4F7D-AB56-2521F4EA93F8@arm.com>
On 01/27/2017 04:46 PM, Alan Hayward wrote:
> --- a/gdb/xtensa-tdep.c
> +++ b/gdb/xtensa-tdep.c
> @@ -370,7 +370,10 @@ static void
> xtensa_register_write_masked (struct regcache *regcache,
> xtensa_register_t *reg, const gdb_byte *buffer)
> {
> - unsigned int value[(MAX_REGISTER_SIZE + 3) / 4];
> + struct gdbarch *gdbarch = get_regcache_arch (regcache);
> + unsigned int *value = (unsigned int *) alloca (max_register_size (gdbarch)
> + + 1);
I don't think I understand this +1.
AFAICS, the previous code was creating an array of ints
such that sizeof(value) is as big as MAX_REGISTER_SIZE, rounded up
to sizeof int. Seems like a replacement would be:
alloca (align_up (max_register_size (gdbarch), 4));
or better:
alloca (align_up (max_register_size (gdbarch), sizeof (int)));
?
> +
> const xtensa_mask_t *mask = reg->mask;
>
> int shift = 0; /* Shift for next mask (mod 32). */
> @@ -454,7 +457,9 @@ static enum register_status
> xtensa_register_read_masked (struct regcache *regcache,
> xtensa_register_t *reg, gdb_byte *buffer)
> {
> - unsigned int value[(MAX_REGISTER_SIZE + 3) / 4];
> + struct gdbarch *gdbarch = get_regcache_arch (regcache);
> + unsigned int *value = (unsigned int *) alloca (max_register_size (gdbarch)
> + + 1);
Ditto.
Thanks,
Pedro Alves