From: Jan Beulich <jbeulich@suse.com>
To: Andrew Burgess <aburgess@redhat.com>
Cc: binutils@sourceware.org
Subject: Re: [PATCHv3] libopcodes: extend the styling within the i386 disassembler
Date: Mon, 30 May 2022 10:19:11 +0200 [thread overview]
Message-ID: <a39930b9-d42d-6165-fa2b-09460f854900@suse.com> (raw)
In-Reply-To: <20220527174443.223739-1-aburgess@redhat.com>
On 27.05.2022 19:44, Andrew Burgess via Binutils wrote:
> @@ -9299,11 +9304,117 @@ get_sib (instr_info *ins, int sizeflag)
> }
>
> /* Like oappend (below), but S is a string starting with '%'.
> - In Intel syntax, the '%' is elided. */
> + In Intel syntax, the '%' is elided. STYLE is used when displaying this
> + part of the output in the disassembler.
As you're touching this comment anyway, can you add reference to
'$'? Or alternatively (that's what I was envisioning with the
comment on v2) drop this function altogether, doing what it does
separately in oappend_register() and oappend_immediate()?
> + This function should not be used directly from the general disassembler
> + code, instead the helpers oappend_register and oappend_immediate should
> + be called as appropriate. */
> +
> +static void
> +oappend_maybe_intel_with_style (instr_info *ins, const char *s,
> + enum disassembler_style style)
> +{
> + oappend_with_style (ins, s + ins->intel_syntax, style);
> +}
> +
> +/* Like oappend_maybe_intel_with_style above, but called when S is the
> + name of a register. */
> +
> static void
> -oappend_maybe_intel (instr_info *ins, const char *s)
> +oappend_register (instr_info *ins, const char *s)
> +{
> + oappend_maybe_intel_with_style (ins, s, dis_style_register);
> +}
> +
> +/* Like oappend_maybe_intel_with_style above, but called when S represents
> + an immediate. */
> +
> +static void
> +oappend_immediate (instr_info *ins, const char *s)
> +{
> + oappend_maybe_intel_with_style (ins, s, dis_style_immediate);
> +}
> +
> +/* Wrap around a call to INS->info->fprintf_styled_func, printing FMT.
> + STYLE is the default style to use in the fprintf_styled_func calls,
> + however, FMT might include embedded style markers (see oappend_style),
> + these embedded markers are not printed, but instead change the style
> + used in the next fprintf_styled_func call.
> +
> + Return non-zero to indicate the print call was a success. */
> +
> +static int ATTRIBUTE_PRINTF_3
> +i386_dis_printf (instr_info *ins, enum disassembler_style style,
> + const char *fmt, ...)
> {
> - oappend (ins, s + ins->intel_syntax);
> + va_list ap;
> + enum disassembler_style curr_style = style;
> + char *start, *curr;
> + char staging_area[100];
> + int res;
> +
> + va_start (ap, fmt);
> + res = vsnprintf (staging_area, sizeof (staging_area), fmt, ap);
> + va_end (ap);
> +
> + if (res < 0)
> + return res;
Perhaps additionally assert no truncation?
Everything else looks good to me, thanks. One more question though
below.
> @@ -9404,8 +9515,7 @@ print_insn (bfd_vma pc, instr_info *ins)
>
> if (ins->address_mode == mode_64bit && sizeof (bfd_vma) < 8)
> {
> - (*ins->info->fprintf_styled_func) (ins->info->stream, dis_style_text,
> - _("64-bit address is disabled"));
> + i386_dis_printf (ins, dis_style_text, _("64-bit address is disabled"));
Just wondering: Couldn't there be an "error" style?
Jan
next prev parent reply other threads:[~2022-05-30 8:19 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-29 13:42 [PATCH 0/2] Disassembler styling for i386-dis.c Andrew Burgess
2022-04-29 13:42 ` [PATCH 1/2] objdump: fix styled printing of addresses Andrew Burgess
2022-05-02 7:14 ` Jan Beulich
2022-05-03 9:52 ` Andrew Burgess
2022-04-29 13:42 ` [PATCH 2/2] libopcodes: extend the styling within the i386 disassembler Andrew Burgess
2022-04-29 18:16 ` Vladimir Mezentsev
2022-05-03 13:15 ` Andrew Burgess
2022-04-29 18:57 ` H.J. Lu
2022-05-03 13:14 ` Andrew Burgess
2022-05-02 7:28 ` Jan Beulich
2022-05-03 13:12 ` Andrew Burgess
2022-05-03 15:47 ` H.J. Lu
2022-05-04 7:58 ` Jan Beulich
2022-05-09 9:48 ` Andrew Burgess
2022-05-09 12:54 ` [PATCHv2] " Andrew Burgess
2022-05-18 12:27 ` Jan Beulich
2022-05-26 12:48 ` Andrew Burgess
2022-05-18 21:23 ` H.J. Lu
2022-05-27 17:44 ` [PATCHv3] " Andrew Burgess
2022-05-30 8:19 ` Jan Beulich [this message]
2022-05-31 17:20 ` Andrew Burgess
2022-06-01 5:59 ` Jan Beulich
2022-06-01 15:56 ` H.J. Lu
2022-06-08 16:03 ` Andrew Burgess
2022-06-10 10:56 ` Jan Beulich
2022-06-10 13:01 ` Andrew Burgess
2022-05-18 7:06 ` [PATCH 2/2] " Jan Beulich
2022-05-18 10:41 ` Andrew Burgess
2022-05-18 10:46 ` Jan Beulich
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=a39930b9-d42d-6165-fa2b-09460f854900@suse.com \
--to=jbeulich@suse.com \
--cc=aburgess@redhat.com \
--cc=binutils@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).