aboutsummaryrefslogtreecommitdiff
path: root/gdb/cli/cli-style.c
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@efficios.com>2020-08-18 22:49:54 -0400
committerSimon Marchi <simon.marchi@polymtl.ca>2020-08-18 22:49:54 -0400
commit9327494e0eeb118727446412a7fce2c0616a6788 (patch)
tree6299733f5c59d9ff08ac75e3c01e20a1be2ad898 /gdb/cli/cli-style.c
parent6cdb985c455d12dccaf0ea9d37298865b9d47d4f (diff)
downloadgdb-9327494e0eeb118727446412a7fce2c0616a6788.zip
gdb-9327494e0eeb118727446412a7fce2c0616a6788.tar.gz
gdb-9327494e0eeb118727446412a7fce2c0616a6788.tar.bz2
gdb: add linux_nat_debug_printf macro
The debug prints inside linux-nat.c almost all have a prefix that indicate in which function they are located. This prefix is an abbreviation of the function name. For example, this print is in the `linux_nat_post_attach_wait` function: if (debug_linux_nat) fprintf_unfiltered (gdb_stdlog, "LNPAW: Attaching to a stopped process\n"); Over time, the code has changed, things were moved, and many of these prefixes are not accurate anymore. Also, unless you know the linux-nat.c file by heart, it's a bit cryptic what LLR, LNW, RSRL, etc, all mean. To address both of these issues, I suggest adding this macro for printing debug statements, which automatically includes the function name. It also includes the `[linux-nat]` prefix to clarify which part of GDB printed this (I think that, ideally, all debug prints would include such a tag). The `__func__` magic symbol is used to get the function name. Unfortunately, in the case of methods, it only contains the method name, not the class name. So we'll get "wait", where I would have liked to get "linux_nat_target::wait". But at least with the `[linux-nat]` tag in the front, it's not really ambiguous. I've made the macro automatically include the trailing newline, because it wouldn't make sense to call it twice to print two parts of one line, the `[linux-nat]` tag would be printed in the middle. An advantage of this (IMO) is that it's less verbose, we don't have to check for `if (debug_linux_nat)` everywhere. Another advantage is that it's easier to customize the output later, without having to touch all call sites. Here's an example of what it looks like in the end: [linux-nat] linux_nat_wait_1: enter [linux-nat] wait: [process -1], [TARGET_WNOHANG] gdb/ChangeLog: * linux-nat.c (linux_nat_debug_printf): New function. (linux_nat_debug_printf_1): New macro. Use throughout the file. Change-Id: Ifcea3255b91400d3ad093cd0b75d3fac241cb998
Diffstat (limited to 'gdb/cli/cli-style.c')
0 files changed, 0 insertions, 0 deletions