[Dwarf-Discuss] DW_AT_default_value reference to "subroutine"

Robinson, Paul Paul_Robinson at playstation.sony.com
Tue Sep 16 12:32:52 PDT 2014

The DW_AT_default_value attribute on a formal_parameter DIE can be used to
express a default argument for the parameter; C++ allows this, for example.
    int foo(int a, int b = 2);
    int bar(int x = foo(3)); // default for x is foo(3,2)
The description of the attribute in DWARF 4 (section 4.1 item 9, p.70)
says it can be a reference to "a variable or subroutine" as well as a
constant. What it means for a variable or constant is pretty obvious; but
it's not really clear about subroutines.  DWARF 4 says it's "the value
returned by the referenced subroutine."

Is this "subroutine" actually a DW_TAG_subprogram DIE?  That's not
expressive enough for the full glory of C++ default arguments.  It's
not even expressive enough to allow the debugger to call a single
arbitrary compiled function, as there's no way to express what
parameters to pass to the compiled function.

Is this "subroutine" actually a DWARF procedure?  That suggests it
should be evaluated like DW_OP_call_ref, which allows executing an
arbitrary DWARF expression, but a DWARF expression can't actually
describe calling a compiled function.

Any old-timers out there who can shed light on the intent of this
terminology?  I see similar verbiage all the way back to DWARF 2.

More information about the Dwarf-Discuss mailing list