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:
parent
19dd0ae5e7
commit
17417fb0ec
9 changed files with 56 additions and 79 deletions
|
@ -1,3 +1,15 @@
|
|||
2020-10-31 Simon Marchi <simon.marchi@polymtl.ca>
|
||||
|
||||
* 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.
|
||||
|
||||
2020-10-31 Simon Marchi <simon.marchi@polymtl.ca>
|
||||
|
||||
* configure: Re-generate.
|
||||
|
|
26
gdb/infrun.c
26
gdb/infrun.c
|
@ -104,17 +104,6 @@ static int infrun_is_async = -1;
|
|||
|
||||
/* See infrun.h. */
|
||||
|
||||
void
|
||||
infrun_debug_printf_1 (const char *func_name, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start (ap, fmt);
|
||||
debug_prefixed_vprintf ("infrun", func_name, fmt, ap);
|
||||
va_end (ap);
|
||||
}
|
||||
|
||||
/* See infrun.h. */
|
||||
|
||||
void
|
||||
infrun_async (int enable)
|
||||
{
|
||||
|
@ -179,17 +168,6 @@ show_debug_infrun (struct ui_file *file, int from_tty,
|
|||
fprintf_filtered (file, _("Inferior debugging is %s.\n"), value);
|
||||
}
|
||||
|
||||
/* See infrun.h. */
|
||||
|
||||
void
|
||||
displaced_debug_printf_1 (const char *func_name, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start (ap, fmt);
|
||||
debug_prefixed_vprintf ("displaced", func_name, fmt, ap);
|
||||
va_end (ap);
|
||||
}
|
||||
|
||||
/* Support for disabling address space randomization. */
|
||||
|
||||
bool disable_randomization = true;
|
||||
|
@ -4667,10 +4645,10 @@ stop_all_threads (void)
|
|||
target_thread_events (false);
|
||||
}
|
||||
|
||||
/* Use infrun_debug_printf_1 directly to get a meaningful function
|
||||
/* Use debug_prefixed_printf directly to get a meaningful function
|
||||
name. */
|
||||
if (debug_infrun)
|
||||
infrun_debug_printf_1 ("stop_all_threads", "done");
|
||||
debug_prefixed_printf ("infrun", "stop_all_threads", "done");
|
||||
};
|
||||
|
||||
/* Request threads to stop, and then wait for the stops. Because
|
||||
|
|
24
gdb/infrun.h
24
gdb/infrun.h
|
@ -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. */
|
||||
|
|
|
@ -199,24 +199,10 @@ show_debug_linux_nat (struct ui_file *file, int from_tty,
|
|||
value);
|
||||
}
|
||||
|
||||
/* Print a debug statement. Should be used through linux_nat_debug_printf. */
|
||||
|
||||
static void ATTRIBUTE_PRINTF (2, 3)
|
||||
linux_nat_debug_printf_1 (const char *func_name, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start (ap, fmt);
|
||||
debug_prefixed_vprintf ("linux-nat", func_name, fmt, ap);
|
||||
va_end (ap);
|
||||
}
|
||||
/* Print a linux-nat debug statement. */
|
||||
|
||||
#define linux_nat_debug_printf(fmt, ...) \
|
||||
do \
|
||||
{ \
|
||||
if (debug_linux_nat) \
|
||||
linux_nat_debug_printf_1 (__func__, fmt, ##__VA_ARGS__); \
|
||||
} \
|
||||
while (0)
|
||||
debug_prefixed_printf ("linux-nat", __func__, fmt, ##__VA_ARGS__)
|
||||
|
||||
struct simple_pid_list
|
||||
{
|
||||
|
|
|
@ -1,3 +1,12 @@
|
|||
2020-10-31 Simon Marchi <simon.marchi@polymtl.ca>
|
||||
|
||||
* 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.
|
||||
|
||||
2020-10-31 Simon Marchi <simon.marchi@polymtl.ca>
|
||||
|
||||
* common.m4: Replace AC_TRY_COMPILE with AC_COMPILE_IFELSE +
|
||||
|
|
|
@ -39,8 +39,21 @@ debug_printf (const char *fmt, ...)
|
|||
/* See gdbsupport/common-debug.h. */
|
||||
|
||||
void
|
||||
debug_prefixed_vprintf (const char *module, const char *func, const char *format,
|
||||
va_list args)
|
||||
debug_prefixed_printf (const char *module, const char *func,
|
||||
const char *format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start (ap, format);
|
||||
debug_prefixed_vprintf (module, func, format, ap);
|
||||
va_end (ap);
|
||||
}
|
||||
|
||||
/* See gdbsupport/common-debug.h. */
|
||||
|
||||
void
|
||||
debug_prefixed_vprintf (const char *module, const char *func,
|
||||
const char *format, va_list args)
|
||||
{
|
||||
debug_printf ("[%s] %s: ", module, func);
|
||||
debug_vprintf (format, args);
|
||||
|
|
|
@ -41,6 +41,12 @@ extern void debug_vprintf (const char *format, va_list ap)
|
|||
/* Print a debug statement prefixed with the module and function name, and
|
||||
with a newline at the end. */
|
||||
|
||||
extern void ATTRIBUTE_PRINTF (3, 4) debug_prefixed_printf
|
||||
(const char *module, const char *func, const char *format, ...);
|
||||
|
||||
/* Print a debug statement prefixed with the module and function name, and
|
||||
with a newline at the end. */
|
||||
|
||||
extern void ATTRIBUTE_PRINTF (3, 0) debug_prefixed_vprintf
|
||||
(const char *module, const char *func, const char *format, va_list args);
|
||||
|
||||
|
|
|
@ -912,14 +912,3 @@ poll_timers (void)
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* See event-loop.h. */
|
||||
|
||||
void
|
||||
event_loop_debug_printf_1 (const char *func_name, const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start (args, fmt);
|
||||
debug_prefixed_vprintf ("event-loop", func_name, fmt, args);
|
||||
va_end (args);
|
||||
}
|
||||
|
|
|
@ -126,26 +126,26 @@ enum class debug_event_loop_kind
|
|||
/* True if we are printing event loop debug statements. */
|
||||
extern debug_event_loop_kind debug_event_loop;
|
||||
|
||||
/* Print an "event loop" debug statement. Should be used through
|
||||
event_loop_debug_printf. */
|
||||
void ATTRIBUTE_PRINTF (2, 3) event_loop_debug_printf_1
|
||||
(const char *func_name, const char *fmt, ...);
|
||||
/* Print an "event loop" debug statement. */
|
||||
|
||||
#define event_loop_debug_printf(fmt, ...) \
|
||||
do \
|
||||
{ \
|
||||
if (debug_event_loop != debug_event_loop_kind::OFF) \
|
||||
event_loop_debug_printf_1 (__func__, fmt, ##__VA_ARGS__); \
|
||||
debug_prefixed_printf ("event-loop", __func__, fmt, ##__VA_ARGS__); \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
/* 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). */
|
||||
|
||||
#define event_loop_ui_debug_printf(is_ui, fmt, ...) \
|
||||
do \
|
||||
{ \
|
||||
if (debug_event_loop == debug_event_loop_kind::ALL \
|
||||
|| (debug_event_loop == debug_event_loop_kind::ALL_EXCEPT_UI \
|
||||
&& !is_ui)) \
|
||||
event_loop_debug_printf_1 (__func__, fmt, ##__VA_ARGS__); \
|
||||
debug_prefixed_printf ("event-loop", __func__, fmt, ##__VA_ARGS__); \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue