PR cli/21688: Detect aliases when issuing python/compile/guile commands (and fix last commit)
My last commit fixed a regression that happened when using inline/multi-line commands for Python/Compile/Guile, but introduced another regression: it is now not possible to use aliases for the commands mentioned above. The fix is to almost revert the change I've made and go back to using the 'struct cmd_list_element *', but at the same time make sure that we advance the 'cmd_name' variable past all the whitespace characters after the command name. If, after skipping the whitespace, we encounter a '\0', it means that the command is not inline. Otherwise, it is. This patch also expands the testcase in order to check for aliases and for trailing whitespace after the command name. gdb/ChangeLog: 2017-06-30 Sergio Durigan Junior <sergiodj@redhat.com> Pedro Alves <palves@redhat.com> PR cli/21688 * cli/cli-script.c (command_name_equals_not_inline): Remove function. (process_next_line): New variable 'inline_cmd'. Adjust 'if' clauses for "python", "compile" and "guile" to use 'command_name_equals' and check for '!inline_cmd'. gdb/testsuite/ChangeLog: 2017-06-30 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/21688 * gdb.python/py-cmd.exp (test_python_inline_or_multiline): Add new tests for alias commands and trailing whitespace.
This commit is contained in:
parent
51ed89aa0d
commit
dc4bde35d1
4 changed files with 54 additions and 18 deletions
|
@ -187,6 +187,8 @@ gdb_test "complete expr_test bar\." \
|
|||
# This proc tests PR cli/21688. The PR is not language-specific, but
|
||||
# the easiest way is just to test with Python.
|
||||
proc test_python_inline_or_multiline { } {
|
||||
global gdb_prompt
|
||||
|
||||
set define_cmd_not_inline {
|
||||
{ "if 1" " >$" "multi-line if 1" }
|
||||
{ "python" " >$" "multi-line python command" }
|
||||
|
@ -194,12 +196,43 @@ proc test_python_inline_or_multiline { } {
|
|||
{ "end" " >$" "multi-line first end" }
|
||||
{ "end" "hello\r\n" "multi-line last end" } }
|
||||
|
||||
# This also tests trailing whitespace on the command.
|
||||
set define_cmd_alias_not_inline {
|
||||
{ "if 1" " >$" "multi-line if 1 alias" }
|
||||
{ "py " " >$" "multi-line python command alias" }
|
||||
{ "print ('hello')" " >$" "multi-line print alias" }
|
||||
{ "end" " >$" "multi-line first end alias" }
|
||||
{ "end" "hello\r\n" "multi-line last end alias" } }
|
||||
|
||||
set define_cmd_alias_foo_not_inline {
|
||||
{ "alias foo=python" "\r\n" "multi-line alias foo" }
|
||||
{ "if 1" " >$" "multi-line if 1 alias foo" }
|
||||
{ "foo " " >$" "multi-line python command alias foo" }
|
||||
{ "print ('hello')" " >$" "multi-line print alias foo" }
|
||||
{ "end" " >$" "multi-line first end alias foo" }
|
||||
{ "end" "hello\r\n" "multi-line last end alias foo" } }
|
||||
|
||||
set define_cmd_inline {
|
||||
{ "if 1" " >$" "inline if 1" }
|
||||
{ "python print ('hello')" " >$" "inline python command" }
|
||||
{ "end" "hello\r\n" "inline end" } }
|
||||
|
||||
foreach t [list $define_cmd_not_inline $define_cmd_inline] {
|
||||
set define_cmd_alias_inline {
|
||||
{ "if 1" " >$" "inline if 1 alias" }
|
||||
{ "py print ('hello')" " >$" "inline python command alias" }
|
||||
{ "end" "hello\r\n" "inline end alias" } }
|
||||
|
||||
set define_cmd_alias_foo_inline {
|
||||
{ "if 1" " >$" "inline if 1 alias foo" }
|
||||
{ "foo print ('hello')" " >$" "inline python command alias foo" }
|
||||
{ "end" "hello\r\n" "inline end alias foo" } }
|
||||
|
||||
foreach t [list $define_cmd_not_inline \
|
||||
$define_cmd_alias_not_inline \
|
||||
$define_cmd_alias_foo_not_inline \
|
||||
$define_cmd_inline \
|
||||
$define_cmd_alias_inline \
|
||||
$define_cmd_alias_foo_inline] {
|
||||
foreach l $t {
|
||||
lassign $l command regex testmsg
|
||||
gdb_test_multiple "$command" "$testmsg" {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue