From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 68BF33857013 for ; Fri, 10 Jul 2020 13:55:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 68BF33857013 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark@simark.ca Received: from [172.16.0.95] (192-222-181-218.qc.cable.ebox.net [192.222.181.218]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 620A41E792; Fri, 10 Jul 2020 09:55:41 -0400 (EDT) Subject: Re: [PATCH] gdb: add linux_nat_debug_printf macro To: Gary Benson Cc: Simon Marchi via Gdb-patches , Joel Brobecker References: <20200702193034.22279-1-simon.marchi@efficios.com> <20200703173306.GA901@adacore.com> <20200710114757.GA2535@blade.nx> From: Simon Marchi Message-ID: <580a486e-1efc-e0c1-70b1-e33fe4f7acac@simark.ca> Date: Fri, 10 Jul 2020 09:55:40 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 In-Reply-To: <20200710114757.GA2535@blade.nx> Content-Type: text/plain; charset=utf-8 Content-Language: tl Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org 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: , X-List-Received-Date: Fri, 10 Jul 2020 13:55:43 -0000 On 2020-07-10 7:47 a.m., Gary Benson via Gdb-patches wrote: > Simon Marchi wrote: >> diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c >> index fde360f5080a..3b5c803b83fd 100644 >> --- a/gdb/linux-nat.c >> +++ b/gdb/linux-nat.c >> @@ -198,6 +198,27 @@ show_debug_linux_nat (struct ui_file *file, int from_tty, >> value); >> } >> >> +/* Print a debug statement. Should be used through linux_nat_debug_printf. */ >> + >> +static void ATTRIBUTE_PRINTF (2, 3) >> +linux_nat_debug_printf_1 (const char *func_name, const char *fmt, ...) >> +{ >> + fprintf_unfiltered (gdb_stdlog, "[linux-nat] %s: ", func_name); >> + >> + va_list ap; >> + va_start (ap, fmt); >> + vfprintf_unfiltered (gdb_stdlog, fmt, ap); >> + va_end (ap); >> + >> + fprintf_unfiltered (gdb_stdlog, "\n"); >> +} > > Would it be useful to use debug_printf and debug_vprintf here? > > Thanks, > Gary Indeed, I think the result would be the same, and it seems to exist for this purpose. I've replaced locally the implementation of linux_nat_debug_printf_1 with: static void ATTRIBUTE_PRINTF (2, 3) linux_nat_debug_printf_1 (const char *func_name, const char *fmt, ...) { debug_printf ("[linux-nat] %s: ", func_name); va_list ap; va_start (ap, fmt); debug_vprintf (fmt, ap); va_end (ap); debug_printf ("\n"); } Simon