public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Lancelot SIX <lsix@lancelotsix.com>
To: Tom Tromey <tromey@adacore.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH 3/7] Remove byte vectors from cplus_struct_type
Date: Mon, 25 Sep 2023 23:32:41 +0100	[thread overview]
Message-ID: <20230925223241.phor5lusw7jd4flf@octopus> (raw)
In-Reply-To: <20230921-field-bits-v1-3-201285360900@adacore.com>

Hi Tom

On Thu, Sep 21, 2023 at 12:01:30PM -0600, Tom Tromey via Gdb-patches wrote:
> This removes some byte vectors from cplus_struct_type, moving the
> information into bitfields in holes in struct field.
> ---
>  gdb/dwarf2/read.c |  86 +++++++-------------------------------
>  gdb/gdbtypes.c    |  53 -----------------------
>  gdb/gdbtypes.h    | 118 ++++++++++++++++++++++++---------------------------
>  gdb/stabsread.c   | 123 +++++++++++++++++++-----------------------------------
>  4 files changed, 113 insertions(+), 267 deletions(-)
> 
> diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
> index 505c8ba12b5..c72512b8204 100644
> --- a/gdb/gdbtypes.h
> +++ b/gdb/gdbtypes.h
> @@ -668,6 +668,46 @@ struct field
>      m_loc.dwarf_block = dwarf_block;
>    }
>  
> +  /* True if this field is 'private'.  */
> +  bool is_private () const
> +  { return m_private; }
> +
> +  /* Set the field's "private" flag.  */
> +  void set_private ()
> +  {
> +    /* Can't have both.  */
> +    gdb_assert (!m_protected);
> +    m_private = true;
> +  }
> +
> +  /* True if this field is 'protected'.  */
> +  bool is_protected () const
> +  { return m_protected; }
> +
> +  /* Set the field's "protected" flag.  */
> +  void set_protected ()
> +  {
> +    /* Can't have both.  */
> +    gdb_assert (!m_private);
> +    m_protected = true;
> +  }
> +
> +  /* True if this field is 'virtual'.  */
> +  bool is_virtual () const
> +  { return m_virtual; }
> +
> +  /* Set the field's "virtual" flag.  */
> +  void set_virtual ()
> +  { m_virtual = true; }
> +
> +  /* True if this field is 'ignored'.  */
> +  bool is_ignored () const
> +  { return m_ignored; }
> +
> +  /* Set the field's "ignored" flag.  */
> +  void set_ignored ()
> +  { m_ignored = true; }
> +
>    union field_location m_loc;
>  
>    /* * For a function or member type, this is 1 if the argument is
> @@ -677,6 +717,15 @@ struct field
>  
>    unsigned int m_artificial : 1;
>  
> +  /* Whether the field is 'private'.  */
> +  bool m_private : 1;
> +  /* Whether the field is 'protected'.  */
> +  bool m_protected : 1;

Is there a reason I miss to not use an enum to describe the visibility?
This would avoid having to verify that m_private and m_protected are
mutually exclusive.

Is seems to me that something similar to

    debug_visibility m_visibility : 2;

(or a custom enum) should work.

> +  /* Whether the field is 'virtual'.  */
> +  bool m_virtual : 1;
> +  /* Whether the field is 'ignored'.  */
> +  bool m_ignored : 1;
> +
>    /* * Discriminant for union field_location.  */
>  
>    ENUM_BITFIELD(field_loc_kind) m_loc_kind : 3;
> diff --git a/gdb/stabsread.c b/gdb/stabsread.c
> index 7402a26a401..9a84e5f3f80 100644
> --- a/gdb/stabsread.c
> +++ b/gdb/stabsread.c
> @@ -3108,11 +3115,15 @@ read_baseclasses (struct stab_field_info *fip, const char **pp,
>  	}
>        ++(*pp);
>  
> -      newobj->visibility = *(*pp)++;
> -      switch (newobj->visibility)
> +      int visibility = *(*pp)++;
> +      switch (visibility)
>  	{
>  	case VISIBILITY_PRIVATE:
> +	  newobj->field.set_private ();
> +	  break;
>  	case VISIBILITY_PROTECTED:
> +	  newobj->field.set_private ();

I think this should be:

  newobj->field.set_protected ();

> +	  break;
>  	case VISIBILITY_PUBLIC:
>  	  break;
>  	default:

Best,
Lancelot.

  reply	other threads:[~2023-09-25 22:32 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-21 18:01 [PATCH 0/7] Remove char-based bitfield macros Tom Tromey
2023-09-21 18:01 ` [PATCH 1/7] Use .def file to stringify type codes Tom Tromey
2023-09-25 21:58   ` Lancelot SIX
2023-09-26 13:10     ` Tom Tromey
2023-09-21 18:01 ` [PATCH 2/7] Print field accessibility inline Tom Tromey
2023-09-21 18:01 ` [PATCH 3/7] Remove byte vectors from cplus_struct_type Tom Tromey
2023-09-25 22:32   ` Lancelot SIX [this message]
2023-10-27 14:20     ` Tom Tromey
2023-09-21 18:01 ` [PATCH 4/7] Add field::is_public Tom Tromey
2023-09-21 18:01 ` [PATCH 5/7] Remove some QUIT calls from need_access_label_p Tom Tromey
2023-09-21 18:01 ` [PATCH 6/7] Remove some type field accessor macros Tom Tromey
2023-09-21 18:01 ` [PATCH 7/7] Remove char-based bitfield macros Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230925223241.phor5lusw7jd4flf@octopus \
    --to=lsix@lancelotsix.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tromey@adacore.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).