[PATCH 06/40] Expression completer should not match explicit location options

Pedro Alves palves@redhat.com
Fri Jun 2 12:22:00 GMT 2017


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



More information about the Gdb-patches mailing list