summaryrefslogtreecommitdiff
path: root/gdb/tui/tui-interp.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/tui/tui-interp.c')
-rw-r--r--gdb/tui/tui-interp.c127
1 files changed, 96 insertions, 31 deletions
diff --git a/gdb/tui/tui-interp.c b/gdb/tui/tui-interp.c
index 75445001233..452dd204f80 100644
--- a/gdb/tui/tui-interp.c
+++ b/gdb/tui/tui-interp.c
@@ -38,8 +38,16 @@ static struct ui_out *tui_ui_out (struct interp *self);
gdb. */
static int tui_start_enabled = 0;
-/* The TUI interpreter. */
-static struct interp *tui_interp;
+/* Returns the INTERP if the INTERP is a TUI, and returns NULL
+ otherwise. */
+
+static struct interp *
+as_tui_interp (struct interp *interp)
+{
+ if (strcmp (interp_name (interp), INTERP_TUI) == 0)
+ return interp;
+ return NULL;
+}
/* Cleanup the tui before exiting. */
@@ -60,10 +68,17 @@ tui_exit (void)
static void
tui_on_normal_stop (struct bpstats *bs, int print_frame)
{
- if (!interp_quiet_p (tui_interp))
+ struct switch_thru_all_uis state;
+
+ SWITCH_THRU_ALL_UIS (state)
{
+ struct interp *tui = as_tui_interp (top_level_interpreter ());
+
+ if (tui == NULL)
+ continue;
+
if (print_frame)
- print_stop_event (tui_ui_out (tui_interp));
+ print_stop_event (tui_ui_out (tui));
}
}
@@ -72,8 +87,17 @@ tui_on_normal_stop (struct bpstats *bs, int print_frame)
static void
tui_on_signal_received (enum gdb_signal siggnal)
{
- if (!interp_quiet_p (tui_interp))
- print_signal_received_reason (tui_ui_out (tui_interp), siggnal);
+ struct switch_thru_all_uis state;
+
+ SWITCH_THRU_ALL_UIS (state)
+ {
+ struct interp *tui = as_tui_interp (top_level_interpreter ());
+
+ if (tui == NULL)
+ continue;
+
+ print_signal_received_reason (tui_ui_out (tui), siggnal);
+ }
}
/* Observer for the end_stepping_range notification. */
@@ -81,8 +105,17 @@ tui_on_signal_received (enum gdb_signal siggnal)
static void
tui_on_end_stepping_range (void)
{
- if (!interp_quiet_p (tui_interp))
- print_end_stepping_range_reason (tui_ui_out (tui_interp));
+ struct switch_thru_all_uis state;
+
+ SWITCH_THRU_ALL_UIS (state)
+ {
+ struct interp *tui = as_tui_interp (top_level_interpreter ());
+
+ if (tui == NULL)
+ continue;
+
+ print_end_stepping_range_reason (tui_ui_out (tui));
+ }
}
/* Observer for the signal_exited notification. */
@@ -90,8 +123,17 @@ tui_on_end_stepping_range (void)
static void
tui_on_signal_exited (enum gdb_signal siggnal)
{
- if (!interp_quiet_p (tui_interp))
- print_signal_exited_reason (tui_ui_out (tui_interp), siggnal);
+ struct switch_thru_all_uis state;
+
+ SWITCH_THRU_ALL_UIS (state)
+ {
+ struct interp *tui = as_tui_interp (top_level_interpreter ());
+
+ if (tui == NULL)
+ continue;
+
+ print_signal_exited_reason (tui_ui_out (tui), siggnal);
+ }
}
/* Observer for the exited notification. */
@@ -99,8 +141,17 @@ tui_on_signal_exited (enum gdb_signal siggnal)
static void
tui_on_exited (int exitstatus)
{
- if (!interp_quiet_p (tui_interp))
- print_exited_reason (tui_ui_out (tui_interp), exitstatus);
+ struct switch_thru_all_uis state;
+
+ SWITCH_THRU_ALL_UIS (state)
+ {
+ struct interp *tui = as_tui_interp (top_level_interpreter ());
+
+ if (tui == NULL)
+ continue;
+
+ print_exited_reason (tui_ui_out (tui), exitstatus);
+ }
}
/* Observer for the no_history notification. */
@@ -108,8 +159,17 @@ tui_on_exited (int exitstatus)
static void
tui_on_no_history (void)
{
- if (!interp_quiet_p (tui_interp))
- print_no_history_reason (tui_ui_out (tui_interp));
+ struct switch_thru_all_uis state;
+
+ SWITCH_THRU_ALL_UIS (state)
+ {
+ struct interp *tui = as_tui_interp (top_level_interpreter ());
+
+ if (tui == NULL)
+ continue;
+
+ print_no_history_reason (tui_ui_out (tui));
+ }
}
/* Observer for the sync_execution_done notification. */
@@ -117,8 +177,12 @@ tui_on_no_history (void)
static void
tui_on_sync_execution_done (void)
{
- if (!interp_quiet_p (tui_interp))
- display_gdb_prompt (NULL);
+ struct interp *tui = as_tui_interp (top_level_interpreter ());
+
+ if (tui == NULL)
+ return;
+
+ display_gdb_prompt (NULL);
}
/* Observer for the command_error notification. */
@@ -126,8 +190,12 @@ tui_on_sync_execution_done (void)
static void
tui_on_command_error (void)
{
- if (!interp_quiet_p (tui_interp))
- display_gdb_prompt (NULL);
+ struct interp *tui = as_tui_interp (top_level_interpreter ());
+
+ if (tui == NULL)
+ return;
+
+ display_gdb_prompt (NULL);
}
/* These implement the TUI interpreter. */
@@ -138,9 +206,6 @@ tui_init (struct interp *self, int top_level)
/* Install exit handler to leave the screen in a good shape. */
atexit (tui_exit);
- if (top_level)
- tui_interp = self;
-
tui_initialize_static_data ();
tui_initialize_io ();
@@ -148,16 +213,6 @@ tui_init (struct interp *self, int top_level)
if (ui_file_isatty (gdb_stdout))
tui_initialize_readline ();
- /* If changing this, remember to update cli-interp.c as well. */
- observer_attach_normal_stop (tui_on_normal_stop);
- observer_attach_signal_received (tui_on_signal_received);
- observer_attach_end_stepping_range (tui_on_end_stepping_range);
- observer_attach_signal_exited (tui_on_signal_exited);
- observer_attach_exited (tui_on_exited);
- observer_attach_no_history (tui_on_no_history);
- observer_attach_sync_execution_done (tui_on_sync_execution_done);
- observer_attach_command_error (tui_on_command_error);
-
return NULL;
}
@@ -246,4 +301,14 @@ _initialize_tui_interp (void)
xfree (interpreter_p);
interpreter_p = xstrdup (INTERP_TUI);
}
+
+ /* If changing this, remember to update cli-interp.c as well. */
+ observer_attach_normal_stop (tui_on_normal_stop);
+ observer_attach_signal_received (tui_on_signal_received);
+ observer_attach_end_stepping_range (tui_on_end_stepping_range);
+ observer_attach_signal_exited (tui_on_signal_exited);
+ observer_attach_exited (tui_on_exited);
+ observer_attach_no_history (tui_on_no_history);
+ observer_attach_sync_execution_done (tui_on_sync_execution_done);
+ observer_attach_command_error (tui_on_command_error);
}