gdb: factor out debug_prefixed_printf_cond

The same pattern happens often to define a "debug_printf" macro:

    #define displaced_debug_printf(fmt, ...) \
      do \
        { \
          if (debug_displaced) \
    	debug_prefixed_printf ("displaced", __func__, fmt, ##__VA_ARGS__); \
        } \
      while (0)

Move this pattern behind a helper macro, debug_prefixed_printf_cond and
update the existing macros to use it.

gdb/ChangeLog:

	* displaced-stepping.h (displaced_debug_printf): Use
	debug_prefixed_printf_cond.
	* dwarf2/read.c (dwarf_read_debug_printf): Likewise.
	(dwarf_read_debug_printf_v): Likewise.
	* infrun.h (infrun_debug_printf): Likewise.
	* linux-nat.c (linux_nat_debug_printf): Likewise.

gdbsupport/ChangeLog:

	* common-debug.h (debug_prefixed_printf_cond): New.
	* event-loop.h (event_loop_debug_printf): Use
	debug_prefixed_printf_cond.

Change-Id: I1ff48b98b8d1cc405d1c7e8da8ceadf4e3a17f99
This commit is contained in:
Simon Marchi
2020-12-11 13:48:11 -05:00
parent 346e7e1923
commit 74b773fcd6
8 changed files with 41 additions and 36 deletions

View File

@@ -129,12 +129,8 @@ extern debug_event_loop_kind debug_event_loop;
/* Print an "event loop" debug statement. */
#define event_loop_debug_printf(fmt, ...) \
do \
{ \
if (debug_event_loop != debug_event_loop_kind::OFF) \
debug_prefixed_printf ("event-loop", __func__, fmt, ##__VA_ARGS__); \
} \
while (0)
debug_prefixed_printf_cond (debug_event_loop != debug_event_loop_kind::OFF, \
"event-loop", fmt, ##__VA_ARGS__)
/* Print an "event loop" debug statement that is know to come from a UI-related
event (e.g. calling the event handler for the fd of the CLI). */