On Thu, Mar 14, 2019 at 1:22 PM Mark Wielaard <mark@xxxxxxxxx> wrote: > > 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 Thanks, Mark! Newer standard is indeed a bit clearer: <quote> This Standard uses the following bit numbering and direction conventions in examples. These conventions are for illustrative purposes and other conventions may apply on particular architectures. - For big-endian architectures, bit offsets are counted from high-order to low-order bits within a byte (or larger storage unit); in this case, the bit offset identifies the high-order bit of the object. - For little-endian architectures, bit offsets are counted from low-order to high-order bits within a byte (or larger storage unit); in this case, the bit offset identifies the low-order bit of the object. In either case, the bit so identified is defined as the beginning of the object. </quote> Will go over all those calculations again today-tomorrow, while I have all the context from yesterday debugging session still fresh in my head.