Expression completer should not match explicit location options
This commit fixes a mismatch between what "print" command completer
thinks the command understands, and what the command actually
understands.
The explicit location options are understood by commands that take
(linespecs and) explicit locations as argument. I.e, breakpoint
commands, and "list". For example:
(gdb) b -source file.c -function my_func
So for those commands, it makes sense that the completer
completes:
"b -sour[TAB]" -> "b -source "
"b -functi[TAB]" -> "b -function "
etc.
However, completion for commands that take expressions (not
linespecs/locations) as arguments, such as the "print" command, also
completes the explicit location options, even though those switches
aren't really understood by these commands. Instead, "-foo" is
understood as an expression applying unary minus on a symbol named
"foo" (think "print -1"):
(gdb) p -func[TAB]
(gdb) p -function [RET]
No symbol "function" in current context.
The patch fixes this by having the expression_completer function
bypass the function that completes explicit locations.
New regression tests included.
gdb/ChangeLog:
2017-06-29 Pedro Alves <palves@redhat.com>
* completer.c (expression_completer): Call
linespec_location_completer instead of location_completer.
gdb/testsuite/ChangeLog:
2017-06-29 Pedro Alves <palves@redhat.com>
* gdb.base/printcmds.exp: Add tests.