diff options
author | Philippe Waroquiers <philippe.waroquiers@skynet.be> | 2019-09-08 15:48:32 +0200 |
---|---|---|
committer | Philippe Waroquiers <philippe.waroquiers@skynet.be> | 2019-11-30 09:36:19 +0100 |
commit | c6ac7fc98718d7e472e1e1c12aae9855c79353a5 (patch) | |
tree | 0bf31537b160a0ecb05b60880735e15e8ec18b1b /gdb/top.c | |
parent | ce4331325cd8407c32407c03e3126fb1dc120304 (diff) | |
download | gdb-c6ac7fc98718d7e472e1e1c12aae9855c79353a5.zip gdb-c6ac7fc98718d7e472e1e1c12aae9855c79353a5.tar.gz gdb-c6ac7fc98718d7e472e1e1c12aae9855c79353a5.tar.bz2 |
Implement user defined prefix.
This patch adds the new 'define-prefix' command that creates (or mark an
existing user defined command) as a prefix command.
This approach was preferred compared to add a -prefix option to
'define' command : with define-prefix, a command can be defined and
afterwards marked as a prefix. Also, it is easier to define a
'prefix' only command in one operation.
This patch also adds completers for the 'define' and 'document' commands.
This makes it easier for the user to type the prefixes for 'define'
and type the documented command name for 'document'.
gdb/ChangeLog
2019-11-30 Philippe Waroquiers <philippe.waroquiers@skynet.be>
* cli/cli-script.c (do_define_command): Ensure a redefined
prefix command is kept as a prefix command.
(define_prefix_command): New function.
(show_user_1): Report user defined prefixes.
(_initialize_cli_script): Create the new 'define-prefix' command.
Add completers for 'define' and 'document'.
* top.c (execute_command): If command is a user-defined prefix only
command, report the list of commands for this prefix command.
Diffstat (limited to 'gdb/top.c')
-rw-r--r-- | gdb/top.c | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -627,6 +627,18 @@ execute_command (const char *p, int from_tty) /* c->user_commands would be NULL in the case of a python command. */ if (c->theclass == class_user && c->user_commands) execute_user_command (c, arg); + else if (c->theclass == class_user + && c->prefixlist && !c->allow_unknown) + /* If this is a user defined prefix that does not allow unknown + (in other words, C is a prefix command and not a command + that can be followed by its args), report the list of + subcommands. */ + { + printf_unfiltered + ("\"%.*s\" must be followed by the name of a subcommand.\n", + (int) strlen (c->prefixname) - 1, c->prefixname); + help_list (*c->prefixlist, c->prefixname, all_commands, gdb_stdout); + } else if (c->type == set_cmd) do_set_command (arg, from_tty, c); else if (c->type == show_cmd) |