Re: [RFC PATCH] gdb: add linux_nat_debug_printf macro

Simon Marchi
2020-08-19T02:56:18Z

On 2020-07-12 1:11 p.m., Tom Tromey wrote:
>>>>>> "Simon" == Simon Marchi via Gdb-patches <gdb-patches@sourceware.org> writes:
>
> Simon> To address both of these issues, I suggest adding this macro for
> Simon> printing debug statements, which automatically includes the function
> Simon> name. It also includes the `[linux-nat]` prefix to clarify which part
> Simon> of GDB printed this (I think that ideally, all debug prints would
> Simon> include such a tag).
>
> Yeah. After seeing your patch I think all the debug prints should be
> done this way.
>
> Simon> The `__func__` magic symbol is used to get the function name.
> Simon> Unfortunately, in the case of methods, it only contains the method name,
>
> We could check for GCC and use __PRETTY_FUNCTION__, though that is the
> full signature, so it might be pretty long.

I remember I tried it and didn't like it much. Printing longer identifiers didn't
help readability. And usually we have enough context to know what the debug
statement is about, especially with the [linux-nat] prefix.

I pushed the patch, since the feedback was positive.

Simon