[Dwarf-Discuss] Location of a returned value?

Todd Allen todd.allen@ccur.com
Tue Jan 6 18:08:11 GMT 2009


For our Ada compiler, we had issues with this.  We invented a vendor-specific
DW_AT_return_method attribute with several enumerators for various places where
the return value could be stored.  The basic one was DW_RMETH_value which was
just the normal location where scalars were returned (i.e. use the ABI).  The
others were for more exotic methods of returning objects that were specific to
our compiler.

But I know of nothing for this in the DWARF standard.

On Tue, Jan 06, 2009 at 10:41:42AM -0500, Andrew Cagney wrote:
> Is there an ABI independent way to describe the location of a value
> returned by a function?  For instance:
> 
> struct ret {
>   int i;
>   int j;
> }
> 
> struct ret callee() {
>   struct ret r = { 1, 2 };
>   return r;
> }
> 
> caller() {
>   struct ret r = callee(); // <- HERE
>   use(&r)
> }
> 
> When stepping, out of callee() debuggers like to display the returned
> value.  Traditionally, this as been implemented using ABI specific
> code which, due to the nature of some ABIs it may not be possible to
> determine the location of that return value even though the compiler
> is fully aware of its location.  For instance, an ABI that passes in
> the return value's destination as a hidden address parameter:
> 
>     ENTER
>     ALLOC "sizeof struct ret for r"
>     ALLOC "sizeof struct ret for return value"
>     PUSH "address of return value"
>     // user does a step -over this call leaving the debugger ...
>     CALLL caller
>     // <- ... here
>     MOVE "return value" to "r"
>     PUSH "address of r"
>     CALL use
>     EXIT
>     RETURN
> 
> After the return while the compiler knows where the result has been
> stored that information isn't always available to the debugger (other
> than using ABI heuristics such as trusting that the result's address
> is in a specific register).
> 
> Several thoughts:
> 
> - as part of the "step -over", the debugger could capture the return
> value's address using ABI knowledge; but this may not work when
> there's a "step -finish"
> - the callee function's debug info could describe the return value's
> address, if known
> - the caller could, at the return point ("... here", above) describe
> the returned value some how
> 
> others?
> 
> Andrew
> 
> 
> One
> _______________________________________________
> Dwarf-Discuss mailing list
> Dwarf-Discuss at lists.dwarfstd.org
> http://lists.dwarfstd.org/listinfo.cgi/dwarf-discuss-dwarfstd.org

-- 
Todd Allen
Concurrent Computer Corporation




More information about the Dwarf-discuss mailing list