Re: [RFA] Locate sparc64 arguments correctly

Michael Snyder
2002-04-23T19:53:24Z

"David S. Miller" wrote:
>
> Two problems:
>
> 1) Debugging information encodes LOC_ARG/LOC_REF_ARG offsets
> with the Sparc64 stack bias included, we keep track of the
> frame pointer with the stack bias removed on sparc64.
>
> sparc64_frame_args_address takes care of that.

This is a good idea, but FRAME_ARGS_ADDRESS is multi-arched.
Can you use that implementation?

> 2) REG_STRUCT_HAS_ADDR was wrong, structs larger than 16 bytes
> are passed by reference.

Have you verified that this is the case on Solaris?

> No regression test changes, likely because these things aren't
> hit by the testsuite.

How about extending testsuite/gdb.base/structs.[c exp]
so that they cover this case?

> 2002-04-20 David S. Miller <davem@redhat.com>
>
> * config/sparc/tm-sp64.h (REG_STRUCT_HAS_ADDR): Structs are passed
> by reference when they are greater than 16 bytes in size, not 32.
> * sparc-tdep.c (sparc_reg_struct_has_addr): Likewise.
>
> * config/sparc/tm-sp64.h (FRAME_ARGS_ADDRESS): Define.
> * sparc-tdep.c (sparc64_frame_args_address): New function.
> (sparc_gdbarch_init): Use it for sparc64, else use
> default_frame_address.
>
> --- config/sparc/tm-sp64.h.~1~ Fri Apr 19 23:02:03 2002
> +++ config/sparc/tm-sp64.h Sat Apr 20 01:55:05 2002
> @@ -223,6 +223,9 @@ CORE_ADDR sparc64_push_arguments (int,
> #undef STACK_ALIGN
> #define STACK_ALIGN(ADDR) (((ADDR) + 15 ) & -16)
>
> +#undef FRAME_ARGS_ADDRESS
> +#define FRAME_ARGS_ADDRESS(FI) ((FI)->frame - 2047)
> +
> /* Initializer for an array of names of registers.
> There should be NUM_REGS strings in this initializer. */
> /* Some of these registers are only accessible from priviledged mode.
> @@ -263,7 +266,7 @@ CORE_ADDR sparc64_push_arguments (int,
> }
>
> #undef REG_STRUCT_HAS_ADDR
> -#define REG_STRUCT_HAS_ADDR(gcc_p,type) (TYPE_LENGTH (type) > 32)
> +#define REG_STRUCT_HAS_ADDR(gcc_p,type) (TYPE_LENGTH (type) > 16)
>
> extern CORE_ADDR sparc64_read_sp ();
> extern CORE_ADDR sparc64_read_fp ();
> --- sparc-tdep.c.~1~ Sat Apr 20 01:46:27 2002
> +++ sparc-tdep.c Sat Apr 20 01:52:38 2002
> @@ -2798,6 +2798,16 @@ sparc64_register_byte (int regno)
> return 64 * 8 + (regno - 80) * 8;
> }
>
> +/* Debugging information stores LOC_ARG/LOC_REF_ARG offsets with the
> + sparc64 stack bias present, this undoes that so that users of
> + FRAME_ARGS_ADDRESS use the right location. */
> +
> +static CORE_ADDR
> +sparc64_frame_args_address (struct frame_info *fi)
> +{
> + return fi->frame - 2047;
> +}
> +
> /* Advance PC across any function entry prologue instructions to reach
> some "real" code. SKIP_PROLOGUE_FRAMELESS_P advances the PC past
> some of the prologue, but stops as soon as it knows that the
> @@ -2886,7 +2896,7 @@ int
> sparc_reg_struct_has_addr (int gcc_p, struct type *type)
> {
> if (GDB_TARGET_IS_SPARC64)
> - return (TYPE_LENGTH (type) > 32);
> + return (TYPE_LENGTH (type) > 16);
> else
> return (gcc_p != 1);
> }
> @@ -3128,6 +3139,7 @@ sparc_gdbarch_init (struct gdbarch_info
> set_gdbarch_use_struct_convention (gdbarch,
> sparc64_use_struct_convention);
> set_gdbarch_write_sp (gdbarch, sparc64_write_sp);
> + set_gdbarch_frame_args_address (gdbarch, sparc64_frame_args_address);
> tdep->y_regnum = SPARC64_Y_REGNUM;
> tdep->fp_max_regnum = SPARC_FP0_REGNUM + 48;
> tdep->intreg_size = 8;