aboutsummaryrefslogtreecommitdiff
path: root/gdb/mi
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/mi')
-rw-r--r--gdb/mi/mi-interp.c64
-rw-r--r--gdb/mi/mi-interp.h1
-rw-r--r--gdb/mi/mi-main.c2
3 files changed, 23 insertions, 44 deletions
diff --git a/gdb/mi/mi-interp.c b/gdb/mi/mi-interp.c
index 313d751..2984cb9 100644
--- a/gdb/mi/mi-interp.c
+++ b/gdb/mi/mi-interp.c
@@ -1087,60 +1087,40 @@ mi_memory_changed (struct inferior *inferior, CORE_ADDR memaddr,
}
}
-/* Emit an event when the selection context (inferior, thread, frame)
- changed. */
-
-static void
-mi_user_selected_context_changed (user_selected_what selection)
+void
+mi_interp::on_user_selected_context_changed (user_selected_what selection)
{
- struct thread_info *tp;
-
/* Don't send an event if we're responding to an MI command. */
if (mi_suppress_notification.user_selected_context)
return;
- if (inferior_ptid != null_ptid)
- tp = inferior_thread ();
- else
- tp = NULL;
-
- SWITCH_THRU_ALL_UIS ()
- {
- struct mi_interp *mi = as_mi_interp (top_level_interpreter ());
- struct ui_out *mi_uiout;
-
- if (mi == NULL)
- continue;
+ thread_info *tp = inferior_ptid != null_ptid ? inferior_thread () : nullptr;
+ ui_out *mi_uiout = this->interp_ui_out ();
+ ui_out_redirect_pop redirect_popper (mi_uiout, this->event_channel);
- mi_uiout = top_level_interpreter ()->interp_ui_out ();
+ target_terminal::scoped_restore_terminal_state term_state;
+ target_terminal::ours_for_output ();
- ui_out_redirect_pop redirect_popper (mi_uiout, mi->event_channel);
+ if (selection & USER_SELECTED_INFERIOR)
+ print_selected_inferior (this->cli_uiout);
- target_terminal::scoped_restore_terminal_state term_state;
- target_terminal::ours_for_output ();
+ if (tp != NULL
+ && (selection & (USER_SELECTED_THREAD | USER_SELECTED_FRAME)))
+ {
+ print_selected_thread_frame (this->cli_uiout, selection);
- if (selection & USER_SELECTED_INFERIOR)
- print_selected_inferior (mi->cli_uiout);
+ gdb_printf (this->event_channel, "thread-selected,id=\"%d\"",
+ tp->global_num);
- if (tp != NULL
- && (selection & (USER_SELECTED_THREAD | USER_SELECTED_FRAME)))
+ if (tp->state != THREAD_RUNNING)
{
- print_selected_thread_frame (mi->cli_uiout, selection);
-
- gdb_printf (mi->event_channel,
- "thread-selected,id=\"%d\"",
- tp->global_num);
-
- if (tp->state != THREAD_RUNNING)
- {
- if (has_stack_frames ())
- print_stack_frame_to_uiout (mi_uiout, get_selected_frame (NULL),
- 1, SRC_AND_LOC, 1);
- }
+ if (has_stack_frames ())
+ print_stack_frame_to_uiout (mi_uiout, get_selected_frame (NULL),
+ 1, SRC_AND_LOC, 1);
}
-
- gdb_flush (mi->event_channel);
}
+
+ gdb_flush (this->event_channel);
}
ui_out *
@@ -1234,6 +1214,4 @@ _initialize_mi_interp ()
gdb::observers::command_param_changed.attach (mi_command_param_changed,
"mi-interp");
gdb::observers::memory_changed.attach (mi_memory_changed, "mi-interp");
- gdb::observers::user_selected_context_changed.attach
- (mi_user_selected_context_changed, "mi-interp");
}
diff --git a/gdb/mi/mi-interp.h b/gdb/mi/mi-interp.h
index 6a02eef..bb66e63 100644
--- a/gdb/mi/mi-interp.h
+++ b/gdb/mi/mi-interp.h
@@ -49,6 +49,7 @@ public:
void on_no_history () override;
void on_sync_execution_done () override;
void on_command_error () override;
+ void on_user_selected_context_changed (user_selected_what selection) override;
/* MI's output channels */
mi_console_file *out;
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c
index dc7d717..7503ffd 100644
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -2138,7 +2138,7 @@ mi_cmd_execute (struct mi_parse *parse)
if (!parse->cmd->preserve_user_selected_context ()
&& current_user_selected_context.has_changed ())
- gdb::observers::user_selected_context_changed.notify
+ interps_notify_user_selected_context_changed
(USER_SELECTED_THREAD | USER_SELECTED_FRAME);
}