This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH 4/6] gdbserver: Delimit debugging output for readability
- From: Joel Brobecker <brobecker at adacore dot com>
- To: Doug Evans <dje at google dot com>
- Cc: Yao Qi <yao at codesourcery dot com>, Pedro Alves <palves at redhat dot com>, gdb-patches <gdb-patches at sourceware dot org>
- Date: Fri, 17 Jan 2014 06:39:55 +0400
- Subject: Re: [PATCH 4/6] gdbserver: Delimit debugging output for readability
- Authentication-results: sourceware.org; auth=none
- References: <yjt2zjnztait dot fsf at ruffy dot mtv dot corp dot google dot com> <52B1842F dot 5020401 at redhat dot com> <21205 dot 55987 dot 69477 dot 892571 at ruffy dot mtv dot corp dot google dot com> <52D826DF dot 4000505 at codesourcery dot com> <CADPb22Ts6CMhb_cEBJRDvWPFqgO7YBZaJ1PGEqj0HDVS=tKzGA at mail dot gmail dot com>
> >> if (debug_threads)
> >> - fprintf (stderr, "stop pc is %08lx\n", pc);
> >> + debug_printf ("stop pc is %08lx\n", pc);
> >> return pc;
> >
> > IWBN to move "if (debug_threads)" into debug_printf too.
>
> I thought of that, but there are times when you want to check
> debug_threads before calling debug_printf.
I used to think the same way as Yao. But I think the pattern that
has been followed pretty consistently is the one above. I've seen
also emails or articles (I can't remember which), which justify
the use of the current pattern. From memory, you're saving a function
call, the string formatting, and also, if you need to call functions
with side-effects, you're saving that too. It doesn't sound like
it is all such a big problem, but I think it's significant enough
that we want to continue with our currently established pattern.
Some units have dealt with that issue by defining a macro expanding
to "if (debug_[...]) call_debug_trace_fun ([...]);".
As Doug suggested, maybe for a followup patch, for those interested.
--
Joel