[DWARVES]: Print the bit offset too
Helps understanding how bitfields really work, and after all it is just confusing, not wrong. See this one: struct usb_bus { struct device * controller; /* 0 8 */ int busnum; /* 8 4 */ /* XXX 4 bytes hole, try to pack */ char * bus_name; /* 16 8 */ u8 uses_dma; /* 24 1 */ u8 otg_port; /* 25 1 */ /* WARNING: DWARF offset=24, real offset=26 */ unsigned int is_b_host:1; /* 24:15 4 */ unsigned int b_hnp_enable:1; /* 24:14 4 */ /* XXX 30 bits hole, try to pack */ int devnum_next; /* 28 4 */ <SNIP> }; So the bitfield _really_ is at offset 24 and the "WARNING:" above is just pahole not understanding how it works, i.e. it starts at 24 and since the bitfield has a 'unsigned int' as its base type it goes from 24 to 27, the offsets start at the end, i.e. from byte 27 back to byte 27, but as only two bits are used, it puts bit padding at the end, at bit offset 0, that is the last bit in byte 27 and uses the first bits of byte 26 at bit offset 14 and 15. Now to make libdwarves finally understand this convention. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
6f40c17161
commit
31d20380cc
16
dwarves.c
16
dwarves.c
|
@ -1478,10 +1478,20 @@ static size_t struct_member__fprintf(struct class_member *self,
|
|||
printed += p;
|
||||
spacing -= p;
|
||||
}
|
||||
if (!sconf.suppress_offset_comment)
|
||||
printed += fprintf(fp, "%*s/* %5u %5u */",
|
||||
if (!sconf.suppress_offset_comment) {
|
||||
size_t size_spacing = 5;
|
||||
|
||||
printed += fprintf(fp, "%*s/* %5u",
|
||||
spacing > 0 ? spacing : 0, " ",
|
||||
offset, size);
|
||||
offset);
|
||||
|
||||
if (self->bit_size != 0) {
|
||||
printed += fprintf(fp, ":%2d", self->bit_offset);
|
||||
size_spacing -= 3;
|
||||
}
|
||||
|
||||
printed += fprintf(fp, " %*u */", size_spacing, size);
|
||||
}
|
||||
}
|
||||
return printed;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue