[RFC] Debuginfo: Add default value support for subprogram arguments

David Blaikie dblaikie at gmail.com
Fri Aug 15 19:09:13 PDT 2014


On Fri, Aug 15, 2014 at 6:18 PM, Robinson, Paul
<Paul_Robinson at playstation.sony.com> wrote:
>> The Dwarf standard reads:
>>
>> A DW_AT_default_value attribute for a formal parameter entry. The value of
>> this attribute is a reference to the debugging information entry for a
>> variable or subroutine, or the value may be a constant. If the attribute
>> form is of class reference, the default value of the parameter is the value
>> of the referenced variable (which may be constant) or the value returned by
>> the referenced subroutine; a reference value of 0 means that no default
>> value has been specified. If the value is of class constant, that constant
>> is interpreted as a default value of the type of the formal parameter.
>>
>> For a constant form there is no way to express the absence of a default value.
>
> As a committee member I cringe at what the spec says here; you'd express the
> absence of a default value by omitting the attribute, duh.

I'm confused as to why this is cringeworthy - could you explain?

Is it that, by defining the absence of a default value by the absence
of the attribute, you can't express the case where you have a default
argument whose value can't be expressed in DWARF? I imagine we'd want
to do that by defining some attribute value to mean "no representable
value" and still use the absence of the attribute to represent the
absence of a default argument.

>> As you can see, this text limits us to emitting information about default
>> values being:
>> - simple constants (DW_FORM_data*)
>> - global variable (DW_FORM_ref*)
>> - calls to functions without arguments (DW_FORM_ref*)
>
> As written, yeah it does have that restriction.  Seems like more complicated
> default-value computations could be handled with a DWARF expression, but
> there's no provision in the spec for the attribute being an expression.
> (Which doesn't stop you from inventing one; go right ahead!)

Does the DWARF expression language provide the ability to express
arbitrary source language expressions? I suppose it has a function
call operation... addition, subtraction, etc... so not sure what we'd
be missing, so maybe it is right.

That would mean providing a totally general purpose source->DWARF
mapping in a compiler, which might be a bit much to ask.

>
>>
>> I tried to go a bit further and implement a more complete solution that adds:
>> - any link time constant (DW_FORM_block*): in this form, the block of data
>> represents the default value as it would be stored in the target memory
>> - arbitrary complex expressions (DW_FORM_str*): when no other of the above
>> forms fits, this dumps the default value expression as textual form. The
>> debugger can then evaluate this expression in the context of the declaration
>> if it has this capacity
>>
>> First of all, would these kind of extensions be welcome? If you agree that
>> they are worthwhile, I’ll submit a request to augment the standard wording.
>
> As I mentioned above, more complicated expressions should be expressed as
> DWARF expressions, you just need to invent a way for the attribute to
> reference the expression.  It's the end of a long week or I'd look up
> some ways to do that for you (sorry).
>
> You are more than welcome to propose enhancements like this on the
> DWARF website (dwarfstd.org).  The deadline for new features in DWARF 5
> has passed, so it would be a while before it actually made it into a
> published standard, but that gives you plenty of time for your
> practical experience with implementing it!
>
> --paulr
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits




More information about the llvm-commits mailing list