This is the mail archive of the gdb-patches@sources.redhat.com 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: [RFA] mips_store_struct_return, mips_extract_struct_value_address


I'm going to withdraw this patch and do a simpler version
(bug-for-bug compatible with the current code).

Michael Snyder wrote:
> 
> These two new functions serve as the gdbarch-ification of the
> corresponding macros, but also add functionality.  The existing
> macros didn't work, because they depended on the value of the
> struct_return address being preserved in $v0 (which the compiler
> was not constrained to do).  Instead we borrow an implementation
> from numerous other targets, and save the value when gdb sets it
> (which ought to be in store_struct_return, but in our case is in
> push_arguments), and then return it later via
> extract_struct_value_address.
> 
> A future improvement would be to move the code that sets
> struct_return from push_arguments into store_struct_return.
> 
>   ------------------------------------------------------------------------
> 2002-08-19  Michael Snyder  <msnyder@redhat.com>
> 
>         * mips-tdep.c (struct_return_addr): New variable.  Address
>         of struct_return as recorded by push_arguments.
>         (mips_eabi_push_arguments, mips_o32_push_arguments,
>         mips_o64_push_arguments, mips_n32n64_push_arguments): Store
>         value of struct_return address.
>         (mips_extract_struct_value_address): New function.
>         Return struct_return_addr as saved by push_arguments.
>         (mips_store_struct_return): New function, empty stub.
>         (mips_gdbarch_init): Set store_struct_return and
>         extract_struct_value_address.
> 
> Index: mips-tdep.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/mips-tdep.c,v
> retrieving revision 1.108
> diff -p -r1.108 mips-tdep.c
> *** mips-tdep.c 19 Aug 2002 23:22:17 -0000      1.108
> --- mips-tdep.c 20 Aug 2002 01:50:53 -0000
> *************** mips_type_needs_double_align (struct typ
> *** 2536,2541 ****
> --- 2536,2543 ----
>   #define ROUND_DOWN(n,a) ((n) & ~((a)-1))
>   #define ROUND_UP(n,a) (((n)+(a)-1) & ~((a)-1))
> 
> + static CORE_ADDR struct_return_addr;
> +
>   CORE_ADDR
>   mips_eabi_push_arguments (int nargs,
>                           struct value **args,
> *************** mips_eabi_push_arguments (int nargs,
> *** 2557,2562 ****
> --- 2559,2566 ----
> 
>     sp = ROUND_DOWN (sp, 16);
>     struct_addr = ROUND_DOWN (struct_addr, 16);
> +   /* Save struct_addr for EXTRACT_STRUCT_VALUE_ADDRESS.  */
> +   struct_return_addr = struct_addr;
> 
>     /* Now make space on the stack for the args.  We allocate more
>        than necessary for EABI, because the first few arguments are
> *************** mips_n32n64_push_arguments (int nargs,
> *** 2810,2815 ****
> --- 2814,2821 ----
> 
>     sp = ROUND_DOWN (sp, 16);
>     struct_addr = ROUND_DOWN (struct_addr, 16);
> +   /* Save struct_addr for EXTRACT_STRUCT_VALUE_ADDRESS.  */
> +   struct_return_addr = struct_addr;
> 
>     /* Now make space on the stack for the args.  */
>     for (argnum = 0; argnum < nargs; argnum++)
> *************** mips_o32_push_arguments (int nargs,
> *** 3036,3041 ****
> --- 3042,3049 ----
> 
>     sp = ROUND_DOWN (sp, 16);
>     struct_addr = ROUND_DOWN (struct_addr, 16);
> +   /* Save struct_addr for EXTRACT_STRUCT_VALUE_ADDRESS.  */
> +   struct_return_addr = struct_addr;
> 
>     /* Now make space on the stack for the args.  */
>     for (argnum = 0; argnum < nargs; argnum++)
> *************** mips_o64_push_arguments (int nargs,
> *** 3335,3340 ****
> --- 3343,3350 ----
> 
>     sp = ROUND_DOWN (sp, 16);
>     struct_addr = ROUND_DOWN (struct_addr, 16);
> +   /* Save struct_addr for EXTRACT_STRUCT_VALUE_ADDRESS.  */
> +   struct_return_addr = struct_addr;
> 
>     /* Now make space on the stack for the args.  */
>     for (argnum = 0; argnum < nargs; argnum++)
> *************** mips_n32n64_store_return_value (struct t
> *** 4760,4765 ****
> --- 4770,4794 ----
>     mips_n32n64_xfer_return_value (type, current_regcache, NULL, valbuf);
>   }
> 
> + static CORE_ADDR
> + mips_extract_struct_value_address (struct regcache *ignore)
> + {
> +   CORE_ADDR ret = struct_return_addr;
> +   /* We can't count on the struct return value being returned
> +      in v0 -- which is why we use mips_store_struct_return
> +      to stash it in a private cache.  FIXME this really calls
> +      for a stack.  */
> +
> +   struct_return_addr = 0;
> +   return ret;
> + }
> +
> + static void
> + mips_store_struct_return (CORE_ADDR addr, CORE_ADDR sp)
> + {
> +   /* Nothing to do -- push_arguments does all the work.  */
> + }
> +
>   /* Exported procedure: Is PC in the signal trampoline code */
> 
>   static int
> *************** mips_gdbarch_init (struct gdbarch_info i
> *** 5832,5837 ****
> --- 5861,5871 ----
> 
>     set_gdbarch_do_registers_info (gdbarch, mips_do_registers_info);
>     set_gdbarch_pc_in_sigtramp (gdbarch, mips_pc_in_sigtramp);
> +
> +   set_gdbarch_store_struct_return (gdbarch, mips_store_struct_return);
> +   set_gdbarch_extract_struct_value_address (gdbarch,
> +                                           mips_extract_struct_value_address);
> +
> 
>     /* Hook in OS ABI-specific overrides, if they have been registered.  */
>     gdbarch_init_osabi (info, gdbarch, osabi);


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