aboutsummaryrefslogtreecommitdiff
path: root/gdbsupport/event-loop.h
diff options
context:
space:
mode:
authorPatrick Monnerat <patrick@monnerat.net>2022-07-15 17:18:32 +0200
committerPatrick Monnerat <patrick@monnerat.net>2022-08-18 11:56:38 +0200
commitbac814af175e89d73b3bdda98d25d684ab5b3e7b (patch)
tree8aa4b054bcd72ab88ce80c53d2af6022fa4aafd9 /gdbsupport/event-loop.h
parent8255dbf0dd513f39bc161f2d4cc945213fbe107e (diff)
downloadgdb-bac814af175e89d73b3bdda98d25d684ab5b3e7b.zip
gdb-bac814af175e89d73b3bdda98d25d684ab5b3e7b.tar.gz
gdb-bac814af175e89d73b3bdda98d25d684ab5b3e7b.tar.bz2
gdbsupport/event-loop: add a timeout parameter to gdb_do_one_event
Since commit b2d8657, having a per-interpreter event/command loop is not possible anymore. As Insight uses a GUI that has its own event loop, gdb and GUI event loops have then to be "merged" (i.e.: work together). But this is problematic as gdb_do_one_event is not aware of this alternate event loop and thus may wait forever. A solution is to delegate GUI events handling to the gdb events handler. Insight uses Tck/Tk as GUI and the latter offers a "notifier" feature to implement such a delegation. The Tcl notifier spec requires the event wait function to support a timeout parameter. Unfortunately gdb_do_one_event does not feature such a parameter. This timeout cannot be implemented externally with a gdb timer, because it would become an event by itself and thus can cause a legitimate event to be missed if the timeout is 0. Tcl implements "idle events" that are (internally) triggered only when no other event is pending. For this reason, it can call the event wait function with a 0 timeout quite often. This patch implements a wait timeout to gdb_do_one_event. The initial pending events monitoring is performed as before without the possibility to enter a wait state. If no pending event has been found during this phase, a timer is then created for the given timeout in order to re-use the implemented timeout logic and the event wait is then performed. This "internal" timer only limits the wait time and should never be triggered. It is deleted upon gdb_do_one_event exit. The new parameter defaults to "no timeout" (-1): as it is used by Insight only, there is no need to update calls from the gdb source tree.
Diffstat (limited to 'gdbsupport/event-loop.h')
-rw-r--r--gdbsupport/event-loop.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/gdbsupport/event-loop.h b/gdbsupport/event-loop.h
index 9ed5928..c82493e 100644
--- a/gdbsupport/event-loop.h
+++ b/gdbsupport/event-loop.h
@@ -76,7 +76,7 @@ typedef void (timer_handler_func) (gdb_client_data);
/* Exported functions from event-loop.c */
-extern int gdb_do_one_event (void);
+extern int gdb_do_one_event (int mstimeout = -1);
extern void delete_file_handler (int fd);
/* Add a file handler/descriptor to the list of descriptors we are