Skip to content

Commit 568ec5b

Browse files
committed
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.
1 parent 9197e8e commit 568ec5b

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

gdb/interps.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#define GDB_INTERPS_H
2424

2525
#include "gdbsupport/intrusive_list.h"
26+
#include "gdbsupport/event-loop.h"
2627

2728
struct bpstat;
2829
struct ui_out;
@@ -78,6 +79,13 @@ class interp : public intrusive_list_node<interp>
7879
virtual void pre_command_loop ()
7980
{}
8081

82+
/* Service one event.
83+
This gives the interpreter a chance to handle its own private
84+
events that cannot be fed into the gdb event mechanism.
85+
In all cases, this should call gdb_do_one_event at some point. */
86+
virtual int do_one_event (int mstimeout = -1)
87+
{ return gdb_do_one_event (mstimeout); }
88+
8189
/* Returns true if this interpreter supports using the readline
8290
library; false if it uses GDB's own simplified readline
8391
emulation. */

gdb/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ start_event_loop ()
399399

400400
try
401401
{
402-
result = gdb_do_one_event ();
402+
result = current_interpreter ()->do_one_event ();
403403
}
404404
catch (const gdb_exception_forced_quit &ex)
405405
{

gdb/top.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ wait_sync_command_done (void)
415415
point. */
416416
scoped_enable_commit_resumed enable ("sync wait");
417417

418-
while (gdb_do_one_event () >= 0)
418+
while (current_interpreter ()->do_one_event () >= 0)
419419
if (ui->prompt_state != PROMPT_BLOCKED)
420420
break;
421421
}
@@ -1031,7 +1031,7 @@ gdb_readline_wrapper (const char *prompt)
10311031
(*after_char_processing_hook) ();
10321032
gdb_assert (after_char_processing_hook == NULL);
10331033

1034-
while (gdb_do_one_event () >= 0)
1034+
while (current_interpreter ()->do_one_event () >= 0)
10351035
if (gdb_readline_wrapper_done)
10361036
break;
10371037

0 commit comments

Comments
 (0)