+2020-12-11 Andrew Burgess <andrew.burgess@embecosm.com>
+
+ PR cli/15104
+ * cli/cli-decode.c (lookup_cmd_1): Pass command list to
+ deprecated_cmd_warning.
+ (deprecated_cmd_warning): Take extra parameter, call
+ lookup_cmd_composition_1 and pass new parameter through.
+ (lookup_cmd_composition_1): New function, takes implementation of
+ lookup_cmd_composition but with extra parameter.
+ (lookup_cmd_composition): Now calls lookup_cmd_composition_1
+ passing in cmdlist.
+ * command.h (deprecated_cmd_warning): Add extra parameter to
+ declaration.
+ * top.c (execute_command): Pass cmdlist to deprecated_cmd_warning.
+
2020-12-11 Andrew Burgess <andrew.burgess@embecosm.com>
* cli/cli-decode.c (lookup_cmd_1): Move header comment into
static void help_all (struct ui_file *stream);
+static int lookup_cmd_composition_1 (const char *text,
+ struct cmd_list_element **alias,
+ struct cmd_list_element **prefix_cmd,
+ struct cmd_list_element **cmd,
+ struct cmd_list_element *cur_list);
+
/* Look up a command whose 'prefixlist' is KEY. Return the command if found,
otherwise return NULL. */
flags. */
if (found->deprecated_warn_user && !lookup_for_completion_p)
- deprecated_cmd_warning (line);
+ deprecated_cmd_warning (line, clist);
/* Return the default_args of the alias, not the default_args
of the command it is pointing to. */
*/
void
-deprecated_cmd_warning (const char *text)
+deprecated_cmd_warning (const char *text, struct cmd_list_element *list)
{
struct cmd_list_element *alias = NULL;
struct cmd_list_element *prefix_cmd = NULL;
struct cmd_list_element *cmd = NULL;
- if (!lookup_cmd_composition (text, &alias, &prefix_cmd, &cmd))
+ if (!lookup_cmd_composition_1 (text, &alias, &prefix_cmd, &cmd, list))
/* Return if text doesn't evaluate to a command. */
return;
cmd->deprecated_warn_user = 0;
}
-
-/* Look up the contents of TEXT as a command in the command list 'cmdlist'.
+/* Look up the contents of TEXT as a command in the command list CUR_LIST.
Return 1 on success, 0 on failure.
If TEXT refers to an alias, *ALIAS will point to that alias.
exist, they are NULL when we return.
*/
-int
-lookup_cmd_composition (const char *text,
- struct cmd_list_element **alias,
- struct cmd_list_element **prefix_cmd,
- struct cmd_list_element **cmd)
+
+static int
+lookup_cmd_composition_1 (const char *text,
+ struct cmd_list_element **alias,
+ struct cmd_list_element **prefix_cmd,
+ struct cmd_list_element **cmd,
+ struct cmd_list_element *cur_list)
{
char *command;
int len, nfound;
- struct cmd_list_element *cur_list;
struct cmd_list_element *prev_cmd;
*alias = NULL;
*prefix_cmd = NULL;
*cmd = NULL;
- cur_list = cmdlist;
-
text = skip_spaces (text);
while (1)
}
}
+/* Look up the contents of TEXT as a command in the command list 'cmdlist'.
+ Return 1 on success, 0 on failure.
+
+ If TEXT refers to an alias, *ALIAS will point to that alias.
+
+ If TEXT is a subcommand (i.e. one that is preceded by a prefix
+ command) set *PREFIX_CMD.
+
+ Set *CMD to point to the command TEXT indicates.
+
+ If any of *ALIAS, *PREFIX_CMD, or *CMD cannot be determined or do not
+ exist, they are NULL when we return.
+
+*/
+
+int
+lookup_cmd_composition (const char *text,
+ struct cmd_list_element **alias,
+ struct cmd_list_element **prefix_cmd,
+ struct cmd_list_element **cmd)
+{
+ return lookup_cmd_composition_1 (text, alias, prefix_cmd, cmd, cmdlist);
+}
+
/* Helper function for SYMBOL_COMPLETION_FUNCTION. */
/* Return a vector of char pointers which point to the different
gdb_test "maintenance deprecate" \
"\"maintenance deprecate\".*" \
"deprecate with no arguments"
+
+ # Test that an alias with a prefix still gives a warning.
+ set file1 [standard_output_file xxx_yyy_cmd]
+ set fd [open "$file1" w]
+ puts $fd \
+"define set xxx_yyy
+echo in command xxx_yyy\\n
+end
+
+alias set qqq_aaa=set xxx_yyy
+maintenance deprecate set qqq_aaa"
+ close $fd
+ gdb_test_no_output "source $file1" \
+ "source file containing xxx_yyy command and its alias"
+ gdb_test "set qqq_aaa" \
+ "Warning: 'qqq_aaa', an alias for the command 'xxx_yyy' is deprecated\\.\r\n.*No alternative known\\..*" \
+ "deprecated alias with prefix give a warning"
+
+ file delete $file1
}
proc_with_prefix bp_deleted_in_command_test {} {