]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb: introduce a per-interpreter event servicing method
authorPatrick Monnerat <patrick@monnerat.net>
Fri, 30 May 2025 17:16:56 +0000 (19:16 +0200)
committerPatrick Monnerat <patrick@monnerat.net>
Mon, 2 Jun 2025 11:19:47 +0000 (13:19 +0200)
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.

gdb/interps.h
gdb/main.c
gdb/top.c

index 8d35309f6868216e4f637044eeaf74a3a700272c..c74495bce18a7c90756a568da90a417f3da06f04 100644 (file)
@@ -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.  */
index 2dcb67d7ce8f7a2d3f9398238ec0d7fa724cb9b6..1806ca0310d961fc8ad1365681ae3b1c20c97c24 100644 (file)
@@ -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)
        {
index 6adef467b904d830b3180f8adb33a05f524e0521..25a2afe09c87e62b1837f0095ce6adceb6339d8e 100644 (file)
--- 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;