aboutsummaryrefslogtreecommitdiff
path: root/gdb/cli
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/cli')
-rw-r--r--gdb/cli/cli-decode.c32
-rw-r--r--gdb/cli/cli-decode.h6
-rw-r--r--gdb/cli/cli-interp.c38
3 files changed, 74 insertions, 2 deletions
diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c
index 0d2b137..acc9c42 100644
--- a/gdb/cli/cli-decode.c
+++ b/gdb/cli/cli-decode.c
@@ -253,6 +253,7 @@ add_cmd (const char *name, enum command_class theclass, cmd_cfunc_ftype *fun,
c->user_commands = NULL;
c->cmd_pointer = NULL;
c->alias_chain = NULL;
+ c->suppress_notification = NULL;
return c;
}
@@ -883,7 +884,22 @@ add_com_alias (const char *name, const char *oldname, enum command_class theclas
{
return add_alias_cmd (name, oldname, theclass, abbrev_flag, &cmdlist);
}
-
+
+/* Add an element with a suppress notification to the list of commands. */
+
+struct cmd_list_element *
+add_com_suppress_notification (const char *name, enum command_class theclass,
+ cmd_cfunc_ftype *fun, const char *doc,
+ int *suppress_notification)
+{
+ struct cmd_list_element *element;
+
+ element = add_cmd (name, theclass, fun, doc, &cmdlist);
+ element->suppress_notification = suppress_notification;
+
+ return element;
+}
+
/* Recursively walk the commandlist structures, and print out the
documentation of commands that match our regex in either their
name, or their documentation.
@@ -1885,7 +1901,19 @@ void
cmd_func (struct cmd_list_element *cmd, char *args, int from_tty)
{
if (cmd_func_p (cmd))
- (*cmd->func) (cmd, args, from_tty);
+ {
+ struct cleanup *cleanups = make_cleanup (null_cleanup, NULL);
+
+ if (cmd->suppress_notification != NULL)
+ {
+ make_cleanup_restore_integer (cmd->suppress_notification);
+ *cmd->suppress_notification = 1;
+ }
+
+ (*cmd->func) (cmd, args, from_tty);
+
+ do_cleanups (cleanups);
+ }
else
error (_("Invalid command"));
}
diff --git a/gdb/cli/cli-decode.h b/gdb/cli/cli-decode.h
index 4ea8063..4ef2e1b 100644
--- a/gdb/cli/cli-decode.h
+++ b/gdb/cli/cli-decode.h
@@ -218,6 +218,12 @@ struct cmd_list_element
/* Link pointer for aliases on an alias list. */
struct cmd_list_element *alias_chain;
+
+ /* If non-null, the pointer to a field in 'struct
+ cli_suppress_notification', which will be set to true in cmd_func
+ when this command is being executed. It will be set back to false
+ when the command has been executed. */
+ int *suppress_notification;
};
extern void help_cmd_list (struct cmd_list_element *, enum command_class,
diff --git a/gdb/cli/cli-interp.c b/gdb/cli/cli-interp.c
index 5d67ba4..cc556a4 100644
--- a/gdb/cli/cli-interp.c
+++ b/gdb/cli/cli-interp.c
@@ -37,6 +37,12 @@ struct cli_interp
struct ui_out *cli_uiout;
};
+/* Suppress notification struct. */
+struct cli_suppress_notification cli_suppress_notification =
+ {
+ 0 /* user_selected_context_changed */
+ };
+
/* Returns the INTERP's data cast as cli_interp if INTERP is a CLI,
and returns NULL otherwise. */
@@ -229,6 +235,36 @@ cli_on_command_error (void)
display_gdb_prompt (NULL);
}
+/* Observer for the user_selected_context_changed notification. */
+
+static void
+cli_on_user_selected_context_changed (user_selected_what selection)
+{
+ struct switch_thru_all_uis state;
+ struct thread_info *tp;
+
+ /* This event is suppressed. */
+ if (cli_suppress_notification.user_selected_context)
+ return;
+
+ tp = find_thread_ptid (inferior_ptid);
+
+ SWITCH_THRU_ALL_UIS (state)
+ {
+ struct cli_interp *cli = as_cli_interp (top_level_interpreter ());
+
+ if (cli == NULL)
+ continue;
+
+ if (selection & USER_SELECTED_INFERIOR)
+ print_selected_inferior (cli->cli_uiout);
+
+ if (tp != NULL
+ && ((selection & (USER_SELECTED_THREAD | USER_SELECTED_FRAME))))
+ print_selected_thread_frame (cli->cli_uiout, selection);
+ }
+}
+
/* pre_command_loop implementation. */
void
@@ -393,4 +429,6 @@ _initialize_cli_interp (void)
observer_attach_no_history (cli_on_no_history);
observer_attach_sync_execution_done (cli_on_sync_execution_done);
observer_attach_command_error (cli_on_command_error);
+ observer_attach_user_selected_context_changed
+ (cli_on_user_selected_context_changed);
}