[Dwarf-Discuss] Attribute DW_AT_location has form DW_FORM_sdata?

Ron Brender ron.brender at gmail.com
Tue Oct 4 11:56:16 PDT 2011


The option to use DW_FORM_sdata in the DW_AT_location attribute of a 
field is new in DWARF *V4*. It is a size optimization for the very 
common case where the field offset is a constant. (Otherwise, an address 
expression is required which is at least a couple bytes larger.) I would 
expect that dwarf_loclist() and dwarf_loclist_n() already must use the 
form in order to distinguish a simple expression versus a location 
list--handling the sdata case should be a minor extension.

Ron

----------------------------------------------------
On 10/4/2011 2:03 PM, Ron Louzon wrote:
> I am working with DWARF output from the GNU 4.4 C++ compiler and I 
> have a question about the output for structure member locations.  I am 
> looking at the following information for a class and its members
> <1><2819e>: Abbrev Number: 108 (DW_TAG_class_type)
> <2819f>   DW_AT_name        : (indirect string, offset: 0x26a2d): 
> CmpCommandListHandler
> <281a3>   DW_AT_byte_size   : 20560
> <281a5>   DW_AT_decl_file   : 55
> <281a6>   DW_AT_decl_line   : 31
> <281a7>   DW_AT_sibling     : <0x2834c>
> <2><281ab>: Abbrev Number: 98 (DW_TAG_member)
> <281ac>   DW_AT_name        : (indirect string, offset: 0xb70e): 
> activeWcl
> <281b0>   DW_AT_decl_file   : 55
> <281b1>   DW_AT_decl_line   : 75
> <281b2>   DW_AT_type        : <0x27bc2>
> <281b6>   DW_AT_data_member_location: 0
> <281b7>   DW_AT_accessibility: 3 (private)
> <2><281b8>: Abbrev Number: 98 (DW_TAG_member)
> <281b9>   DW_AT_name        : (indirect string, offset: 0x1ca9d): 
> activeMcl
> <281bd>   DW_AT_decl_file   : 55
> <281be>   DW_AT_decl_line   : 78
> <281bf>   DW_AT_type        : <0x277ee>
> <281c3>   DW_AT_data_member_location: 8216
> <281c6>   DW_AT_accessibility: 3 (private)
> In the past, when dealing with structure and class members, I have 
> always been able to use the dwarf_loclist() and dwarf_loclist_n() 
> functions to retrieve location information for the members.  These 
> functions would return the offset which was applicable for whatever 
> member was being examined.  With the GNU 4.4 compiler, these functions 
> are returning an error because the DW_AT_data_member_location 
> attribute is of the form DW_FORM_sdata and these functions do not 
> handle that attribute form.
> I have never encountered this before.  I can deal with this by reading 
> the data as a signed number but is this normal?  Do I always need to 
> examine the form type to determine how to deal with a 
> DW_AT_data_member_location attribute or is this a special case due to 
> abnormal output from the GNU 4.4 compiler?
> Thanks.
> Ron
>
>
> _______________________________________________
> Dwarf-Discuss mailing list
> Dwarf-Discuss at lists.dwarfstd.org
> http://lists.dwarfstd.org/listinfo.cgi/dwarf-discuss-dwarfstd.org

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.dwarfstd.org/private.cgi/dwarf-discuss-dwarfstd.org/attachments/20111004/b545867e/attachment-0002.htm>


More information about the Dwarf-Discuss mailing list