[PATCH 4/6] gdbserver: Delimit debugging output for readability

Joel Brobecker brobecker@adacore.com
Fri Jan 17 02:40:00 GMT 2014


> >>    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



More information about the Gdb-patches mailing list