This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH 06/40] Expression completer should not match explicit location options
- From: Pedro Alves <palves at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Fri, 2 Jun 2017 13:22:04 +0100
- Subject: [PATCH 06/40] Expression completer should not match explicit location options
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=palves at redhat dot com
- Dkim-filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 9FBDA232058
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 9FBDA232058
- References: <1496406158-12663-1-git-send-email-palves@redhat.com>
Currently, the expression completer matches explicit location options,
which would only make sense for commands that work with linespecs, not
expressions.
I.e., currently, this:
"p -functi"
Completes to:
"p -function "
This patch fixes that, and adds regression tests.
gdb/ChangeLog:
yyyy-mm-dd Pedro Alves <palves@redhat.com>
* completer.c (expression_completer): Call
linespec_location_completer instead of location_completer.
gdb/testsuite/ChangeLog:
yyyy-mm-dd Pedro Alves <palves@redhat.com>
* gdb.base/printcmds.exp: Add tests.
---
gdb/completer.c | 2 +-
gdb/testsuite/gdb.base/printcmds.exp | 6 ++++++
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/gdb/completer.c b/gdb/completer.c
index 6acf115..ee587fb 100644
--- a/gdb/completer.c
+++ b/gdb/completer.c
@@ -643,7 +643,7 @@ expression_completer (struct cmd_list_element *ignore,
;
/* Not ideal but it is what we used to do before... */
- return location_completer (ignore, p, word);
+ return linespec_location_completer (ignore, text, word);
}
/* See definition in completer.h. */
diff --git a/gdb/testsuite/gdb.base/printcmds.exp b/gdb/testsuite/gdb.base/printcmds.exp
index d949b30..323ca73 100644
--- a/gdb/testsuite/gdb.base/printcmds.exp
+++ b/gdb/testsuite/gdb.base/printcmds.exp
@@ -931,6 +931,12 @@ gdb_test "ptype \"abc\"" " = char \\\[4\\\]"
gdb_test "print \$cvar = \"abc\"" " = \"abc\""
gdb_test "print sizeof (\$cvar)" " = 4"
+# GDB used to complete the explicit location options even when
+# printing expressions.
+gdb_test_no_output "complete p -function"
+gdb_test_no_output "complete p -line"
+gdb_test_no_output "complete p -source"
+
gdb_file_cmd ${binfile}
gdb_test "print \$pc" "No registers\\." "print \$pc (with file)"
--
2.5.5