Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Fam Zheng <fam@euphon.net>
To: Simon Marchi <simark@simark.ca>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH v2] disass: Add /x modifier to print offsets in hex
Date: Thu, 24 Sep 2020 07:26:43 +0000	[thread overview]
Message-ID: <CABgc4wSRH5=FPnt7eRUyjXfY6TLqJX0ed7p3_Fug5DKnaBZo_A@mail.gmail.com> (raw)
In-Reply-To: <5127be3c-ca5a-1e0f-d19a-b83d4da0ec74@simark.ca>

On Thu, Sep 24, 2020 at 3:25 AM Simon Marchi <simark@simark.ca> wrote:
>
>
> Hi,

Hi Simon,

>
> That looks reasonable to me.
>
> - This probably deserves a NEWS entry.
> - There's probably some doc to update (doc/gdb.texinfo) for the affected
>   commands.
> - Could you add a test for this?  You probably don't need a new file,
>   just enhance some existing basic disasm test.

All make sense!

>
> > @@ -2535,7 +2540,7 @@ can be shown using \"show listsize\"."));
> >
> >    c = add_com ("disassemble", class_vars, disassemble_command, _("\
> >  Disassemble a specified section of memory.\n\
> > -Usage: disassemble[/m|/r|/s] START [, END]\n\
> > +Usage: disassemble[/m|/r|/s|/r] START [, END]\n\
> >  Default is the function surrounding the pc of the selected frame.\n\
> >  \n\
> >  With a /s modifier, source lines are included (if available).\n\
> > @@ -2551,6 +2556,8 @@ in favor of /s.\n\
> >  \n\
> >  With a /r modifier, raw instructions in hex are included.\n\
> >  \n\
> > +With a /x modifier, offsets are printed as hex.\n\
>
> Really a nit, but just above we say "in hex", so it would be nice to be
> consistent and say "in hex" here too.

Okay, will change.

>
> > @@ -250,7 +251,10 @@ gdb_pretty_print_disassembler::pretty_print_insn (const struct disasm_insn *insn
> >          the offset takes the place of the "+" here.  */
> >       if (offset >= 0)
> >         m_uiout->text ("+");
> > -     m_uiout->field_signed ("offset", offset);
> > +     snprintf(offset_buf, sizeof(offset_buf),
> > +                 flags & DISASSEMBLY_HEX_OFFSET ? "0x%x" : "%d",
> > +                 offset);
> > +     m_uiout->field_string("offset", offset_buf);
>
> You could skip the temporary buffer with:
>
>         m_uiout->field_fmt ("offset",
>                             ((flags & DISASSEMBLY_HEX_OFFSET) != 0
>                              ? "0x%x" : "%d"),
>                             offset);
>
> Note that the GNU coding style requires a space before parentheses in
> function (and function-like) calls.

Thanks, will send v3 later addressing above.

Fam

>
> Simon

  reply	other threads:[~2020-09-24  7:27 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-23 10:19 fam
2020-09-23 10:39 ` Andreas Schwab
2020-09-23 11:12   ` Fam Zheng
2020-09-24  3:25 ` Simon Marchi
2020-09-24  7:26   ` Fam Zheng [this message]
2020-09-24 11:05 ` Andrew Burgess
2020-09-24 12:20   ` Pedro Alves
2020-09-24 13:22     ` Andrew Burgess

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='CABgc4wSRH5=FPnt7eRUyjXfY6TLqJX0ed7p3_Fug5DKnaBZo_A@mail.gmail.com' \
    --to=fam@euphon.net \
    --cc=gdb-patches@sourceware.org \
    --cc=simark@simark.ca \
    /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