Fix alias command not detecting non matching prefix & sometimes asserting.
alias_command does not detect that the prefixes of the alias command and the aliased command are not matching: it is comparing the alias prefix with itself, instead of comparing it with the aliased command prefix. This causes either the alias command to silently do nothing, or to have GDB asserting: (gdb) alias assigne imprime limite-elements = set print elements ../../binutils-gdb/gdb/cli/cli-cmds.c:1552: internal-error: void alias_command(const char*, int): Assertion `c_command != NULL && c_command != (struct cmd_list_element *) -1' failed. A problem internal to GDB has been detected, Fix the logic, and update gdb.base/alias.exp to test these cases. gdb/ChangeLog 2019-06-25 Philippe Waroquiers <philippe.waroquiers@skynet.be> * cli/cli-cmds.c (alias_command): Compare the alias prefix with the command prefix. gdb/testsuite/ChangeLog 2019-06-25 Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.base/alias.exp: Test non matching/non existing prefixes.
This commit is contained in:
parent
9b444f9533
commit
b65b566cdc
4 changed files with 64 additions and 4 deletions
|
@ -1518,8 +1518,8 @@ alias_command (const char *args, int from_tty)
|
|||
Example: alias spe = set print elements
|
||||
|
||||
Otherwise ALIAS and COMMAND must have the same number of words,
|
||||
and every word except the last must match; and the last word of
|
||||
ALIAS is made an alias of the last word of COMMAND.
|
||||
and every word except the last must identify the same prefix command;
|
||||
and the last word of ALIAS is made an alias of the last word of COMMAND.
|
||||
Example: alias set print elms = set pr elem
|
||||
Note that unambiguous abbreviations are allowed. */
|
||||
|
||||
|
@ -1538,10 +1538,11 @@ alias_command (const char *args, int from_tty)
|
|||
error (_("Mismatched command length between ALIAS and COMMAND."));
|
||||
|
||||
/* Create copies of ALIAS and COMMAND without the last word,
|
||||
and use that to verify the leading elements match. */
|
||||
and use that to verify the leading elements give the same
|
||||
prefix command. */
|
||||
std::string alias_prefix_string (argv_to_string (alias_argv,
|
||||
alias_argc - 1));
|
||||
std::string command_prefix_string (argv_to_string (alias_argv,
|
||||
std::string command_prefix_string (argv_to_string (command_argv.get (),
|
||||
command_argc - 1));
|
||||
alias_prefix = alias_prefix_string.c_str ();
|
||||
command_prefix = command_prefix_string.c_str ();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue