From c058728c31684d08da396f1bf50fabaa196dc9d9 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Sun, 16 Jan 2022 21:27:58 -0500 Subject: gdbserver: introduce threads_debug_printf, THREADS_SCOPED_DEBUG_ENTER_EXIT Add the threads_debug_printf and THREADS_SCOPED_DEBUG_ENTER_EXIT, which use the logging infrastructure from gdbsupport/common-debug.h. Replace all debug_print uses that are predicated by debug_threads with threads_dethreads_debug_printf. Replace uses of the debug_enter and debug_exit macros with THREADS_SCOPED_DEBUG_ENTER_EXIT, which serves essentially the same purpose, but allows showing what comes between the enter and the exit in an indented form. Note that "threads" debug is currently used for a bit of everything in GDBserver, not only threads related stuff. It should ideally be cleaned up and separated logically as is done in GDB, but that's out of the scope of this patch. Change-Id: I2d4546464462cb4c16f7f1168c5cec5a89f2289a --- gdbserver/tracepoint.cc | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) (limited to 'gdbserver/tracepoint.cc') diff --git a/gdbserver/tracepoint.cc b/gdbserver/tracepoint.cc index 0136f6e..5459dc3 100644 --- a/gdbserver/tracepoint.cc +++ b/gdbserver/tracepoint.cc @@ -87,11 +87,7 @@ trace_vdebug (const char *fmt, ...) #define trace_debug(fmt, args...) \ do { \ - if (debug_threads) \ - { \ - debug_printf ((fmt), ##args); \ - debug_printf ("\n"); \ - } \ + threads_debug_printf ((fmt), ##args); \ } while (0) #endif @@ -324,8 +320,7 @@ tracepoint_look_up_symbols (void) if (look_up_one_symbol (symbol_list[i].name, addrp, 1) == 0) { - if (debug_threads) - debug_printf ("symbol `%s' not found\n", symbol_list[i].name); + threads_debug_printf ("symbol `%s' not found", symbol_list[i].name); return; } } @@ -4519,15 +4514,14 @@ handle_tracepoint_bkpts (struct thread_info *tinfo, CORE_ADDR stop_pc) ipa_expr_eval_result, paddress (ipa_error_tracepoint)); - if (debug_threads) - { - if (ipa_trace_buffer_is_full) - trace_debug ("lib stopped due to full buffer."); - if (ipa_stopping_tracepoint) - trace_debug ("lib stopped due to tpoint"); - if (ipa_error_tracepoint) - trace_debug ("lib stopped due to error"); - } + if (ipa_trace_buffer_is_full) + trace_debug ("lib stopped due to full buffer."); + + if (ipa_stopping_tracepoint) + trace_debug ("lib stopped due to tpoint"); + + if (ipa_error_tracepoint) + trace_debug ("lib stopped due to error"); if (ipa_stopping_tracepoint != 0) { -- cgit v1.1