diff options
author | Yao Qi <yao@codesourcery.com> | 2012-08-09 12:53:46 +0000 |
---|---|---|
committer | Yao Qi <yao@codesourcery.com> | 2012-08-09 12:53:46 +0000 |
commit | 5b9afe8a3531f45255ee97465b52d2769a9a8ab5 (patch) | |
tree | 7d475e24cb1da1640836ae4b9ed9840f07291ef8 /gdb/cli/cli-decode.c | |
parent | d21911eaddba472db273e212ae6047186974f394 (diff) | |
download | gdb-5b9afe8a3531f45255ee97465b52d2769a9a8ab5.zip gdb-5b9afe8a3531f45255ee97465b52d2769a9a8ab5.tar.gz gdb-5b9afe8a3531f45255ee97465b52d2769a9a8ab5.tar.bz2 |
gdb/
* cli/cli-decode.c (set_cmd_prefix): New.
(lookup_cmd_for_prefixlist): New.
(add_prefix_cmd): Call set_cmd_prefix and update field 'prefix'
of each cmd_list_element in *prefixlist.
(add_setshow_cmd_full): set_cmd_prefix.
(add_alias_cmd): Likewise.
* cli/cli-decode.h (struct cmd_list_element) <prefix>: New field.
Declare 'auto_boolean_enums'.
* cli/cli-setshow.c: Include "observer.h".
(notify_command_param_changed_p): New.
(add_setshow_auto_boolean_cmd): Move auto_boolean_enums out.
Remove 'static'.
(do_setshow_command): Split it to ...
(do_set_command, do_show_command): ... them. New.
(do_set_command): Call observer_notify_command_param_changed if
notify_command_param_changed_p returns true.
(cmd_show_list): Caller update.
* auto-load.c (set_auto_load_cmd): Likewise.
* remote.c (show_remote_cmd): Likewise.
* cli/cli-setshow.h: Update declarations.
* top.c (execute_command): Call do_set_command and do_show_command.
* NEWS: Mention new MI notification.
* mi/mi-interp.c: Declare mi_command_param_changed.
(mi_interpreter_init): Attach mi_command_param_changed to
observer command_param_changed.
(mi_command_param_changed): New.
Remove mi_suppress_breakpoint_notifications.
Define global variable mi_suppress_notification.
(mi_breakpoint_created): Update.
(mi_breakpoint_deleted): Likewise.
(mi_breakpoint_modified): Likewise.
* mi/mi-main.c (mi_cmd_execute): Likewise. Check command
'gdb-set' and set mi_suppress_notification.
* mi/mi-main.h: (mi_suppress_notification): New struct.
gdb/doc/
* observer.texi: New observer command_param_changed.
* gdb.texinfo (GDB/MI Async Records): Doc for '=cmd-param-changed'.
gdb/testsuite/
* gdb.mi/mi-cmd-param-changed.exp: New.
* gdb.mi/mi-cli.exp: Update for MI notification "=cmd-param-changed".
* gdb.mi/mi-var-rtti.exp, gdb.mi/mi2-cli.exp: Likewise.
* gdb.mi/mi2-prompt.exp: Likewise.
Diffstat (limited to 'gdb/cli/cli-decode.c')
-rw-r--r-- | gdb/cli/cli-decode.c | 67 |
1 files changed, 66 insertions, 1 deletions
diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c index c337b43..3c2e152 100644 --- a/gdb/cli/cli-decode.c +++ b/gdb/cli/cli-decode.c @@ -52,6 +52,53 @@ static struct cmd_list_element *find_cmd (char *command, static void help_all (struct ui_file *stream); +/* Look up a command whose 'prefixlist' is KEY. Return the command if found, + otherwise return NULL. */ + +static struct cmd_list_element * +lookup_cmd_for_prefixlist (struct cmd_list_element **key, + struct cmd_list_element *list) +{ + struct cmd_list_element *p = NULL; + + for (p = list; p != NULL; p = p->next) + { + struct cmd_list_element *q; + + if (p->prefixlist == NULL) + continue; + else if (p->prefixlist == key) + return p; + + q = lookup_cmd_for_prefixlist (key, *(p->prefixlist)); + if (q != NULL) + return q; + } + + return NULL; +} + +static void +set_cmd_prefix (struct cmd_list_element *c, struct cmd_list_element **list) +{ + struct cmd_list_element *p; + + /* Check to see if *LIST contains any element other than C. */ + for (p = *list; p != NULL; p = p->next) + if (p != c) + break; + + if (p == NULL) + { + /* *SET_LIST only contains SET. */ + p = lookup_cmd_for_prefixlist (list, setlist); + + c->prefix = p ? (p->cmd_pointer ? p->cmd_pointer : p) : p; + } + else + c->prefix = p->prefix; +} + static void print_help_for_command (struct cmd_list_element *c, char *prefix, int recurse, struct ui_file *stream); @@ -193,6 +240,7 @@ add_cmd (char *name, enum command_class class, void (*fun) (char *, int), c->prefixlist = NULL; c->prefixname = NULL; c->allow_unknown = 0; + c->prefix = NULL; c->abbrev_flag = 0; set_cmd_completer (c, make_symbol_completion_list_fn); c->destroyer = NULL; @@ -268,6 +316,8 @@ add_alias_cmd (char *name, char *oldname, enum command_class class, c->cmd_pointer = old; c->alias_chain = old->aliases; old->aliases = c; + + set_cmd_prefix (c, list); return c; } @@ -284,10 +334,21 @@ add_prefix_cmd (char *name, enum command_class class, struct cmd_list_element **list) { struct cmd_list_element *c = add_cmd (name, class, fun, doc, list); + struct cmd_list_element *p; c->prefixlist = prefixlist; c->prefixname = prefixname; c->allow_unknown = allow_unknown; + + if (list == &cmdlist) + c->prefix = NULL; + else + set_cmd_prefix (c, list); + + /* Update the field 'prefix' of each cmd_list_element in *PREFIXLIST. */ + for (p = *prefixlist; p != NULL; p = p->next) + p->prefix = c; + return c; } @@ -392,6 +453,9 @@ add_setshow_cmd_full (char *name, full_set_doc, set_list); if (set_func != NULL) set_cmd_sfunc (set, set_func); + + set_cmd_prefix (set, set_list); + show = add_set_or_show_cmd (name, show_cmd, class, var_type, var, full_show_doc, show_list); show->show_value_func = show_func; @@ -430,6 +494,8 @@ add_setshow_enum_cmd (char *name, c->enums = enumlist; } +const char * const auto_boolean_enums[] = { "on", "off", "auto", NULL }; + /* Add an auto-boolean command named NAME to both the set and show command list lists. CLASS is as in add_cmd. VAR is address of the variable which will contain the value. DOC is the documentation @@ -445,7 +511,6 @@ add_setshow_auto_boolean_cmd (char *name, struct cmd_list_element **set_list, struct cmd_list_element **show_list) { - static const char *auto_boolean_enums[] = { "on", "off", "auto", NULL }; struct cmd_list_element *c; add_setshow_cmd_full (name, class, var_auto_boolean, var, |