From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by sourceware.org (Postfix) with ESMTP id 56A463842400 for ; Fri, 10 Jul 2020 14:23:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 56A463842400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-113-YiWyal95MgqdquIOSDNdkw-1; Fri, 10 Jul 2020 10:23:47 -0400 X-MC-Unique: YiWyal95MgqdquIOSDNdkw-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id F37F9800C64; Fri, 10 Jul 2020 14:23:45 +0000 (UTC) Received: from blade.nx (ovpn-114-254.ams2.redhat.com [10.36.114.254]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4045F5C1D3; Fri, 10 Jul 2020 14:23:45 +0000 (UTC) Received: by blade.nx (Postfix, from userid 1000) id 5492D816CCA9; Fri, 10 Jul 2020 15:23:44 +0100 (BST) Date: Fri, 10 Jul 2020 15:23:44 +0100 From: Gary Benson To: Simon Marchi Cc: Simon Marchi via Gdb-patches , Joel Brobecker Subject: Re: [PATCH] gdb: add linux_nat_debug_printf macro Message-ID: <20200710142344.GA10668@blade.nx> References: <20200702193034.22279-1-simon.marchi@efficios.com> <20200703173306.GA901@adacore.com> <20200710114757.GA2535@blade.nx> <580a486e-1efc-e0c1-70b1-e33fe4f7acac@simark.ca> MIME-Version: 1.0 In-Reply-To: <580a486e-1efc-e0c1-70b1-e33fe4f7acac@simark.ca> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-13.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, 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 14:24:06 -0000 Simon Marchi wrote: > 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? > > 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"); > } Awesome, thanks Simon. Cheers, Gary -- Gary Benson - he / him / his Principal Software Engineer, Red Hat