On Thu, 2019-03-14 at 12:56 -0700, Andrii Nakryiko wrote: > On Thu, Mar 14, 2019 at 12:44 PM Arnaldo Carvalho de Melo > <arnaldo.melo@xxxxxxxxx> wrote: > > > > But, in http://dwarfstd.org/doc/Dwarf3.pdf, page 75, we have: > > > > <quote> > > > > If the data member entry describes a bit field, then that entry has the > > following attributes: > > > > - A DW_AT_byte_size attribute whose value (see Section 2.19) is the > > number of bytes that contain an instance of the bit field and any > > padding bits. The byte size attribute may be omitted if the size of > > the object containing the bit field can be inferred from the type > > attribute of the data member containing the bit field. > > > > - A DW_AT_bit_offset attribute whose value (see Section 2.19) is the > > number of bits to the left of the leftmost (most significant) bit of > > the bit field value. > > > > - A DW_AT_bit_size attribute whose value (see Section 2.19) is the > > number of bits occupied by the bit field value. The location > > description for a bit field calculates the address of an anonym ous > > object containing the bit field. The address is relati ve to the > > structure, union, or cla ss that most closely encloses the bit field > > declaration. The number of bytes in this anonymous object is the value > > of the byte size attribute of the bit field. The offset (in bits) fr > > om the most significant bit of the anonymous object to the most > > significant bit of the bit field is the value of the bit offset > > attribute. > > > > And following it there is an example with some tables, I'll read this > > more thorougly later. > > > Thanks! I'll meditate on that as well later today :) I haven't meditated on it yet, but would warn about using the now ancient DWARF3 spec for this. See in particular the following DWARF issue "Packed unaligned bit fields" resolved for DWARF4: http://dwarfstd.org/ShowIssue.php?issue=081130.1 You might even just want to see what DWARF5 says about it: http://dwarfstd.org/doc/DWARF5.pdf