From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id ZPWhLFgKm2IDOgoAWB0awg (envelope-from ) for ; Sat, 04 Jun 2022 03:31:36 -0400 Received: by simark.ca (Postfix, from userid 112) id A71191E221; Sat, 4 Jun 2022 03:31:36 -0400 (EDT) Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=T91L/Wwb; dkim-atps=neutral X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RDNS_DYNAMIC,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 3F2D11E143 for ; Sat, 4 Jun 2022 03:31:36 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BC9B13829BE0 for ; Sat, 4 Jun 2022 07:31:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BC9B13829BE0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1654327895; bh=vuAG+FJI2sjRvzR3853e+7BSPvqqOm/+5E3R1pg0EAU=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=T91L/WwbMhMeCXqc03Cn1tBSGoz3IJItPqaxmzqT392lGqtPUd7m97FpFS8+MtfEN 66iVUMiMb7jvLmoDLeOBbliy+t0+zhrP1prQ82k1GJDRSPJLjZklx4/MODgNky/hf1 mDdwtldItGmWC0s4nG/lSvJaplHUMRXCo3W5cRM0= Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id 850423856DD8 for ; Sat, 4 Jun 2022 07:31:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 850423856DD8 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id B5C2C21C37 for ; Sat, 4 Jun 2022 07:31:16 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id A3B2113A5F for ; Sat, 4 Jun 2022 07:31:16 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id qzzZJkQKm2LuSQAAMHmgww (envelope-from ) for ; Sat, 04 Jun 2022 07:31:16 +0000 Date: Sat, 4 Jun 2022 09:31:15 +0200 To: gdb-patches@sourceware.org Subject: [PATCH][gdb] Fix maint selftest -v print_one_insn Message-ID: <20220604073113.GA6823@delia.home> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Tom de Vries via Gdb-patches Reply-To: Tom de Vries Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" Hi, 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. Any comments? Thanks, - Tom [gdb] Fix maint selftest -v print_one_insn --- 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; }