This is the mail archive of the gdb@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] Struct return values


   Date: Thu, 22 Jan 2004 09:20:46 -0500
   From: Andrew Cagney <cagney@gnu.org>

   > Hmm, OK, but this means that there are really three classes of ABIs here:
   > 
   > a) The return value address is passed to the callee, and the callee
   >    may clobber the location where the address is stored (i.e. it's
   >    stored in the callee's stack frame, or in a scratch register).
   > 
   > b) The return value address is passed to the callee, and the callee
   >    may clobber the location where the address is stored (i.e. it's
   >    stored in the callee's stack frame, or in a scratch register).  We
   >    can't "return VALUE" or display the return value with "finish".

   (I suspect you ment something like: while the callee can clober the 
   location containing the original return value address it is required to 
   return that address in a known location when the function finishes)

Something like that, yes.  I must have inadvertedly replaced it with
the "can't return & finish" phrase :-(.  Sorry for the confusion.

   > c) The return value address is passed to the callee in a location that
   >    isn't clobbered by the callee (i.e. in the caller's stack frame, or
   >    in a preserved register).
   > 
   > This means that
   > 
   > a) We cannot "return VALUE" or display the return value with "finish".
   > 
   > b) We cannot "return VALUE" but we can display the return values with
   >    "finish".
   > 
   > c) We can both "return VALUE" and display the return value with
   >    "finish".
   > 
   > Examples are:
   > 
   > a) The PPC System V psABI: The return value address is passed in r3,
   >    which is "volatile".
   > 
   > b) The AMD64 System V psABI: The return values address is passed in
   >    %rdi.  On return %rax will contain the address that has been passed
   >    in by the caller in %rdi.
   > 
   > c) The (32-bit) SPARC System V psABI: The return address is stored in
   >    a reserved slot in the caller's frame.

   Can b) be made equivalent to c)?  Does the ABI require that the CFI 
   unwind the %rax register such that it contains the return value address? 
     If that or something similar is true then it is just c).

I'm afraid not.  Both %rdi and %rax aren't preserved across function
calls.  Therefore, I don't think it's reasonable to expect that the
CFI says something other than that its contents are undefined.

   > Personally I find it very usefull that GDB prints the return value
   > when I say "finish", so I'd like to make that work too.

   Yes, perhaps get SPARC working and then see what can be tinkered with 
   for AMD.  It will eventually mean two methods, or an extra param.

I'll do that.

Mark


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