aboutsummaryrefslogtreecommitdiff
path: root/gdb/command.h
diff options
context:
space:
mode:
authorAndrew Burgess <andrew.burgess@embecosm.com>2020-12-08 17:32:34 +0000
committerAndrew Burgess <andrew.burgess@embecosm.com>2020-12-11 22:10:50 +0000
commit1536146f30900b77c8381930669532f4073df196 (patch)
tree5d743ff450de62eb026bb9dbb99ffe4dc2abee14 /gdb/command.h
parent966484941738b7a474fb7e4fe29eb5693fc9096c (diff)
downloadgdb-1536146f30900b77c8381930669532f4073df196.zip
gdb-1536146f30900b77c8381930669532f4073df196.tar.gz
gdb-1536146f30900b77c8381930669532f4073df196.tar.bz2
gdb: don't warn about deprecated aliases during tab completion
Consider this gdb session, where on line #3 tab completion is used: (gdb) alias xxx_yyy_zzz=break (gdb) maint deprecate xxx_yyy_zzz (gdb) xxx_yyy_<TAB> The third line then updates to look like this: (gdb) xxx_yyy_Warning: 'xxx_yyy_zzz', an alias for the command 'break' is deprecated. No alternative known. zzz What's happened is during tab completion the alias has been resolved to the actual command being aliased, and at this stage the warning is issued. Clearly this is not what we want during tab completion. In this commit I add a new parameter to the lookup function, a boolean that indicates if the lookup is being done as part of completion. This flag is used to suppress the warning. Now we get the expected behaviour, the alias completes without any warning, but the warning is still given once the user executes the alias. gdb/ChangeLog: * cli/cli-decode.c (lookup_cmd_1): Move header comment into command.h, add extra parameter, and use this to guard giving a warning. * command.h (lookup_cmd_1): Add comment from cli/cli-decode.c, include argument names in declaration, add new argument. * completer.c (complete_line_internal_1): Remove unneeded brackets, pass extra argument to lookup_cmd_1. gdb/testsuite/ChangeLog: * gdb.base/completion.exp: Add additional tests.
Diffstat (limited to 'gdb/command.h')
-rw-r--r--gdb/command.h52
1 files changed, 47 insertions, 5 deletions
diff --git a/gdb/command.h b/gdb/command.h
index 22e43de..a6ddaa2 100644
--- a/gdb/command.h
+++ b/gdb/command.h
@@ -278,11 +278,53 @@ extern struct cmd_list_element *lookup_cmd (const char **,
std::string *,
int, int);
-extern struct cmd_list_element *lookup_cmd_1 (const char **,
- struct cmd_list_element *,
- struct cmd_list_element **,
- std::string *,
- int);
+/* This routine takes a line of TEXT and a CLIST in which to start the
+ lookup. When it returns it will have incremented the text pointer past
+ the section of text it matched, set *RESULT_LIST to point to the list in
+ which the last word was matched, and will return a pointer to the cmd
+ list element which the text matches. It will return NULL if no match at
+ all was possible. It will return -1 (cast appropriately, ick) if ambigous
+ matches are possible; in this case *RESULT_LIST will be set to point to
+ the list in which there are ambiguous choices (and *TEXT will be set to
+ the ambiguous text string).
+
+ if DEFAULT_ARGS is not null, *DEFAULT_ARGS is set to the found command
+ default args (possibly empty).
+
+ If the located command was an abbreviation, this routine returns the base
+ command of the abbreviation. Note that *DEFAULT_ARGS will contain the
+ default args defined for the alias.
+
+ It does no error reporting whatsoever; control will always return
+ to the superior routine.
+
+ In the case of an ambiguous return (-1), *RESULT_LIST will be set to point
+ at the prefix_command (ie. the best match) *or* (special case) will be NULL
+ if no prefix command was ever found. For example, in the case of "info a",
+ "info" matches without ambiguity, but "a" could be "args" or "address", so
+ *RESULT_LIST is set to the cmd_list_element for "info". So in this case
+ RESULT_LIST should not be interpreted as a pointer to the beginning of a
+ list; it simply points to a specific command. In the case of an ambiguous
+ return *TEXT is advanced past the last non-ambiguous prefix (e.g.
+ "info t" can be "info types" or "info target"; upon return *TEXT has been
+ advanced past "info ").
+
+ If RESULT_LIST is NULL, don't set *RESULT_LIST (but don't otherwise
+ affect the operation).
+
+ This routine does *not* modify the text pointed to by TEXT.
+
+ If IGNORE_HELP_CLASSES is nonzero, ignore any command list elements which
+ are actually help classes rather than commands (i.e. the function field of
+ the struct cmd_list_element is NULL).
+
+ When LOOKUP_FOR_COMPLETION_P is true the completion is being requested
+ for the completion engine, no warnings should be printed. */
+
+extern struct cmd_list_element *lookup_cmd_1
+ (const char **text, struct cmd_list_element *clist,
+ struct cmd_list_element **result_list, std::string *default_args,
+ int ignore_help_classes, bool lookup_for_completion_p = false);
extern struct cmd_list_element *deprecate_cmd (struct cmd_list_element *,
const char * );