From: Simon Marchi <simark@simark.ca>
To: fam@euphon.net, gdb-patches@sourceware.org
Subject: Re: [PATCH v2] disass: Add /x modifier to print offsets in hex
Date: Wed, 23 Sep 2020 23:25:01 -0400 [thread overview]
Message-ID: <5127be3c-ca5a-1e0f-d19a-b83d4da0ec74@simark.ca> (raw)
In-Reply-To: <20200923101906.2897399-1-fam@euphon.net>
Hi,
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.
> @@ -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.
> @@ -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.
Simon
next prev parent reply other threads:[~2020-09-24 3:25 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 [this message]
2020-09-24 7:26 ` Fam Zheng
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=5127be3c-ca5a-1e0f-d19a-b83d4da0ec74@simark.ca \
--to=simark@simark.ca \
--cc=fam@euphon.net \
--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