gdb: add debug prints in event loop

Add debug printouts about event loop-related events:

 - When a file descriptor handler gets invoked
 - When an async event/signal handler gets invoked

gdb/ChangeLog:

	* async-event.c (invoke_async_signal_handlers): Add debug
	print.
	(check_async_event_handlers): Likewise.
	* event-top.c (show_debug_event_loop): New function.
	(_initialize_event_top): Register "set debug event-loop"
	setting.

gdbserver/ChangeLog:

	* server.cc (handle_monitor_command): Handle "set
	debug-event-loop".
	(captured_main): Handle "--debug-event-loop".
	(monitor_show_help): Mention new setting.
	(gdbserver_usage): Mention new flag.

gdbsupport/ChangeLog:

	* event-loop.h (debug_event_loop): New variable declaration.
	(event_loop_debug_printf_1): New function declaration.
	(event_loop_debug_printf): New macro.
	* event-loop.cc (debug_event_loop): New variable.
	(handle_file_event): Add debug print.
	(event_loop_debug_printf_1): New function.

Change-Id: If78ed3a69179881368e7895b42940ce13b6a1a05
This commit is contained in:
Simon Marchi
2020-10-02 14:44:40 -04:00
committed by Simon Marchi
parent ba98841943
commit 6b01403b25
8 changed files with 192 additions and 10 deletions

View File

@@ -955,6 +955,8 @@ monitor_show_help (void)
monitor_output (" Enable h/w breakpoint/watchpoint debugging messages\n");
monitor_output (" set remote-debug <0|1>\n");
monitor_output (" Enable remote protocol debugging messages\n");
monitor_output (" set event-loop-debug <0|1>\n");
monitor_output (" Enable event loop debugging messages\n");
monitor_output (" set debug-format option1[,option2,...]\n");
monitor_output (" Add additional information to debugging messages\n");
monitor_output (" Options: all, none");
@@ -1389,6 +1391,16 @@ handle_monitor_command (char *mon, char *own_buf)
remote_debug = 0;
monitor_output ("Protocol debug output disabled.\n");
}
else if (strcmp (mon, "set event-loop-debug 1") == 0)
{
debug_event_loop = debug_event_loop_kind::ALL;
monitor_output ("Event loop debug output enabled.\n");
}
else if (strcmp (mon, "set event-loop-debug 0") == 0)
{
debug_event_loop = debug_event_loop_kind::OFF;
monitor_output ("Event loop debug output disabled.\n");
}
else if (startswith (mon, "set debug-format "))
{
std::string error_msg
@@ -3468,6 +3480,7 @@ gdbserver_usage (FILE *stream)
" none\n"
" timestamp\n"
" --remote-debug Enable remote protocol debugging output.\n"
" --event-loop-debug Enable event loop debugging output.\n"
" --disable-packet=OPT1[,OPT2,...]\n"
" Disable support for RSP packets or features.\n"
" Options:\n"
@@ -3683,6 +3696,8 @@ captured_main (int argc, char *argv[])
}
else if (strcmp (*next_arg, "--remote-debug") == 0)
remote_debug = 1;
else if (strcmp (*next_arg, "--event-loop-debug") == 0)
debug_event_loop = debug_event_loop_kind::ALL;
else if (startswith (*next_arg, "--debug-file="))
debug_set_output ((*next_arg) + sizeof ("--debug-file=") -1);
else if (strcmp (*next_arg, "--disable-packet") == 0)