aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@polymtl.ca>2020-12-11 13:48:11 -0500
committerSimon Marchi <simon.marchi@polymtl.ca>2020-12-11 14:01:12 -0500
commit74b773fcd658c52554a6af07c657f677c52f8102 (patch)
treeb192e163ad6ce311802e338938c9fd7e8dfddb51 /gdb
parent346e7e192370a4d602e14466825c329ed5920c8f (diff)
downloadgdb-74b773fcd658c52554a6af07c657f677c52f8102.zip
gdb-74b773fcd658c52554a6af07c657f677c52f8102.tar.gz
gdb-74b773fcd658c52554a6af07c657f677c52f8102.tar.bz2
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
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog9
-rw-r--r--gdb/displaced-stepping.h7
-rw-r--r--gdb/dwarf2/read.c16
-rw-r--r--gdb/infrun.h7
-rw-r--r--gdb/linux-nat.c7
5 files changed, 16 insertions, 30 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 992da3d..787ee0d 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,12 @@
+2020-12-11 Simon Marchi <simon.marchi@polymtl.ca>
+
+ * 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.
+
2020-12-11 Tom Tromey <tom@tromey.com>
* p-exp.y (intvar): Remove global.
diff --git a/gdb/displaced-stepping.h b/gdb/displaced-stepping.h
index d1a1ceb..146c3d0 100644
--- a/gdb/displaced-stepping.h
+++ b/gdb/displaced-stepping.h
@@ -33,12 +33,7 @@ extern bool debug_displaced;
/* Print a "displaced" debug statement. */
#define displaced_debug_printf(fmt, ...) \
- do \
- { \
- if (debug_displaced) \
- debug_prefixed_printf ("displaced", __func__, fmt, ##__VA_ARGS__); \
- } \
- while (0)
+ debug_prefixed_printf_cond (debug_displaced, "displaced",fmt, ##__VA_ARGS__)
enum displaced_step_prepare_status
{
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;
diff --git a/gdb/infrun.h b/gdb/infrun.h
index d5e6d27..4a4db84 100644
--- a/gdb/infrun.h
+++ b/gdb/infrun.h
@@ -34,12 +34,7 @@ extern unsigned int debug_infrun;
/* Print an "infrun" debug statement. */
#define infrun_debug_printf(fmt, ...) \
- do \
- { \
- if (debug_infrun) \
- debug_prefixed_printf ("infrun", __func__, fmt, ##__VA_ARGS__); \
- } \
- while (0)
+ debug_prefixed_printf_cond (debug_infrun, "infrun",fmt, ##__VA_ARGS__)
/* Nonzero if we want to give control to the user when we're notified
of shared library events by the dynamic linker. */
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index f1b2c74..da5f277 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -202,12 +202,7 @@ show_debug_linux_nat (struct ui_file *file, int from_tty,
/* Print a linux-nat debug statement. */
#define linux_nat_debug_printf(fmt, ...) \
- do \
- { \
- if (debug_linux_nat) \
- debug_prefixed_printf ("linux-nat", __func__, fmt, ##__VA_ARGS__); \
- } \
- while (0)
+ debug_prefixed_printf_cond (debug_linux_nat, "linux-nat", fmt, ##__VA_ARGS__)
struct simple_pid_list
{