[Dwarf-Discuss] decoding of form entries

Mathieu Lacage mathieu.lacage at gmail.com
Mon Aug 2 10:25:44 PDT 2010

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 ?

This attribute is defined in p9 (dw4) with a link to p75 section 5.1
(btw, that link in the d4 pdf does not work while it works fine in the
dw3 pdf). That section says:
"A base type entry has either a DW_AT_byte_size attribute or a
DW_AT_bit_size attribute whose integer constant value (see Section
2.21) is the amount of storage needed to hold a value of the type."

Ok, so, section 2.21 explains how to read the value:

"Many debugging information entries allow either a DW_AT_byte_size
attribute or a DW_AT_bit_size attribute, whose integer constant value
(see Section 2.19) specifies an amount of storage. The value of the
DW_AT_byte_size attribute is interpreted in bytes and the value of the
DW_AT_bit_size attribute is interpreted in bits."

Which, really, does not tell me how to read the value. But, hey,
section 2.19 is supposed to tell me, hence, my original email.

In this case, my question is that I really don't see how I would have
to parse a DT_AT_byte_size attribute encoded with a form of type
"reference". To make my question crystal clear, if the value of the
attribute in the original DIE is encoded with a reference form, shall
I expect the new DIE referenced by this form to contain another
DW_AT_byte_size attribute that is encoded with a non-reference form ?
I guess that the new DIE might be allowed to contain a
reference-encoded DW_AT_byte_size but that the dw4 spec should ensure
that, at some point while parsing the chain of referenced DIEs, _one_
of them will contain a non-reference form version of that
DW_AT_byte_size attribute.

(note, that I picked this attribute arbitrarily: the same question
holds for every attribute mentioned in 2.19, that is: DW_AT_allocated,
DW_AT_associated, DW_AT_bit_offset, DW_AT_bit_size, DW_AT_byte_size,
DW_AT_count, DW_AT_lower_bound, DW_AT_byte_stride, DW_AT_bit_stride,

I am not trying to nitpick here: I am just reading the spec and trying
to figure how to implement a reader so, I would like to know what I
need to do to implement a robust reader that does not start to barf
when the compiler generates some weird un-expected but perfectly valid
data. They are out there trying to get me :)

thanks for your patience,
Mathieu Lacage <mathieu.lacage at gmail.com>

More information about the Dwarf-Discuss mailing list