aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/ChangeLog10
-rw-r--r--gdb/cli/cli-decode.c48
-rw-r--r--gdb/command.h52
-rw-r--r--gdb/completer.c5
-rw-r--r--gdb/testsuite/ChangeLog4
-rw-r--r--gdb/testsuite/gdb.base/completion.exp6
6 files changed, 74 insertions, 51 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 8445611..0c6ced3 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,13 @@
+2020-12-11 Andrew Burgess <andrew.burgess@embecosm.com>
+
+ * 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.
+
2020-12-11 Simon Marchi <simon.marchi@polymtl.ca>
* infrun.h (debug_infrun): Make a bool.
diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c
index 71924c3..c62b849 100644
--- a/gdb/cli/cli-decode.c
+++ b/gdb/cli/cli-decode.c
@@ -1613,50 +1613,12 @@ valid_user_defined_cmd_name_p (const char *name)
return true;
}
-/* 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). */
+/* See command.h. */
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)
+ int ignore_help_classes, bool lookup_for_completion_p)
{
char *command;
int len, nfound;
@@ -1715,7 +1677,7 @@ lookup_cmd_1 (const char **text, struct cmd_list_element *clist,
itself and we will adjust the appropriate DEPRECATED_WARN_USER
flags. */
- if (found->deprecated_warn_user)
+ if (found->deprecated_warn_user && !lookup_for_completion_p)
deprecated_cmd_warning (line);
/* Return the default_args of the alias, not the default_args
@@ -1729,8 +1691,8 @@ lookup_cmd_1 (const char **text, struct cmd_list_element *clist,
if (found->prefixlist)
{
- c = lookup_cmd_1 (text, *found->prefixlist, result_list,
- default_args, ignore_help_classes);
+ c = lookup_cmd_1 (text, *found->prefixlist, result_list, default_args,
+ ignore_help_classes, lookup_for_completion_p);
if (!c)
{
/* Didn't find anything; this is as far as we got. */
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 * );
diff --git a/gdb/completer.c b/gdb/completer.c
index 7f63ced..4c1ad25 100644
--- a/gdb/completer.c
+++ b/gdb/completer.c
@@ -1388,9 +1388,8 @@ complete_line_internal_1 (completion_tracker &tracker,
result_list = 0;
}
else
- {
- c = lookup_cmd_1 (&p, cmdlist, &result_list, NULL, ignore_help_classes);
- }
+ c = lookup_cmd_1 (&p, cmdlist, &result_list, NULL, ignore_help_classes,
+ true);
/* Move p up to the next interesting thing. */
while (*p == ' ' || *p == '\t')
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 7f68228..f2262f6 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2020-12-11 Andrew Burgess <andrew.burgess@embecosm.com>
+
+ * gdb.base/completion.exp: Add additional tests.
+
2020-12-11 Tom de Vries <tdevries@suse.de>
PR testsuite/26991
diff --git a/gdb/testsuite/gdb.base/completion.exp b/gdb/testsuite/gdb.base/completion.exp
index 1c5d03b..14d56a5 100644
--- a/gdb/testsuite/gdb.base/completion.exp
+++ b/gdb/testsuite/gdb.base/completion.exp
@@ -962,3 +962,9 @@ foreach_with_prefix cmd { "watch" "awatch" "rwatch" } {
}
}
}
+
+# Check that tab completion of a deprecated alias does not display the
+# warning about the alias being deprecated during tab completion.
+gdb_test_no_output "alias xxx_yyy_zzz=break"
+gdb_test_no_output "maint deprecate xxx_yyy_zzz"
+test_gdb_complete_unique "xxx_yyy_" "xxx_yyy_zzz"