[Lldb-commits] [PATCH] D50802: Expression autocompletion with variables and symbols

Arnaud Coomans via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed Aug 15 13:20:52 PDT 2018


acoomans created this revision.
acoomans added a reviewer: lldb-commits.

This adds autocompletion for the `expression` (and thus `print` and `p`) commands. Variables and symbols are suggested.

For example: let's assume we have a struct called //my_struct//. We break, then run:

  (lldb) p my_ [TAB]

will autocomplete to:

  (lldb) p my_struct

Now let's assume we run:

  (lldb) p m [TAB]

we'll get suggestions from all corresponding symbols like this:

  Available completions:
  	mach_absolute_time
  	mach_approximate_time
  	mach_boottime_usec
  	mach_continuous_approximate_time
  	mach_continuous_time
  	mach_error
  [...]
  More (Y/n/a):


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D50802

Files:
  source/Commands/CommandObjectExpression.cpp
  source/Commands/CommandObjectExpression.h


Index: source/Commands/CommandObjectExpression.h
===================================================================
--- source/Commands/CommandObjectExpression.h
+++ source/Commands/CommandObjectExpression.h
@@ -62,6 +62,8 @@
 
   Options *GetOptions() override;
 
+  int HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector) override;
+
 protected:
   //------------------------------------------------------------------
   // IOHandler::Delegate functions
@@ -80,6 +82,8 @@
 
   void GetMultilineExpression();
 
+    bool WantsRawCommandString() override { return false; }
+
   OptionGroupOptions m_option_group;
   OptionGroupFormat m_format_options;
   OptionGroupValueObjectDisplay m_varobj_options;
Index: source/Commands/CommandObjectExpression.cpp
===================================================================
--- source/Commands/CommandObjectExpression.cpp
+++ source/Commands/CommandObjectExpression.cpp
@@ -307,6 +307,16 @@
 
 Options *CommandObjectExpression::GetOptions() { return &m_option_group; }
 
+int CommandObjectExpression::HandleArgumentCompletion(CompletionRequest &request,
+                                                      OptionElementVector &opt_element_vector)   {
+  CommandCompletions::InvokeCommonCompletionCallbacks(
+          GetCommandInterpreter(),
+          CommandCompletions::eVariablePathCompletion | CommandCompletions::eSymbolCompletion,
+          request,
+          nullptr);
+  return request.GetNumberOfMatches();
+}
+
 static lldb_private::Status
 CanBeUsedForElementCountPrinting(ValueObject &valobj) {
   CompilerType type(valobj.GetCompilerType());


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50802.160906.patch
Type: text/x-patch
Size: 1653 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20180815/994c1566/attachment.bin>


More information about the lldb-commits mailing list