[PATCH 3/6] Use std::vector<bool> for agent_expr::reg_mask
John Baldwin
jhb@FreeBSD.org
Tue Jun 20 15:30:45 GMT 2023
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
More information about the Gdb-patches
mailing list