public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: John Baldwin <jhb@FreeBSD.org>
To: Tom Tromey <tom@tromey.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH 3/6] Use std::vector<bool> for agent_expr::reg_mask
Date: Tue, 20 Jun 2023 08:30:45 -0700	[thread overview]
Message-ID: <f7577dc7-4c26-0b1d-b2d0-179f9c97d2b4@FreeBSD.org> (raw)
In-Reply-To: <20230619-ax-new-v1-3-b26175d997a9@tromey.com>

On 6/19/23 2:06 PM, Tom Tromey wrote:
> agent_expr::reg_mask implements its own packed boolean vector.  This
> patch replaces it with a std::vector<bool>, simplifying the code.
> ---
>   gdb/ax-general.c | 30 ++++++------------------------
>   gdb/ax.h         | 15 +++++----------
>   gdb/tracepoint.c | 16 +++++-----------
>   3 files changed, 16 insertions(+), 45 deletions(-)
> 
> diff --git a/gdb/ax-general.c b/gdb/ax-general.c
> index d5f4c51e65d..89e297eddc6 100644
> --- a/gdb/ax-general.c
> +++ b/gdb/ax-general.c
> @@ -330,8 +325,9 @@ ax_print (struct ui_file *f, struct agent_expr *x)
>   
>     gdb_printf (f, _("Scope: %s\n"), paddress (x->gdbarch, x->scope));
>     gdb_printf (f, _("Reg mask:"));
> -  for (i = 0; i < x->reg_mask_len; ++i)
> -    gdb_printf (f, _(" %02x"), x->reg_mask[i]);
> +  for (i = 0; i < x->reg_mask.size (); ++i)
> +    if (x->reg_mask[i])
> +      gdb_printf (f, _(" %02x"), i);
>     gdb_printf (f, _("\n"));

This was previously printing the bytes of the raw bitmask so that the mask was
printed in packed hex.  Now it is printing each bit as a 2 character hex value
(so you now end up with 01 01 00 00 00 01 00 00 instead of c4 for example).
Re-synthesizing the packed hex output may not be useful, but perhaps you could
print it as binary instead by only printing 0 or 1 for each bit without spaces
(or maybe only spaces between each 8 bits?).  Something like:

    for (i = 0; i < x->reg_mask.size (); ++i)
      {
        if (i % 8 == 0)
          gdb_printf(f, _(" "));
        gdb_printf (f, _("%u"), x->reg_mask[i]);
      }

-- 
John Baldwin


  reply	other threads:[~2023-06-20 15:30 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-19 21:06 [PATCH 0/6] C++-ify and simplify agent expressions Tom Tromey
2023-06-19 21:06 ` [PATCH 1/6] Remove mem2hex Tom Tromey
2023-06-19 21:06 ` [PATCH 2/6] Use gdb::byte_vector in agent_expr Tom Tromey
2023-06-19 21:06 ` [PATCH 3/6] Use std::vector<bool> for agent_expr::reg_mask Tom Tromey
2023-06-20 15:30   ` John Baldwin [this message]
2023-06-20 17:04     ` Tom Tromey
2023-06-19 21:06 ` [PATCH 4/6] Simplify agent_expr constructor Tom Tromey
2023-06-19 21:06 ` [PATCH 5/6] Use bool for agent_expr::tracing Tom Tromey
2023-06-20 15:31   ` John Baldwin
2023-06-20 17:04     ` Tom Tromey
2023-06-19 21:06 ` [PATCH 6/6] Make aop_map 'static' Tom Tromey
2023-06-20 15:39   ` John Baldwin
2023-06-20 17:12     ` 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=f7577dc7-4c26-0b1d-b2d0-179f9c97d2b4@FreeBSD.org \
    --to=jhb@freebsd.org \
    --cc=gdb-patches@sourceware.org \
    --cc=tom@tromey.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).