[Dwarf-Discuss] Attribute as reference uses target DIE value or address?

Roland McGrath roland at redhat.com
Fri Apr 16 13:32:04 PDT 2010

I agree that the "reference" clause of 2.19 is unclear and should be
reworded.  From the uses of DW_AT_upper_bound in Appendix D, I think we
can see what it's intended to mean.  The phrase "another entity" refers
to a program entity like a variable, constant, or subprogram.  The
phrase "specifies the value of the attribute" means that the calculation
of the dynamic value of that entity yields the dynamic value of the
attribute (here, the upper bound).  The examples shown include a
DW_TAG_variable where the meaning is the value of that variable (via
DW_AT_location or DW_AT_const_value), a DW_TAG_member where the meaning
is the value of that member in the structure-typed object that also
contains the type whose DW_AT_upper_bound attribute we are looking at,
and a DW_TAG_inlined_subroutine whose DW_AT_const_value gives the value.
In all cases it's "the dynamic value", whether that is actually a
compile-time constant or is a location description from which to read
out a runtime value.

So I think the meaning of the reference case of 2.19 is fairly clear-cut
in fact.  But the wording is far from making it obvious what it means.

For the exprloc case, the examples suggest that it really is only a
DWARF expression and not a location description.  i.e., examples that
compute an address and use DW_OP_deref to fetch the value.

> Moreover I understand loclistptr was not applicable to DW_AT_*_bound in DWARF3
> as both constant and loclistptr shared there DW_FORM_data{4,8} before DWARF4
> introduced new DW_FORM_sec_offset.  But wouldn't it be better to avoid this
> artificial DW_TAG_variable by allowing DW_FORM_sec_offset for DW_AT_*_bound?

I agree.  In fact, I tend to think that all the specifications that say
exprloc is an expected class should instead use a class "location" that
can always be either exprloc or loclistptr.


More information about the Dwarf-Discuss mailing list