diff options
author | Jerome Guitton <guitton@adacore.com> | 2017-01-10 15:15:53 +0100 |
---|---|---|
committer | Jerome Guitton <guitton@adacore.com> | 2017-02-08 19:03:25 +0100 |
commit | 604c4576fdcfc4e7c28f569b3748a1b6b4e0dbd4 (patch) | |
tree | 49f6059faa172e3ff89401319709a6f7ef2cff95 /gdb/testsuite | |
parent | 3d7b173c29900879c9a5958dd6029fd36666e57c (diff) | |
download | gdb-604c4576fdcfc4e7c28f569b3748a1b6b4e0dbd4.zip gdb-604c4576fdcfc4e7c28f569b3748a1b6b4e0dbd4.tar.gz gdb-604c4576fdcfc4e7c28f569b3748a1b6b4e0dbd4.tar.bz2 |
Command abbreviation in define
When defining a new macro, "command" is not recognized as an alias for
"commands":
(gdb) define breakmain
Type commands for definition of "breakmain".
End with a line saying just "end".
>break main
>command
>echo "IN MAIN\n"
>end
(gdb)
There is a special case for while-stepping, where 'ws' and 'stepping' are
recognized explicitely. Instead of adding more special cases, this change
uses cli-decode.
gdb/ChangeLog:
* cli/cli-decode.c (find_command_name_length): Make it extern.
* cli/cli-decode.h (find_command_name_length): Declare.
* cli/cli-script.c (command_name_equals, line_first_arg):
New functions.
(process_next_line): Use cli-decode to parse command names.
(build_command_line): Make args a constant pointer.
gdb/testsuite/ChangeLog:
* gdb.base/define.exp: Add test for command abbreviations
in define.
Diffstat (limited to 'gdb/testsuite')
-rw-r--r-- | gdb/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/define.exp | 32 |
2 files changed, 37 insertions, 0 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index f5a0a8e..39f6776 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-02-08 Jerome Guitton <guitton@adacore.com> + + * gdb.base/define.exp: Add test for command abbreviations + in define. + 2017-02-06 Luis Machado <lgustavo@codesourcery.com> * gdb.reverse/insn-reverse.c: Include insn-reverse-x86.c. diff --git a/gdb/testsuite/gdb.base/define.exp b/gdb/testsuite/gdb.base/define.exp index 59203ec..711ed25 100644 --- a/gdb/testsuite/gdb.base/define.exp +++ b/gdb/testsuite/gdb.base/define.exp @@ -147,6 +147,38 @@ gdb_test_multiple "define ifnospace" "define user command: ifnospace" \ gdb_test "ifnospace" ".*hi there.*" "test ifnospace is parsed correctly" +# Verify that the command parser properly handles command abbreviations. +with_test_prefix "command abbreviations in define" { + set test "define user command: breakmain" + gdb_test_multiple "define breakmain" "$test" { + -re "Type commands for definition of \"breakmain\".\r\nEnd with a line saying just \"end\".\r\n>$" { + pass "$test" + set test "send body of breakmain" + gdb_test_multiple "break main\ncommand\necho\nend\nend" "$test" { + -re "$gdb_prompt $"\ + {pass "$test"} + } + } + } + + gdb_test "breakmain" ".*Breakpoint .*" "run user command" + + # If GDB fails to interpret properly the abbrev "command", the last "end" + # will be missing. Issue it to avoid a desync that would break the other + # tests in this file. + gdb_test "end" \ + "This command cannot be used at the top level.*" \ + "additional end command" + + gdb_test "info break \$bpnum" \ + [multi_line \ + "Num Type\[ \]+Disp Enb Address\[ \]+What.*" \ + "\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*" \ + "\[\t \]+echo.*"] \ + "info break shows echo command" +} + + # Verify that the command parser doesn't require a space after an 'while' # command in a user defined function. # |