aboutsummaryrefslogtreecommitdiff
path: root/gdb/python
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/python')
-rw-r--r--gdb/python/py-all-events.def1
-rw-r--r--gdb/python/py-event-types.def5
-rw-r--r--gdb/python/py-tui.c28
3 files changed, 34 insertions, 0 deletions
diff --git a/gdb/python/py-all-events.def b/gdb/python/py-all-events.def
index 4df5541..f315e75 100644
--- a/gdb/python/py-all-events.def
+++ b/gdb/python/py-all-events.def
@@ -45,3 +45,4 @@ GDB_PY_DEFINE_EVENT(connection_removed)
GDB_PY_DEFINE_EVENT(executable_changed)
GDB_PY_DEFINE_EVENT(new_progspace)
GDB_PY_DEFINE_EVENT(free_progspace)
+GDB_PY_DEFINE_EVENT(tui_enabled)
diff --git a/gdb/python/py-event-types.def b/gdb/python/py-event-types.def
index f43a51b..e22f042 100644
--- a/gdb/python/py-event-types.def
+++ b/gdb/python/py-event-types.def
@@ -140,3 +140,8 @@ GDB_PY_DEFINE_EVENT_TYPE (free_progspace,
"FreeProgspaceEvent",
"GDB free Progspace event object",
event_object_type);
+
+GDB_PY_DEFINE_EVENT_TYPE (tui_enabled,
+ "TuiEnabledEvent",
+ "GDB TUI enabled event object",
+ event_object_type);
diff --git a/gdb/python/py-tui.c b/gdb/python/py-tui.c
index afa6f36..09f0a60 100644
--- a/gdb/python/py-tui.c
+++ b/gdb/python/py-tui.c
@@ -36,6 +36,9 @@
#include "tui/tui-layout.h"
#include "tui/tui-wingeneral.h"
#include "tui/tui-winsource.h"
+#include "observable.h"
+#include "py-events.h"
+#include "py-event.h"
class tui_py_window;
@@ -616,6 +619,29 @@ PyTypeObject gdbpy_tui_window_object_type =
0, /* tp_alloc */
};
+/* Called when TUI is enabled or disabled. */
+
+static void
+gdbpy_tui_enabled (bool state)
+{
+ gdbpy_enter enter_py;
+
+ if (evregpy_no_listeners_p (gdb_py_events.tui_enabled))
+ return;
+
+ gdbpy_ref<> event_obj = create_event_object (&tui_enabled_event_object_type);
+ if (event_obj == nullptr)
+ {
+ gdbpy_print_stack ();
+ return;
+ }
+
+ gdbpy_ref<> code (PyBool_FromLong (state));
+ if (evpy_add_attribute (event_obj.get (), "enabled", code.get ()) < 0
+ || evpy_emit_event (event_obj.get (), gdb_py_events.tui_enabled) < 0)
+ gdbpy_print_stack ();
+}
+
#endif /* TUI */
/* Initialize this module. */
@@ -627,6 +653,8 @@ gdbpy_initialize_tui ()
gdbpy_tui_window_object_type.tp_new = PyType_GenericNew;
if (gdbpy_type_ready (&gdbpy_tui_window_object_type) < 0)
return -1;
+
+ gdb::observers::tui_enabled.attach (gdbpy_tui_enabled, "py-tui");
#endif /* TUI */
return 0;