This is the mail archive of the mailing list for the GDB project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Removal of uses of MAX_REGISTER_SIZE

On 01/24/2017 10:31 AM, Alan Hayward wrote:
> This patch replaces all current uses of MAX_REGISTER_SIZE with calls to
> either register_size() when the register number is known, and
> max_register_size() in all other cases.
> It assumes that the patch "[PATCH 3/3] Calculate max register size" will be
> approved, and follows the methods used in that series of 3 patches.
> In a couple of cases I've moved variables outside a loop to prevent multiple
> allocations.

The very first hunk calls alloca in a loop (I didn't look any
further).  This is unfortunately easy to get wrong with alloca.  (Not
just in this patch, but also future patches that might move things
around and add loops around allocas without noticing.)  Wish
the compiler warned about it and/or that C++ supported VLAs.  :-/

> index 801c03d5a0b5d205dc967cb0d53e299ea95eaa8f..a317c8f2bb192fc25689c84375b8c7bb327dd596 100644
> --- a/gdb/aarch64-tdep.c
> +++ b/gdb/aarch64-tdep.c
> @@ -1982,7 +1982,8 @@ aarch64_store_return_value (struct type *type, struct regcache *regs,
>        for (i = 0; i < elements; i++)
>  	{
>  	  int regno = AARCH64_V0_REGNUM + i;
> -	  bfd_byte tmpbuf[MAX_REGISTER_SIZE];
> +	  bfd_byte *tmpbuf = (bfd_byte *) alloca (register_size (gdbarch,
> +								 regno));
>  	  if (aarch64_debug)
>  	    {

Pedro Alves

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]