This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH 2/2] Change ptype/o to print bit offset
>>>>> "Eli" == Eli Zaretskii <eliz@gnu.org> writes:
>> /* 5: 0 | 4 */ unsigned int y : 3;
>> /* 5: 3 | 4 */ unsigned int z : 3;
>> /* XXX 2-bit padding */
>> /* XXX 3-byte padding */
Eli> This loses information, because now the bits part is just a trivial
Eli> conversion of the field size in the declaration. The current display
Eli> shows something that cannot be trivially gleaned by looking at the
Eli> bitfield sizes.
Eli> I'm not objecting to the change, I'm just saying we lose something
Eli> here.
We don't actually lose anything here, because the padding is spelled out
explicitly in the comments that are printed.
Also, consider an example like this, from an Ada test case:
/* offset | size */ type = struct aggregates__nested_packed {
/* 0: 5 | 1 */ <range type> q000 : 3;
/* 0:23 | 8 */ struct aggregates__packed_rec {
/* 0 | 4 */ integer packed_array_assign_w;
/* 4: 5 | 1 */ <range type> packed_array_assign_x : 3;
/* 4: 2 | 1 */ <range type> packed_array_assign_y : 3;
/* XXX 2-bit padding */
/* XXX 3-byte padding */
/* total size (bytes): 8 */
} r000 : 38;
The "0:23" here is, IMO, actively confusing.
Tom