This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: RFA/types: Clean up use of field bitsize
- From: Daniel Jacobowitz <drow at mvista dot com>
- To: gdb-patches at sources dot redhat dot com
- Date: Sun, 10 Nov 2002 19:58:23 -0500
- Subject: Re: RFA/types: Clean up use of field bitsize
- References: <20020930010515.GA27762@nevyn.them.org>
On Sun, Sep 29, 2002 at 09:05:15PM -0400, Daniel Jacobowitz wrote:
> Right now, we have this really disturbing comment:
>
> /* Size of this field, in bits, or zero if not packed.
> For an unpacked field, the field's type's length
> says how many bytes the field occupies.
> A value of -1 or -2 indicates a static field; -1 means the location
> is specified by the label loc.physname; -2 means that loc.physaddr
> specifies the actual address. */
>
> Think about this for a moment. While in practice a static member is never
> going to be packed, and in at least C++ can not be a bit-field, that's not
> logically obvious for other languages. I don't know Ada but I wouldn't be
> surprised if there were some construct which violated this assumption.
>
> Worse, all sorts of places don't check for negative bitsize at all. It may
> be that they're all safe - I didn't spend a lot of time working out problem
> cases - but I have my doubts.
>
> So, since I needed to gain a new field here anyway, and since I have no
> compunctions about shrinking this field a little (packed bitfields of size
> greater than a couple of words are allowed in some languages IIRC (including
> GNU C maybe? Although they are not allowed in ISO C99), but they're
> definitely dodgy), and since signed bitfields are not portable, I cleaned up
> the construct. It turned out to be painless except for making sure symbol
> readers initialized it, which was a little tedious.
>
> This patch:
> Moves 'artificial' out from 'loc' and makes it a bitfield
> Creates a 'static_kind' bitfield
> Makes 'bitsize' into a bitfield
>
> The goal is to allow more kinds of fields to be marked artificial -
> particularly data members. After this patch I'll submit the followup to
> mark DW_AT_artificial members as artificial types.
>
> OK?
It's in. Now to do the followon for artificial members; this will let
us hide _vptr members in type output if requested. And probably a set
option to toggle the artificial behavior...
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer