[Dwarf-Discuss] decoding of form entries

Todd Allen todd.allen at ccur.com
Mon Aug 2 14:11:49 PDT 2010

On Mon, Aug 02, 2010 at 04:50:45PM -0400, Michael Eager wrote:
> David Gross wrote:
> > Michael wrote:
> >> David Gross wrote:
> >>> Michael wrote:
> >>>
> >>>> Mathieu Lacage wrote:
> >>>>> On Mon, Aug 2, 2010 at 18:07, Michael Eager <eager at eagercon.com> wrote:
> >>>>>
> >>>>>>> So, I have a very practical question: if I want to get the value of
> >>>>>>> this form, I read the reference, that gives me a new location to parse
> >>>>>>> in the dwarf sections. What is the content of that new location ? Does
> >>>>>>> it point to an entry (meaning, I am going to find there an abbrev
> >>>>>>> code) ? If so, how do I know which attribute in this entry is going to
> >>>>>>> contain the value of my original attribute ? Would it be expected to
> >>>>>>> be the same attribute with a different non-reference form ?
> >>>>>> In the most common cases, the "entity" will be another DIE in the
> >>>>>> same compilation unit, which you will need to parse to find the
> >>>>>> value of attribute you are looking for.
> >>>>> That is what I suspected but, I am not sure I really understand your
> >>>>> answer so, let me restate my question again.
> >>>>>
> >>>>> How do I know which attribute to look for in the new DIE ? Is it
> >>>>> expected that the new DIE will contain the same attribute I looked at
> >>>>> originally but with a non-reference form ? For the sake of discussion,
> >>>>> what about DW_AT_byte_size ?
> >>>> Yes, generally you would search the referenced DIE to find the same
> >>>> attribute.
> >>> I see a different pattern in D.2.2 (Ada Example): 13$ contains a
> >>> DW_AT_upper_bound whose value is a reference to a variable.  The
> >>> variable does not contain a DW_AT_upper_bound; the value of the
> >>> variable itself is the value of the DW_AT_upper_bound.  That's the
> >>> pattern that I expected to see; I wasn't aware that the standard
> >>> intends to support the delegation pattern you describe above.
> >> For DW_AT_upper_bound and DW_AT_lower_bound, the intent of a reference
> >> is to point to the DIE for a variable which contains the value.  But
> >> this does not appear to be stated explicitly in the description of
> >> 5.11 Subrange Type Entries.
> >>
> >> Can you add an issue so that we fix this in the next version?
> > 
> > Do you mean that these two attributes are different from the rest of
> > the "applicable attributes" listed under Static and Dynamic
> > Properties?
> Maybe.  My interpretation of a reference for DW_AT_upper_bound
> was that it pointed to a variable with the dynamic value of
> the bound.  For DW_AT_byte_size, a reference points to a DIE
> which has an attribute with that value.
> Perhaps this was an incorrect impression.  The DWARF spec does say
> that the reference is to "another entity which specifies the value
> of the attribute" which I took to mean that the reference contained
> an attribute with the value, not that the variable contained that
> value.
> Are there compilers which generate a reference to a variable containing
> the value of DW_AT_byte_size?
> I think that our wording allows both interpretations, unfortunately.

Our Ada compiler uses references for several attributes where the referenced DIE
looks like an anonymous variable (or constant) with a DW_AT_location.  In
addition to DW_AT_lower_bound and DW_AT_lower_bound, we use this approach for
DW_AT_stride_size and DW_AT_bit_offset.  There may be other spec-defined
attributes, too.  And there definitely are a bunch more implementation-defined
attributes where we use this.

Anyway, attribute references to DW_TAG_variable / DW_TAG_constant DIE's which
represent the values of the attributes is our view of the norm.

I would go so far as to say that it ought to be legitimate for an attribute to
reference a DW_TAG_constant DIE which has a DW_AT_const_value attribute with the

Todd Allen
Concurrent Computer Corporation

More information about the Dwarf-Discuss mailing list