[Dwarf-Discuss] How to get union member offset?

Jun Koi junkoi2004 at gmail.com
Thu Apr 2 02:07:21 PDT 2009


On Fri, Mar 27, 2009 at 10:49 AM, Roland McGrath <roland at redhat.com> wrote:
>> I am trying to get the offset of a member in an union. However, there
>> is no attribute DW_AT_data_member_location attached to it!
>
> All members of a union start at offset 0.  I think the C standard may
> require that this is always true because of its pointer casting rules.
>
> But regardless DWARF 3 section 5.6.6 says: "The location description for
> a data member of a union may be omitted, since all data members of a
> union begin at the same address."
>
> What I'd consider wise consumer behavior is always to look for
> DW_AT_data_member_location as for struct, class, etc. as you already do.
> If it's not found and the containing type is a union, treat it as if
> you'd found the attribute with DW_FORM_udata and value 0.
>

Excellent, but still there is a question: given a Dwarf_Die, how can
we find its container? Is there any function for that?

Thanks,
J



More information about the Dwarf-Discuss mailing list