Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Joel Brobecker <brobecker@adacore.com>
To: Simon Marchi <simark@simark.ca>
Cc: Gary Benson <gbenson@redhat.com>,
	Simon Marchi via Gdb-patches <gdb-patches@sourceware.org>
Subject: Re: [PATCH] gdb: add linux_nat_debug_printf macro
Date: Mon, 13 Jul 2020 07:32:43 -0700	[thread overview]
Message-ID: <20200713143243.GK4914@adacore.com> (raw)
In-Reply-To: <580a486e-1efc-e0c1-70b1-e33fe4f7acac@simark.ca>

Hi Simon,

On Fri, Jul 10, 2020 at 09:55:40AM -0400, 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?
> > 
> > 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");
> }

I skimmed through the patch, and it looked good to me.

Thanks again for doing that. That's a nice improvement.

Thinking out loud (and certainly not a suggestion or request that
you take care of the implementation): I'm wondering if we should be
thinking about generalizing this approach, somehow. For instance,
if we a function that took not just a func name, but also the name
of the unit:

    unit_debug_vprintf (const char *module_name, const char *func_name,
                        const char *fmt, ...)

... or perhaps more generally:

    unit_debug_vprintf (const char *label, const char *func_name,
                        const char *fmt, ...)

... then all modules would have to do to have consistent logging
is to define one macro.

-- 
Joel


  parent reply	other threads:[~2020-07-13 14:32 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-02 19:30 [RFC PATCH] " Simon Marchi
2020-07-03 17:33 ` Joel Brobecker
2020-07-08 21:07   ` [PATCH] " Simon Marchi
2020-07-10 11:47     ` Gary Benson
2020-07-10 13:55       ` Simon Marchi
2020-07-10 14:23         ` Gary Benson
2020-07-13 14:32         ` Joel Brobecker [this message]
2020-07-13 14:38           ` Simon Marchi
2020-07-13 14:56             ` Gary Benson
2020-07-12 17:11 ` [RFC PATCH] " Tom Tromey
2020-08-19  2:56   ` Simon Marchi
2020-08-19  3:39     ` Simon Marchi
2020-08-19  3:44       ` Simon Marchi

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=20200713143243.GK4914@adacore.com \
    --to=brobecker@adacore.com \
    --cc=gbenson@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=simark@simark.ca \
    /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