public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: Enze Li via Gdb-patches <gdb-patches@sourceware.org>
Subject: Re: [PATCH v7] gdb: Add new 'print nibbles' feature
Date: Fri, 14 Jan 2022 13:32:25 -0700	[thread overview]
Message-ID: <87y23idpnq.fsf@tromey.com> (raw)
In-Reply-To: <MEAP282MB02934AED0CD96F7109ACAFFBDD449@MEAP282MB0293.AUSP282.PROD.OUTLOOK.COM> (Enze Li via Gdb-patches's message of "Wed, 29 Dec 2021 21:45:37 +0800")

>>>>> ">" == Enze Li via Gdb-patches <gdb-patches@sourceware.org> writes:

>> This new feature displays binary values by group, with four
>> bits per group.

>> The motivation behind this work is to enhance the readability
>> of binary values.

Thank you for the patch.

>> +@item -nibbles [@code{on}|@code{off}]
>> +Set whether to print binary values in groups of four bits, known
>> +as ``nibbles''.  @xref{set print nibbles}.

I think if new print flags are added, we generally also add them to the
Python layer, see valpy_format_string.

>> +/* Return the digit separator for the current debugging language. */
>> +
>> +static char
>> +get_digit_separator ()
>> +{
>> +  if (current_language != nullptr)
>> +    {
>> +      switch (current_language->la_language)
>> +	{
>> +	case language_cplus:
>> +	  return '\'';
>> +	case language_rust:
>> +	  return '_';
>> +	default:
>> +	  return ' ';
>> +	}
>> +    }
>> +  else
>> +    return ' ';

It's better to add this kind of thing to the language object itself, or
to generic_val_print_decorations.  I'd say probably the latter,
depending on whether that's difficult.

>> +		  if ((0xf0 & (mask >> i) && (*p & 0xf0)) ||
>> +		      (0x0f & (mask >> i) && (*p & 0x0f)))

In gdb operators are put at the start of the continuing line.
Also this reads very weirdly to me.  It could probably benefit from some
explict "!= 0" somewhere.

thanks,
Tom

  parent reply	other threads:[~2022-01-14 20:32 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-29 13:45 Enze Li
2022-01-11 14:06 ` [PING][PATCH " Enze Li
2022-01-14 20:32 ` Tom Tromey [this message]
2022-03-31 13:41 ` [PATCH " Pedro Alves

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=87y23idpnq.fsf@tromey.com \
    --to=tom@tromey.com \
    --cc=gdb-patches@sourceware.org \
    /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).