public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
From: Tom de Vries <vries@sourceware.org>
To: gdb-cvs@sourceware.org
Subject: [binutils-gdb] [gdb] Fix maint selftest -v print_one_insn
Date: Mon,  6 Jun 2022 17:27:52 +0000 (GMT)	[thread overview]
Message-ID: <20220606172752.29B8B3850860@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=faec7017f0302e33a3d2be107e83a3ef21a4813e

commit faec7017f0302e33a3d2be107e83a3ef21a4813e
Author: Tom de Vries <tdevries@suse.de>
Date:   Mon Jun 6 19:27:46 2022 +0200

    [gdb] Fix maint selftest -v print_one_insn
    
    When running the print_one_insn selftests with -v, I get:
    ...
    $ gdb -q -batch -ex "maint selftest -v print_one_insn"
    Running selftest print_one_insn::A6.
    .shor   0x783eRunning selftest print_one_insn::A7.
    trap_s  0x1Running selftest print_one_insn::ARC600.
    .shor   0x783eRunning selftest print_one_insn::ARC601.
    Running selftest print_one_insn::ARC700.
    trap_s  0x1Running selftest print_one_insn::ARCv2.
    trap_s  0x1Running selftest print_one_insn::EM.
    trap_s  0x1Running selftest print_one_insn::HS.
    trap_s  0x1Running selftest print_one_insn::Loongarch32.
    ...
    
    The insn is written to gdb_stdout, and there is code in the selftest to add a
    newline after the insn, which writes to stream().
    
    The stream() ui_file points into a string buffer, which the disassembler uses
    before writing to gdb_stdout, so writing into it after the disassembler has
    finished has no effect.
    
    Fix this by using gdb_stdlog and debug_printf (which is what the unit test
    infrastructure itself uses) instead, such that we have:
    ...
    Running selftest print_one_insn::A6.
    .shor   0x783e
    Running selftest print_one_insn::A7.
    trap_s  0x1
    Running selftest print_one_insn::ARC600.
    .shor   0x783e
    Running selftest print_one_insn::ARC601.
    Running selftest print_one_insn::ARC700.
    trap_s  0x1
    Running selftest print_one_insn::ARCv2.
    trap_s  0x1
    Running selftest print_one_insn::Loongarch32.
    ...
    
    Note: I've also removed the printing of arch_name, which would give
    us otherwise the redundant:
    ...
    Running selftest print_one_insn::A6.
    arc .shor       0x783e
    Running selftest print_one_insn::A7.
    arc trap_s      0x1
    ...
    
    Tested on x86_64-linux.

Diff:
---
 gdb/disasm-selftests.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/gdb/disasm-selftests.c b/gdb/disasm-selftests.c
index b3c5d997720..266745d01c7 100644
--- a/gdb/disasm-selftests.c
+++ b/gdb/disasm-selftests.c
@@ -171,7 +171,7 @@ print_one_insn_test (struct gdbarch *gdbarch)
 				    const gdb_byte *insn,
 				    size_t len)
       : gdb_disassembler (gdbarch,
-			  (run_verbose () ? gdb_stdout : &null_stream),
+			  (run_verbose () ? gdb_stdlog : &null_stream),
 			  gdb_disassembler_test::read_memory),
 	m_insn (insn), m_len (len)
     {
@@ -180,16 +180,10 @@ print_one_insn_test (struct gdbarch *gdbarch)
     int
     print_insn (CORE_ADDR memaddr)
     {
-      if (run_verbose ())
-	{
-	  gdb_printf (stream (), "%s ",
-		      gdbarch_bfd_arch_info (arch ())->arch_name);
-	}
-
       int len = gdb_disassembler::print_insn (memaddr);
 
       if (run_verbose ())
-	gdb_printf (stream (), "\n");
+	debug_printf ("\n");
 
       return len;
     }


                 reply	other threads:[~2022-06-06 17:27 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20220606172752.29B8B3850860@sourceware.org \
    --to=vries@sourceware.org \
    --cc=gdb-cvs@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).