mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-03 21:34:46 +08:00
Fix problem that alias can be defined or not depending on the order.
When an alias name starts with the name of another alias, GDB was accepting to define the aliases in one order (short first, long after), but refused it the other way around. So, fix the logic to recognise an already existing alias by using lookup_cmd_composition. Also, this revealed a bug in lookup_cmd_composition: when the searched command is a prefix command, lookup_cmd_composition was not returning the fact that a command was found even if the TEXT to parse was fully consumed. gdb/ChangeLog YYYY-MM-DD Philippe Waroquiers <philippe.waroquiers@skynet.be> * cli/cli-cmds.c (alias_command): Check for an existing alias using lookup_cmd_composition, as valid_command_p is too strict and forbids aliases that are the prefix of an existing alias or command. * cli/cli-decode.c (lookup_cmd_composition): Ensure a prefix command is properly recognised as a valid command. gdb/testsuite/ChangeLog 2020-05-15 Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.base/alias.exp: Test aliases starting with a prefix of another alias.
This commit is contained in:
@ -1694,8 +1694,29 @@ alias_command (const char *args, int from_tty)
|
||||
/* ALIAS must not exist. */
|
||||
std::string alias_string (argv_to_string (alias_argv, alias_argc));
|
||||
alias = alias_string.c_str ();
|
||||
if (valid_command_p (alias))
|
||||
error (_("Alias already exists: %s"), alias);
|
||||
{
|
||||
cmd_list_element *alias_cmd, *prefix_cmd, *cmd;
|
||||
|
||||
if (lookup_cmd_composition (alias, &alias_cmd, &prefix_cmd, &cmd))
|
||||
{
|
||||
const char *alias_name = alias_argv[alias_argc-1];
|
||||
|
||||
/* If we found an existing ALIAS_CMD, check that the prefix differ or
|
||||
the name differ. */
|
||||
|
||||
if (alias_cmd != nullptr
|
||||
&& alias_cmd->prefix == prefix_cmd
|
||||
&& strcmp (alias_name, alias_cmd->name) == 0)
|
||||
error (_("Alias already exists: %s"), alias);
|
||||
|
||||
/* Check ALIAS differs from the found CMD. */
|
||||
|
||||
if (cmd->prefix == prefix_cmd
|
||||
&& strcmp (alias_name, cmd->name) == 0)
|
||||
error (_("Alias %s is the name of an existing command"), alias);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* If ALIAS is one word, it is an alias for the entire COMMAND.
|
||||
Example: alias spe = set print elements
|
||||
|
Reference in New Issue
Block a user