5a56e9c5e9
* NEWS: Mention new command. * command.h (valid_user_defined_cmd_name_p): Declare. * defs.h (make_cleanup_dyn_string_delete): Declare. * utils.c: #include "dyn-string.h". (do_dyn_string_delete, make_cleanup_dyn_string_delete): New functions. * cli/cli-cmds.c: #include "dyn-string.h". (argv_to_dyn_string, valid_command_p, alias_command): New functions. (init_cli_cmds): Add new command. * cli/cli-decode.c (valid_user_defined_cmd_name_p): New function. doc/ * gdb.texinfo (Extending GDB): Document alias command. testsuite/ * gdb.base/alias.exp: Add tests for alias command.
68 lines
2.3 KiB
Text
68 lines
2.3 KiB
Text
# Test the alias command.
|
|
# Copyright 2011 Free Software Foundation, Inc.
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation; either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
gdb_exit
|
|
gdb_start
|
|
gdb_reinitialize_dir $srcdir/$subdir
|
|
|
|
# Helper to test the -a option to alias.
|
|
# Aliases that are abbreviations of commands (e.g. r -> run)
|
|
# do not appear in help output.
|
|
|
|
proc test_abbrev_not_present { alias_name } {
|
|
global gdb_prompt
|
|
set alias_present 0
|
|
set test_name "abbrev $alias_name not present in help command list"
|
|
gdb_test_multiple "help aliases" $test_name {
|
|
-re "\[\r\n\]$alias_name \[^\r\n\]*" {
|
|
set alias_present 1
|
|
exp_continue
|
|
}
|
|
-re ".*$gdb_prompt $" {
|
|
if { !$alias_present } then {
|
|
pass $test_name
|
|
} else {
|
|
fail $test_name
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
proc test_abbrev_alias { name gdb_command test_value } {
|
|
gdb_test_no_output $gdb_command
|
|
gdb_test_no_output "$name print elements $test_value"
|
|
gdb_test "show print elements" "Limit .* is $test_value\[.\]" "verify $name"
|
|
test_abbrev_not_present $name
|
|
}
|
|
|
|
test_abbrev_alias set2 "alias -a set2=set" 42
|
|
test_abbrev_alias set3 "alias -a set3= set" 43
|
|
test_abbrev_alias set4 "alias -a set4 =set" 44
|
|
test_abbrev_alias set5 "alias -a set5 = set" 45
|
|
test_abbrev_alias set6 "alias -a -- set6 = set" 46
|
|
test_abbrev_alias -a "alias -a -- -a = set" 47
|
|
|
|
gdb_test "alias set2=set" "already exists: set2"
|
|
gdb_test "alias foo=bar" "Invalid command to alias to: bar"
|
|
|
|
gdb_test_no_output "alias spe = set p elem"
|
|
gdb_test_no_output "spe 50"
|
|
gdb_test "show print elements" "Limit .* is 50\[.\]" "verify spe"
|
|
|
|
gdb_test_no_output "alias set pr elms = set p elem"
|
|
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 .*"
|