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

Jan Kratochvil jan.kratochvil at redhat.com
Fri Apr 16 07:54:11 PDT 2010


Hi,

currently when GCC needs to use loclistptr DW_AT_lower_bound/DW_AT_upper_bound
(due to PC dependent location of dynamic values of these attributes) it uses
reference to an artificial variable DIE:

 <1><74>: Abbrev Number: 7 (DW_TAG_array_type)
 <2><7d>: Abbrev Number: 8 (DW_TAG_subrange_type)
    <82>   DW_AT_upper_bound : <0x59>
 <2><59>: Abbrev Number: 4 (DW_TAG_variable)
    <5a>   DW_AT_artificial  : 1
    <5b>   DW_AT_type        : <0x8a>
    <5f>   DW_AT_location    : 0x83     (location list)

Therefore emulating loclistptr <0x83> assignment to the subrange type <0x7d>.

There is open GCC debug/ PR:
	http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43762

as GCC now creates the artificial variable expecting attribute reference uses
its location (=address).  The other possibility is the variable should be read
out and its value should be used as the value of the attribute referencing it.

Jakub Jelinek wrote in PR debug/43762:
# I think 2.19 Static and Dynamic Values of Attributes is what matters here:
# 
# The value of these attributes is determined based on the class as follows:
# - For a constant, the value of the constant is the value of the attribute.
# - For a reference, the value is a reference to another entity which specifies
# the value of the attribute.
# - For an exprloc, the value is interpreted as a DWARF expression or location
# description; evaluation of the expression yields the value of the attribute.
# 
# The "or location description" confuses me, either it is a DWARF expression, or
# location description, but leaving in both options is ambiguous, given that a
# DWARF expression is also a memory location description and differ in a
# dereference.

Therefore "For a reference" could more clearly state if only DW_TAG_variable
(or also DW_TAG_constant and others?) could be referenced and if its read out
value (and not the location) gets used as the attribute value.

"For an exprloc" case clarification is described by Jakub above.

------------------------------------------------------------------------------

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?


Thanks,
Jan



More information about the Dwarf-Discuss mailing list