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: [RFC] fixing extract_struct_value_address


Michael Snyder <msnyder@redhat.com> writes:
> 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.

Doesn't this stack push and pop exactly as the generic dummy frame
stack does?  Couldn't we just add a `struct_return_addr' field to
`struct dummy_frame'?


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