aboutsummaryrefslogtreecommitdiff
path: root/gdbsupport
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 /gdbsupport
parent346e7e192370a4d602e14466825c329ed5920c8f (diff)
downloadfsf-binutils-gdb-74b773fcd658c52554a6af07c657f677c52f8102.zip
fsf-binutils-gdb-74b773fcd658c52554a6af07c657f677c52f8102.tar.gz
fsf-binutils-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 'gdbsupport')
-rw-r--r--gdbsupport/ChangeLog6
-rw-r--r--gdbsupport/common-debug.h17
-rw-r--r--gdbsupport/event-loop.h8
3 files changed, 25 insertions, 6 deletions
diff --git a/gdbsupport/ChangeLog b/gdbsupport/ChangeLog
index 417e44a..6be1f24 100644
--- a/gdbsupport/ChangeLog
+++ b/gdbsupport/ChangeLog
@@ -1,3 +1,9 @@
+2020-12-11 Simon Marchi <simon.marchi@polymtl.ca>
+
+ * common-debug.h (debug_prefixed_printf_cond): New.
+ * event-loop.h (event_loop_debug_printf): Use
+ debug_prefixed_printf_cond.
+
2020-12-08 Alexander Fedotov <alfedotov@gmail.com>
* pathstuff.cc (get_standard_cache_dir): Use LOCALAPPDATA environment
diff --git a/gdbsupport/common-debug.h b/gdbsupport/common-debug.h
index f9ddcca..7bc6218 100644
--- a/gdbsupport/common-debug.h
+++ b/gdbsupport/common-debug.h
@@ -50,4 +50,21 @@ extern void ATTRIBUTE_PRINTF (3, 4) debug_prefixed_printf
extern void ATTRIBUTE_PRINTF (3, 0) debug_prefixed_vprintf
(const char *module, const char *func, const char *format, va_list args);
+
+/* Helper to define "_debug_print" macros.
+
+ DEBUG_ENABLED_COND is an expression that evaluates to true if the debugging
+ statement is enabled and should be printed.
+
+ The other arguments, as well as the name of the current function, are
+ forwarded to debug_prefixed_printf. */
+
+#define debug_prefixed_printf_cond(debug_enabled_cond, module, fmt, ...) \
+ do \
+ { \
+ if (debug_enabled_cond) \
+ debug_prefixed_printf (module, __func__, fmt, ##__VA_ARGS__); \
+ } \
+ while (0)
+
#endif /* COMMON_COMMON_DEBUG_H */
diff --git a/gdbsupport/event-loop.h b/gdbsupport/event-loop.h
index 6880899..09d665f 100644
--- a/gdbsupport/event-loop.h
+++ b/gdbsupport/event-loop.h
@@ -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). */