This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: [RFC] fixing extract_struct_value_address
- From: Michael Snyder <msnyder at redhat dot com>
- To: Daniel Jacobowitz <drow at mvista dot com>
- Cc: gdb-patches at sources dot redhat dot com, kevinb at redhat dot com, cagney at redhat dot com
- Date: Wed, 21 Aug 2002 18:48:15 -0700
- Subject: Re: [RFC] fixing extract_struct_value_address
- Organization: Red Hat, Inc.
- References: <3D6418C5.FBF117D@redhat.com> <20020822013255.GA18169@nevyn.them.org>
Daniel Jacobowitz wrote:
>
> On Wed, Aug 21, 2002 at 03:48:37PM -0700, Michael Snyder wrote:
> > Problem: Find a function's return value when it is a struct
> > returned by reference (thru a pointer).
> >
> > Solution level one: Take the value of the register that was
> > used by the caller to pass the struct return address.
> >
> > Shortcoming: that register isn't preserved, so may be clobbered.
> >
> > Solution level two: Save the struct_return address when it
> > is passed to store_struct_return (or push_arguments), and
> > recover it when it is needed by extract_struct_value_address.
> >
> > Shortcoming: Not reentrant. Nested function calls will clobber it.
> >
> > Proposed solution: create a stack structure, and "push" the
> > struct_return address in store_struct_return, popping it in
> > extract_return_address. If you can't find it on the stack,
> > then use the value of the appropriate arg0 register.
> >
> > I think this should work for most targets, so the code for
> > managing the stack can be shared.
> >
> > What do you think?
>
> Sharing the solution to this across targets would be a good step
> forward - I just had to use the same hack for another port. You want
> to be careful of functions which don't return (either GDB is activated
> inside the called function and the expression is never finished, or we
> longjmp out, or something...) but I believe there's somewhere that
> already tries to figure these things out...
I've a sample implementation which I've now tested on four targets.
I'll post it tomorrow, after a little more testing.