[Dwarf-Discuss] Default values

Michael Eager eager@eagercon.com
Tue Jan 8 08:28:38 GMT 2008


Jim Blandy wrote:
> I have a question about a part of the spec that seems unclear to me.
> Section 4.1, numbered para 9 describes DW_AT_default_value, which can
> refer to a "subroutine" to compute the default value to pass.  In this
> case, does the term "subroutine" refer to a function in the user's
> program that the debugger can invoke?  What arguments should the
> debugger pass?  Is the subroutine required to accept no arguments?
> Does this mean that in order to describe the C++ declarations:
> 
>      extern float d;
>      extern float foo (float x = d * 2);
> 
> the producer would need to emit machine code into the user's program,
> generate a die describing that code, and have x's DW_AT_default_value
> attribute refer to that die?
> 
> Or, did this mean to say "DWARF procedure", as described in section
> 5.16, instead of "subroutine"?  If that's the case, then we have a
> situation in the existing spec where DWARF expressions compute values
> of potentially arbitrary type.

A DW_AT_default_value attribute points to a DIE which describes the
default value.  This is either a constant or a reference to a variable
or a subroutine.  DWARF cannot describe an expression as a default
value.  In this case, a compiler could emit a hidden subroutine which
computed the default value. The DW_AT_default_value attribute would
refer to the DIE for this hidden subroutine.

This is one of the areas where the specification allows much to the
readers imagination, without a lot of guidance.  I would imagine that
the subroutine is called using the same calling convention as a
normal function.  No arguments are passed to the subroutine and the
value, returned according to the ABI, would be of the appropriate type
for the formal parameter.  That's my understanding, but it certainly could
be made much clearer with some additional commentary.


-- 
Michael Eager	 eager at eagercon.com
1960 Park Blvd., Palo Alto, CA 94306  650-325-8077




More information about the Dwarf-discuss mailing list