aboutsummaryrefslogtreecommitdiff
path: root/gdb/mi
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/mi')
-rw-r--r--gdb/mi/mi-cmd-stack.c6
-rw-r--r--gdb/mi/mi-interp.c30
-rw-r--r--gdb/mi/mi-main.c89
3 files changed, 27 insertions, 98 deletions
diff --git a/gdb/mi/mi-cmd-stack.c b/gdb/mi/mi-cmd-stack.c
index acb44a2..fadfdaa 100644
--- a/gdb/mi/mi-cmd-stack.c
+++ b/gdb/mi/mi-cmd-stack.c
@@ -34,6 +34,7 @@
#include "extension.h"
#include <ctype.h>
#include "mi-parse.h"
+#include "user-selection.h"
enum what_to_list { locals, arguments, all };
@@ -696,7 +697,10 @@ mi_cmd_stack_select_frame (char *command, char **argv, int argc)
if (argc == 0 || argc > 1)
error (_("-stack-select-frame: Usage: FRAME_SPEC"));
- select_frame_command (argv[0], 1 /* not used */ );
+ struct frame_info *frame = parse_frame_specification (argv[0], NULL);
+ user_selection *us = global_user_selection ();
+
+ us->select_frame (frame, true);
}
void
diff --git a/gdb/mi/mi-interp.c b/gdb/mi/mi-interp.c
index 86340e4..958f154 100644
--- a/gdb/mi/mi-interp.c
+++ b/gdb/mi/mi-interp.c
@@ -39,6 +39,7 @@
#include "cli-out.h"
#include "thread-fsm.h"
#include "cli/cli-interp.h"
+#include "user-selection.h"
/* These are the interpreter setup, etc. functions for the MI
interpreter. */
@@ -1282,16 +1283,17 @@ mi_memory_changed (struct inferior *inferior, CORE_ADDR memaddr,
changed. */
static void
-mi_user_selected_context_changed (user_selected_what selection)
+mi_on_global_user_selection_changed (user_selection *us,
+ user_selected_what selection)
{
- struct thread_info *tp;
+ struct inferior *inf = us->inferior ();
+ struct thread_info *thread = us->thread ();
+ struct frame_info *frame = us->frame ();
/* Don't send an event if we're responding to an MI command. */
if (mi_suppress_notification.user_selected_context)
return;
- tp = find_thread_ptid (inferior_ptid);
-
SWITCH_THRU_ALL_UIS ()
{
struct mi_interp *mi = as_mi_interp (top_level_interpreter ());
@@ -1311,23 +1313,19 @@ mi_user_selected_context_changed (user_selected_what selection)
target_terminal_ours_for_output ();
if (selection & USER_SELECTED_INFERIOR)
- print_selected_inferior (mi->cli_uiout);
+ print_selected_inferior (mi->cli_uiout, inf);
- if (tp != NULL
+ if (thread != NULL
&& (selection & (USER_SELECTED_THREAD | USER_SELECTED_FRAME)))
{
- print_selected_thread_frame (mi->cli_uiout, selection);
+ print_selected_thread_frame (mi->cli_uiout, us, selection);
fprintf_unfiltered (mi->event_channel,
"thread-selected,id=\"%d\"",
- tp->global_num);
+ thread->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 (thread->state != THREAD_RUNNING && frame != nullptr)
+ print_stack_frame_to_uiout (mi_uiout, frame, 1, SRC_AND_LOC, 1);
}
gdb_flush (mi->event_channel);
@@ -1439,6 +1437,6 @@ _initialize_mi_interp (void)
observer_attach_command_param_changed (mi_command_param_changed);
observer_attach_memory_changed (mi_memory_changed);
observer_attach_sync_execution_done (mi_on_sync_execution_done);
- observer_attach_user_selected_context_changed
- (mi_user_selected_context_changed);
+ observer_attach_global_user_selection_changed
+ (mi_on_global_user_selection_changed);
}
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c
index cf4e45a..63458d9 100644
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -54,6 +54,7 @@
#include "extension.h"
#include "gdbcmd.h"
#include "observer.h"
+#include "user-selection.h"
#include <ctype.h>
#include "run-time-clock.h"
@@ -560,31 +561,15 @@ mi_cmd_target_flash_erase (char *command, char **argv, int argc)
void
mi_cmd_thread_select (char *command, char **argv, int argc)
{
- enum gdb_rc rc;
- char *mi_error_message;
- ptid_t previous_ptid = inferior_ptid;
-
if (argc != 1)
error (_("-thread-select: USAGE: threadnum."));
- rc = gdb_thread_select (current_uiout, argv[0], &mi_error_message);
+ thread_select (argv[0], false);
- /* If thread switch did not succeed don't notify or print. */
- if (rc == GDB_RC_FAIL)
- {
- make_cleanup (xfree, mi_error_message);
- error ("%s", mi_error_message);
- }
+ user_selection *us = global_user_selection ();
- print_selected_thread_frame (current_uiout,
+ print_selected_thread_frame (current_uiout, us,
USER_SELECTED_THREAD | USER_SELECTED_FRAME);
-
- /* Notify if the thread has effectively changed. */
- if (!ptid_equal (inferior_ptid, previous_ptid))
- {
- observer_notify_user_selected_context_changed (USER_SELECTED_THREAD
- | USER_SELECTED_FRAME);
- }
}
void
@@ -2025,6 +2010,8 @@ captured_mi_execute_command (struct ui_out *uiout, struct mi_parse *context)
{
char *argv[2];
+ apply_global_user_selection ();
+
/* A CLI command was read from the input stream. */
/* This "feature" will be removed as soon as we have a
complete set of mi commands. */
@@ -2085,34 +2072,6 @@ mi_print_exception (const char *token, struct gdb_exception exception)
fputs_unfiltered ("\n", mi->raw_stdout);
}
-/* Determine whether the parsed command already notifies the
- user_selected_context_changed observer. */
-
-static int
-command_notifies_uscc_observer (struct mi_parse *command)
-{
- if (command->op == CLI_COMMAND)
- {
- /* CLI commands "thread" and "inferior" already send it. */
- return (strncmp (command->command, "thread ", 7) == 0
- || strncmp (command->command, "inferior ", 9) == 0);
- }
- else /* MI_COMMAND */
- {
- if (strcmp (command->command, "interpreter-exec") == 0
- && command->argc > 1)
- {
- /* "thread" and "inferior" again, but through -interpreter-exec. */
- return (strncmp (command->argv[1], "thread ", 7) == 0
- || strncmp (command->argv[1], "inferior ", 9) == 0);
- }
-
- else
- /* -thread-select already sends it. */
- return strcmp (command->command, "thread-select") == 0;
- }
-}
-
void
mi_execute_command (const char *cmd, int from_tty)
{
@@ -2139,7 +2098,6 @@ mi_execute_command (const char *cmd, int from_tty)
if (command != NULL)
{
- ptid_t previous_ptid = inferior_ptid;
struct cleanup *cleanup = make_cleanup (null_cleanup, NULL);
command->token = token;
@@ -2178,39 +2136,6 @@ mi_execute_command (const char *cmd, int from_tty)
bpstat_do_actions ();
- if (/* The notifications are only output when the top-level
- interpreter (specified on the command line) is MI. */
- interp_ui_out (top_level_interpreter ())->is_mi_like_p ()
- /* Don't try report anything if there are no threads --
- the program is dead. */
- && thread_count () != 0
- /* If the command already reports the thread change, no need to do it
- again. */
- && !command_notifies_uscc_observer (command))
- {
- struct mi_interp *mi = (struct mi_interp *) top_level_interpreter ();
- int report_change = 0;
-
- if (command->thread == -1)
- {
- report_change = (!ptid_equal (previous_ptid, null_ptid)
- && !ptid_equal (inferior_ptid, previous_ptid)
- && !ptid_equal (inferior_ptid, null_ptid));
- }
- else if (!ptid_equal (inferior_ptid, null_ptid))
- {
- struct thread_info *ti = inferior_thread ();
-
- report_change = (ti->global_num != command->thread);
- }
-
- if (report_change)
- {
- observer_notify_user_selected_context_changed
- (USER_SELECTED_THREAD | USER_SELECTED_FRAME);
- }
- }
-
mi_parse_free (command);
do_cleanups (cleanup);
@@ -2224,6 +2149,8 @@ mi_cmd_execute (struct mi_parse *parse)
cleanup = prepare_execute_command ();
+ apply_global_user_selection ();
+
if (parse->all && parse->thread_group != -1)
error (_("Cannot specify --thread-group together with --all"));