aboutsummaryrefslogtreecommitdiff
path: root/gdbsupport/event-loop.cc
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@polymtl.ca>2020-10-02 14:44:40 -0400
committerSimon Marchi <simon.marchi@efficios.com>2020-10-02 14:47:42 -0400
commit6b01403b25c0eb6ce9e7b2e3cc6f5da674089e72 (patch)
treebb4c228df496538c86485682474aee12791491c4 /gdbsupport/event-loop.cc
parentba98841943b085891eb4bf4debc3981ac95bb7fb (diff)
downloadgdb-6b01403b25c0eb6ce9e7b2e3cc6f5da674089e72.zip
gdb-6b01403b25c0eb6ce9e7b2e3cc6f5da674089e72.tar.gz
gdb-6b01403b25c0eb6ce9e7b2e3cc6f5da674089e72.tar.bz2
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
Diffstat (limited to 'gdbsupport/event-loop.cc')
-rw-r--r--gdbsupport/event-loop.cc38
1 files changed, 32 insertions, 6 deletions
diff --git a/gdbsupport/event-loop.cc b/gdbsupport/event-loop.cc
index 0d78122..9494158 100644
--- a/gdbsupport/event-loop.cc
+++ b/gdbsupport/event-loop.cc
@@ -34,6 +34,10 @@
#include "gdbsupport/gdb_sys_time.h"
#include "gdbsupport/gdb_select.h"
+/* See event-loop.h. */
+
+debug_event_loop_kind debug_event_loop;
+
/* Tell create_file_handler what events we are interested in.
This is used by the select version of the event loop. */
@@ -64,6 +68,9 @@ struct file_handler
/* User-friendly name of this handler. Heap-allocated, owned by this.*/
std::string *name;
+ /* If set, this file descriptor is used for a user interface. */
+ bool is_ui;
+
/* Was an error detected on this fd? */
int error;
@@ -164,7 +171,7 @@ timer_list;
static void create_file_handler (int fd, int mask, handler_func *proc,
gdb_client_data client_data,
- std::string &&name);
+ std::string &&name, bool is_ui);
static int gdb_wait_for_event (int);
static int update_wait_timeout (void);
static int poll_timers (void);
@@ -239,7 +246,7 @@ gdb_do_one_event (void)
void
add_file_handler (int fd, handler_func *proc, gdb_client_data client_data,
- std::string &&name)
+ std::string &&name, bool is_ui)
{
#ifdef HAVE_POLL
struct pollfd fds;
@@ -265,7 +272,8 @@ add_file_handler (int fd, handler_func *proc, gdb_client_data client_data,
if (use_poll)
{
#ifdef HAVE_POLL
- create_file_handler (fd, POLLIN, proc, client_data, std::move (name));
+ create_file_handler (fd, POLLIN, proc, client_data, std::move (name),
+ is_ui);
#else
internal_error (__FILE__, __LINE__,
_("use_poll without HAVE_POLL"));
@@ -273,7 +281,7 @@ add_file_handler (int fd, handler_func *proc, gdb_client_data client_data,
}
else
create_file_handler (fd, GDB_READABLE | GDB_EXCEPTION,
- proc, client_data, std::move (name));
+ proc, client_data, std::move (name), is_ui);
}
/* Helper for add_file_handler.
@@ -289,7 +297,8 @@ add_file_handler (int fd, handler_func *proc, gdb_client_data client_data,
static void
create_file_handler (int fd, int mask, handler_func * proc,
- gdb_client_data client_data, std::string &&name)
+ gdb_client_data client_data, std::string &&name,
+ bool is_ui)
{
file_handler *file_ptr;
@@ -358,6 +367,7 @@ create_file_handler (int fd, int mask, handler_func * proc,
file_ptr->client_data = client_data;
file_ptr->mask = mask;
file_ptr->name = new std::string (std::move (name));
+ file_ptr->is_ui = is_ui;
}
/* Return the next file handler to handle, and advance to the next
@@ -558,7 +568,12 @@ handle_file_event (file_handler *file_ptr, int ready_mask)
/* If there was a match, then call the handler. */
if (mask != 0)
- (*file_ptr->proc) (file_ptr->error, file_ptr->client_data);
+ {
+ event_loop_ui_debug_printf (file_ptr->is_ui,
+ "invoking fd file handler `%s`",
+ file_ptr->name->c_str ());
+ file_ptr->proc (file_ptr->error, file_ptr->client_data);
+ }
}
}
}
@@ -897,3 +912,14 @@ 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);
+}