This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFA/doco] Fix gdb.Field attributes documentation for enum types.
- From: Joel Brobecker <brobecker at adacore dot com>
- To: Eli Zaretskii <eliz at gnu dot org>
- Cc: gdb-patches at sourceware dot org
- Date: Mon, 30 Dec 2013 06:57:15 +0400
- Subject: Re: [RFA/doco] Fix gdb.Field attributes documentation for enum types.
- Authentication-results: sourceware.org; auth=none
- References: <1387783386-6072-1-git-send-email-brobecker at adacore dot com> <834n5z8rxl dot fsf at gnu dot org> <20131228033003 dot GD4532 at adacore dot com> <83vby92vo5 dot fsf at gnu dot org>
> > @table @code
> > @item bitpos
> > This attribute is not available for @code{enum} or @code{static}
> > -(as in C@t{++} or Java) fields. The value is the bit position of
> > -the field.
> > +(as in C@t{++} or Java) fields. The value is the position, counting
> > +in bits, from the start of the containing type.
>
> Thanks, this is clear.
Thanks. I just pushed the commit.
> I'm curious: why are the bit units useful? Field offsets are
> generally counted in bytes, not bits.
It's normally true that fields are byte-aligned. But the containing
structures can also be packed, in which case the fields no longer
start at byte offsets. You need bit-precision to determine their
location. Some example in the GDB code bases are, I think, struct
symbol, where some of the fields are packed together to fit within
the same word, without regard to byte boundaries (avoiding unused
"holes").
--
Joel