From 74b773fcd658c52554a6af07c657f677c52f8102 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Fri, 11 Dec 2020 13:48:11 -0500 Subject: 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 --- gdb/dwarf2/read.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) (limited to 'gdb/dwarf2') diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 2bf1453..91f669b 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -96,22 +96,14 @@ static unsigned int dwarf_read_debug = 0; /* Print a "dwarf-read" debug statement if dwarf_read_debug is >= 1. */ #define dwarf_read_debug_printf(fmt, ...) \ - do \ - { \ - if (dwarf_read_debug >= 1) \ - debug_prefixed_printf ("dwarf-read", __func__, fmt, ##__VA_ARGS__); \ - } \ - while (0) + debug_prefixed_printf_cond (dwarf_read_debug >= 1, "dwarf-read", fmt, \ + ##__VA_ARGS__) /* Print a "dwarf-read" debug statement if dwarf_read_debug is >= 2. */ #define dwarf_read_debug_printf_v(fmt, ...) \ - do \ - { \ - if (dwarf_read_debug >= 2) \ - debug_prefixed_printf ("dwarf-read", __func__, fmt, ##__VA_ARGS__); \ - } \ - while (0) + debug_prefixed_printf_cond (dwarf_read_debug >= 2, "dwarf-read", fmt, \ + ##__VA_ARGS__) /* When non-zero, dump DIEs after they are read in. */ static unsigned int dwarf_die_debug = 0; -- cgit v1.1