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. */
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 ();
gdb_test_no_output "set pr elms 51"
gdb_test "show print elements" "Limit .* is 51\[.\]" "verify set pr elms"
gdb_test "help set print" "set print elms .*"
+
+# Verify alias command detects a non existing prefix.
+gdb_test "alias assigne imprime limite-elements = set print elements" \
+ "ALIAS and COMMAND prefixes do not match\." \
+ "assigne imprime prefix not defined"
+
+gdb_test "alias set imprime limite-elements = set print elements" \
+ "ALIAS and COMMAND prefixes do not match\." \
+ "set imprime prefix not defined"
+
+# Verify alias command detects a non matching prefix.
+gdb_test "alias set ada limite-elements = set print elements" \
+ "ALIAS and COMMAND prefixes do not match\." \
+ "mismatched prefix"
+
+# Verify alias command detects a non matching prefix due to length.
+gdb_test "alias set imprime-limite-elements = set print elements" \
+ "Mismatched command length between ALIAS and COMMAND\." \
+ "mismatched length"
+
+
+# Gradually define the prefixes and the limite-elements command.
+gdb_test_no_output "alias assigne = set" "alias assigne"
+gdb_test_no_output "alias assigne imprime = set print" "alias assigne imprime"
+gdb_test_no_output "alias assigne imprime limite-elements = set print elements" \
+ "alias assigne imprime limite-elements"
+
+# Define an alias using the command prefix with a command using an alias prefix.
+gdb_test_no_output "alias set print max-elements = assigne imprime elements" \
+ "alias set print max-elements using assigne imprime"
+
+
+# Tests the resulting prefixes and commands.
+gdb_test_no_output "assigne print elements 52"
+gdb_test "show print elements" "Limit .* is 52\[.\]" "verify 52"
+
+gdb_test_no_output "assigne imprime elements 53"
+gdb_test "show print elements" "Limit .* is 53\[.\]" "verify 53"
+
+gdb_test_no_output "assigne imprime limite-elements 54"
+gdb_test "show print elements" "Limit .* is 54\[.\]" "verify 54"
+
+gdb_test_no_output "set imprime elements 55"
+gdb_test "show print elements" "Limit .* is 55\[.\]" "verify 55"
+
+gdb_test_no_output "set print limite-elements 56"
+gdb_test "show print elements" "Limit .* is 56\[.\]" "verify 56"
+
+gdb_test_no_output "set print max-elements 57"
+gdb_test "show print elements" "Limit .* is 57\[.\]" "verify 57"