[Lldb-commits] [PATCH] D81177: [lldb] Tab completion for `frame select`

Raphael Isemann via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue Jun 30 04:19:06 PDT 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rG80eb42281feb: [lldb] Tab completion for `frame select` (authored by MrHate, committed by teemperor).
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81177/new/

https://reviews.llvm.org/D81177

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


Index: lldb/test/API/functionalities/completion/TestCompletion.py
===================================================================
--- lldb/test/API/functionalities/completion/TestCompletion.py
+++ lldb/test/API/functionalities/completion/TestCompletion.py
@@ -415,6 +415,13 @@
         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()
Index: lldb/source/Commands/CommandObjectFrame.cpp
===================================================================
--- lldb/source/Commands/CommandObjectFrame.cpp
+++ lldb/source/Commands/CommandObjectFrame.cpp
@@ -289,6 +289,22 @@
 
   ~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:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81177.274414.patch
Type: text/x-patch
Size: 1751 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20200630/a220b50c/attachment.bin>


More information about the lldb-commits mailing list