Author: Gongyu Deng
Date: 2020-06-30T13:13:38+02:00
New Revision: 80eb42281feb7834054be5f933f63d8c64af229d

URL: 
https://github.com/llvm/llvm-project/commit/80eb42281feb7834054be5f933f63d8c64af229d
DIFF: 
https://github.com/llvm/llvm-project/commit/80eb42281feb7834054be5f933f63d8c64af229d.diff

LOG: [lldb] Tab completion for `frame select`

Summary: Provided the tab completion for command `frame select`.

Reviewers: teemperor, JDevlieghere

Reviewed By: teemperor

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D81177

Added: 
    

Modified: 
    lldb/source/Commands/CommandObjectFrame.cpp
    lldb/test/API/functionalities/completion/TestCompletion.py

Removed: 
    


################################################################################
diff  --git a/lldb/source/Commands/CommandObjectFrame.cpp 
b/lldb/source/Commands/CommandObjectFrame.cpp
index 5a61fc40e2e7..9ad4e3238359 100644
--- a/lldb/source/Commands/CommandObjectFrame.cpp
+++ b/lldb/source/Commands/CommandObjectFrame.cpp
@@ -289,6 +289,22 @@ class CommandObjectFrameSelect : public 
CommandObjectParsed {
 
   ~CommandObjectFrameSelect() override = default;
 
+  void
+  HandleArgumentCompletion(CompletionRequest &request,
+                           OptionElementVector &opt_element_vector) override {
+    if (!m_exe_ctx.HasProcessScope() || request.GetCursorIndex() != 0)
+      return;
+
+    lldb::ThreadSP thread_sp = m_exe_ctx.GetThreadSP();
+    const uint32_t frame_num = thread_sp->GetStackFrameCount();
+    for (uint32_t i = 0; i < frame_num; ++i) {
+      lldb::StackFrameSP frame_sp = thread_sp->GetStackFrameAtIndex(i);
+      StreamString strm;
+      frame_sp->Dump(&strm, false, true);
+      request.TryCompleteCurrentArg(std::to_string(i), strm.GetString());
+    }
+  }
+
   Options *GetOptions() override { return &m_options; }
 
 protected:

diff  --git a/lldb/test/API/functionalities/completion/TestCompletion.py 
b/lldb/test/API/functionalities/completion/TestCompletion.py
index 4a548ad77083..b9ddba30a5e4 100644
--- a/lldb/test/API/functionalities/completion/TestCompletion.py
+++ b/lldb/test/API/functionalities/completion/TestCompletion.py
@@ -415,6 +415,13 @@ def test_completion_description_command_options(self):
         self.check_completion_with_desc("breakpoint set --Z", [
         ])
 
+    def test_frame_select(self):
+        self.build()
+        self.main_source_spec = lldb.SBFileSpec("main.cpp")
+        lldbutil.run_to_source_breakpoint(self, '// Break here', 
self.main_source_spec)
+
+        self.complete_from_to('frame select ', ['0'])
+
     @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24489")
     def test_symbol_name(self):
         self.build()


        
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to