From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id ME2rMXJy2l+KMwAAWB0awg (envelope-from ) for ; Wed, 16 Dec 2020 15:47:46 -0500 Received: by simark.ca (Postfix, from userid 112) id B2F141F0B8; Wed, 16 Dec 2020 15:47:46 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.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 4A63F1E552 for ; Wed, 16 Dec 2020 15:47:43 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9ABF6388CC1C; Wed, 16 Dec 2020 20:47:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9ABF6388CC1C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1608151662; bh=Quu/zXgWeOvUWYfPTiX7jP/KOurrDPAhrB+GJCQfVi0=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=oAgvy7G2NLFOUwiEMxGSvKGSR8PW2O2PWVeFKn03+6Xpph5wBgZP6/j8hCDOh2Kso nxM0FPFa/us9/lXkjV1YM8bdi5LdjVcopVwyb6JzDjlHYKj/4orkcfrEjACT9nnhpb QBGhoUzfzKCJUMPuYFjs/d6EixDh8QzVdGDjFu5o= Received: from barracuda.ebox.ca (barracuda.ebox.ca [96.127.255.19]) by sourceware.org (Postfix) with ESMTPS id 4887C388C003 for ; Wed, 16 Dec 2020 20:47:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 4887C388C003 X-ASG-Debug-ID: 1608151659-0c856e67e21fa3e0001-fS2M51 Received: from smtp.ebox.ca (smtp.ebox.ca [96.127.255.82]) by barracuda.ebox.ca with ESMTP id s13W98vgvIaA1Ac6 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 16 Dec 2020 15:47:39 -0500 (EST) X-Barracuda-Envelope-From: simon.marchi@efficios.com X-Barracuda-RBL-Trusted-Forwarder: 96.127.255.82 Received: from epycamd.internal.efficios.com (192-222-181-218.qc.cable.ebox.net [192.222.181.218]) by smtp.ebox.ca (Postfix) with ESMTP id 546F7441D65; Wed, 16 Dec 2020 15:47:39 -0500 (EST) X-Barracuda-RBL-IP: 192.222.181.218 X-Barracuda-Effective-Source-IP: 192-222-181-218.qc.cable.ebox.net[192.222.181.218] X-Barracuda-Apparent-Source-IP: 192.222.181.218 To: gdb-patches@sourceware.org Subject: [PATCH v2 2/3] gdb: use infrun_debug_printf in print_target_wait_results Date: Wed, 16 Dec 2020 15:47:36 -0500 X-ASG-Orig-Subj: [PATCH v2 2/3] gdb: use infrun_debug_printf in print_target_wait_results Message-Id: <20201216204737.900975-2-simon.marchi@efficios.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201216204737.900975-1-simon.marchi@efficios.com> References: <20201216204737.900975-1-simon.marchi@efficios.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Barracuda-Connect: smtp.ebox.ca[96.127.255.82] X-Barracuda-Start-Time: 1608151659 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://96.127.255.19:443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at ebox.ca X-Barracuda-Scan-Msg-Size: 3350 X-Barracuda-BRTS-Status: 1 X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=8.0 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.86572 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- 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: Simon Marchi via Gdb-patches Reply-To: Simon Marchi Cc: Simon Marchi Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" The code in print_target_wait_results uses a single call to debug_printf in order to make sure a single timestamp is emitted, despite printing multiple lines. The result is: 941502.043284 [infrun] target_wait (-1.0.0, status) = [infrun] 649832.649832.0 [process 649832], [infrun] status->kind = stopped, signal = GDB_SIGNAL_TRAP I find this decision a bit counter productive, because it messes up the alignment of the three lines. We don't care that three (slightly different) timestamps are printed. I suggest to change this function to use infrun_debug_printf, with this result: 941601.425771 [infrun] print_target_wait_results: target_wait (-1.0.0 [process -1], status) = 941601.425824 [infrun] print_target_wait_results: 651481.651481.0 [process 651481], 941601.425867 [infrun] print_target_wait_results: status->kind = stopped, signal = GDB_SIGNAL_TRAP Note that the current code only prints the waiton_ptid as a string between square brackets if pid != -1. I don't think this complexity is needed in a debug print. I made it so it's always printed, which I think results in a much simpler function. gdb/ChangeLog: * infrun.c (print_target_wait_results): Use infrun_debug_printf. Change-Id: I817bd10286b8e641a6c751ac3a1bd1ddf9b18ce0 --- gdb/infrun.c | 36 +++++++++++------------------------- 1 file changed, 11 insertions(+), 25 deletions(-) diff --git a/gdb/infrun.c b/gdb/infrun.c index f509481e3d3..fe07be5e381 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -3275,31 +3275,17 @@ void print_target_wait_results (ptid_t waiton_ptid, ptid_t result_ptid, const struct target_waitstatus *ws) { - std::string status_string = target_waitstatus_to_string (ws); - string_file stb; - - /* The text is split over several lines because it was getting too long. - Call fprintf_unfiltered (gdb_stdlog) once so that the text is still - output as a unit; we want only one timestamp printed if debug_timestamp - is set. */ - - stb.printf ("[infrun] target_wait (%d.%ld.%ld", - waiton_ptid.pid (), - waiton_ptid.lwp (), - waiton_ptid.tid ()); - if (waiton_ptid.pid () != -1) - stb.printf (" [%s]", target_pid_to_str (waiton_ptid).c_str ()); - stb.printf (", status) =\n"); - stb.printf ("[infrun] %d.%ld.%ld [%s],\n", - result_ptid.pid (), - result_ptid.lwp (), - result_ptid.tid (), - target_pid_to_str (result_ptid).c_str ()); - stb.printf ("[infrun] %s\n", status_string.c_str ()); - - /* This uses %s in part to handle %'s in the text, but also to avoid - a gcc error: the format attribute requires a string literal. */ - fprintf_unfiltered (gdb_stdlog, "%s", stb.c_str ()); + infrun_debug_printf ("target_wait (%d.%ld.%ld [%s], status) =", + waiton_ptid.pid (), + waiton_ptid.lwp (), + waiton_ptid.tid (), + target_pid_to_str (waiton_ptid).c_str ()); + infrun_debug_printf (" %d.%ld.%ld [%s],", + result_ptid.pid (), + result_ptid.lwp (), + result_ptid.tid (), + target_pid_to_str (result_ptid).c_str ()); + infrun_debug_printf (" %s", target_waitstatus_to_string (ws).c_str ()); } /* Select a thread at random, out of those which are resumed and have -- 2.29.2