[binutils-gdb] gdb: introduce a per-interpreter event servicing method
Patrick Monnerat
monnerat@sourceware.org
Mon Jun 2 12:15:25 GMT 2025
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=568ec5b9831b0d6abc7aff4e76cefcc0fa7e0c5e
commit 568ec5b9831b0d6abc7aff4e76cefcc0fa7e0c5e
Author: Patrick Monnerat <patrick@monnerat.net>
Date: Fri May 30 19:16:56 2025 +0200
gdb: introduce a per-interpreter event servicing method
This allows an interpreter to override internal calls to
gdb_do_one_event in case the former needs to handle alternate event
sources.
The default action is to call gdb_do_one_event and this is not overriden
in current internal interpreters. However this feature allows to easily
embed Tcl/Tk in insight that needs to concurrently handle Tcl events for
GUI handling.
In all cases, an interpreter event servicing method must call
gdb_do_one_event at some point.
All internal event servicing calls from gdb now direct to the
interpreter-specific method rather than gdb_do_one_event itself.
Diff:
---
gdb/interps.h | 8 ++++++++
gdb/main.c | 2 +-
gdb/top.c | 4 ++--
3 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/gdb/interps.h b/gdb/interps.h
index 8d35309f686..c74495bce18 100644
--- a/gdb/interps.h
+++ b/gdb/interps.h
@@ -23,6 +23,7 @@
#define GDB_INTERPS_H
#include "gdbsupport/intrusive_list.h"
+#include "gdbsupport/event-loop.h"
struct bpstat;
struct ui_out;
@@ -78,6 +79,13 @@ public:
virtual void pre_command_loop ()
{}
+ /* Service one event.
+ This gives the interpreter a chance to handle its own private
+ events that cannot be fed into the gdb event mechanism.
+ In all cases, this should call gdb_do_one_event at some point. */
+ virtual int do_one_event (int mstimeout = -1)
+ { return gdb_do_one_event (mstimeout); }
+
/* Returns true if this interpreter supports using the readline
library; false if it uses GDB's own simplified readline
emulation. */
diff --git a/gdb/main.c b/gdb/main.c
index 2dcb67d7ce8..1806ca0310d 100644
--- a/gdb/main.c
+++ b/gdb/main.c
@@ -399,7 +399,7 @@ start_event_loop ()
try
{
- result = gdb_do_one_event ();
+ result = current_interpreter ()->do_one_event ();
}
catch (const gdb_exception_forced_quit &ex)
{
diff --git a/gdb/top.c b/gdb/top.c
index 6adef467b90..25a2afe09c8 100644
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -415,7 +415,7 @@ wait_sync_command_done (void)
point. */
scoped_enable_commit_resumed enable ("sync wait");
- while (gdb_do_one_event () >= 0)
+ while (current_interpreter ()->do_one_event () >= 0)
if (ui->prompt_state != PROMPT_BLOCKED)
break;
}
@@ -1031,7 +1031,7 @@ gdb_readline_wrapper (const char *prompt)
(*after_char_processing_hook) ();
gdb_assert (after_char_processing_hook == NULL);
- while (gdb_do_one_event () >= 0)
+ while (current_interpreter ()->do_one_event () >= 0)
if (gdb_readline_wrapper_done)
break;
More information about the Gdb-cvs
mailing list