diff options
author | Simon Marchi <simon.marchi@polymtl.ca> | 2020-10-02 14:44:40 -0400 |
---|---|---|
committer | Simon Marchi <simon.marchi@efficios.com> | 2020-10-02 14:47:42 -0400 |
commit | 6b01403b25c0eb6ce9e7b2e3cc6f5da674089e72 (patch) | |
tree | bb4c228df496538c86485682474aee12791491c4 /gdbsupport/event-loop.h | |
parent | ba98841943b085891eb4bf4debc3981ac95bb7fb (diff) | |
download | gdb-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.h')
-rw-r--r-- | gdbsupport/event-loop.h | 44 |
1 files changed, 42 insertions, 2 deletions
diff --git a/gdbsupport/event-loop.h b/gdbsupport/event-loop.h index d7478b0..c29d6a8 100644 --- a/gdbsupport/event-loop.h +++ b/gdbsupport/event-loop.h @@ -84,11 +84,13 @@ extern void delete_file_handler (int fd); FD is the file descriptor for the file/stream to be listened to. - NAME is a user-friendly name for the handler. */ + NAME is a user-friendly name for the handler. + + If IS_UI is set, this file descriptor is used for a user interface. */ extern void add_file_handler (int fd, handler_func *proc, gdb_client_data client_data, - std::string &&name); + std::string &&name, bool is_ui = false); extern int create_timer (int milliseconds, timer_handler_func *proc, @@ -109,4 +111,42 @@ extern int invoke_async_signal_handlers (); extern int check_async_event_handlers (); +enum class debug_event_loop_kind +{ + OFF, + + /* Print all event-loop related messages, except events from user-interface + event sources. */ + ALL_EXCEPT_UI, + + /* Print all event-loop related messages. */ + ALL, +}; + +/* 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, ...); + +#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__); \ + } \ + while (0) + +#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__); \ + } \ + while (0) + #endif /* EVENT_LOOP_H */ |