gdb, gdbsupport: add debug_prefixed_printf, remove boilerplate functions

The *_debug_print_1 functions are all very similar, the only difference
being the subsystem name.  Remove them all and make the logging macros
use a new debug_prefixed_printf function directly.

gdb/ChangeLog:

	* infrun.c (infrun_debug_printf_1): Remove.
	(displaced_debug_printf_1): Remove.
	(stop_all_threads): Use debug_prefixed_printf.
	* infrun.h (infrun_debug_printf_1): Remove.
	(infrun_debug_printf): Use debug_prefixed_printf.
	(displaced_debug_printf_1): Remove.
	(displaced_debug_printf): Use debug_prefixed_printf.
	* linux-nat.c (linux_nat_debug_printf_1): Remove.
	(linux_nat_debug_printf): Use debug_prefixed_printf.

gdbsupport/ChangeLog:

	* common-debug.cc (debug_prefixed_printf): New.
	* common-debug.h (debug_prefixed_printf): New declaration.
	* event-loop.cc (event_loop_debug_printf_1): Remove.
	* event-loop.h (event_loop_debug_printf_1): Remove.
	(event_loop_debug_printf): Use debug_prefixed_printf.
	(event_loop_ui_debug_printf): Use debug_prefixed_printf.

Change-Id: Ib323087c7257f0060121d302055c41eb64aa60c6
This commit is contained in:
Simon Marchi 2020-10-31 09:01:25 -04:00
parent 19dd0ae5e7
commit 17417fb0ec
9 changed files with 56 additions and 79 deletions

View file

@ -31,34 +31,18 @@ struct thread_info;
/* True if we are debugging run control. */
extern unsigned int debug_infrun;
/* Print an "infrun" debug statement. Should be used through
infrun_debug_printf. */
void ATTRIBUTE_PRINTF (2, 3) infrun_debug_printf_1
(const char *func_name, const char *fmt, ...);
/* Print an "infrun" debug statement. */
#define infrun_debug_printf(fmt, ...) \
do \
{ \
if (debug_infrun) \
infrun_debug_printf_1 (__func__, fmt, ##__VA_ARGS__); \
} \
while (0)
debug_prefixed_printf ("infrun", __func__, fmt, ##__VA_ARGS__)
/* True if we are debugging displaced stepping. */
extern bool debug_displaced;
/* Print a "displaced" debug statement. Should be used through
displaced_debug_printf. */
void ATTRIBUTE_PRINTF (2, 3) displaced_debug_printf_1
(const char *func_name, const char *fmt, ...);
/* Print a "displaced" debug statement. */
#define displaced_debug_printf(fmt, ...) \
do \
{ \
if (debug_displaced) \
displaced_debug_printf_1 (__func__, fmt, ##__VA_ARGS__); \
} \
while (0)
debug_prefixed_printf ("displaced", __func__, 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. */