[Lldb-commits] [PATCH] D75418: tab completion for process signal

Raphael Isemann via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri Mar 6 17:07:13 PST 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rG2bba1c22e77a: tab completion for process signal (authored by teemperor).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75418

Files:
  lldb/source/Commands/CommandObjectProcess.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
@@ -85,6 +85,23 @@
                               ['mips',
                                'arm64'])
 
+    def test_process_signal(self):
+        # The tab completion for "process signal"  won't work without a running process.
+        self.complete_from_to('process signal ',
+                              'process signal ')
+
+        # Test with a running process.
+        self.build()
+        self.main_source = "main.cpp"
+        self.main_source_spec = lldb.SBFileSpec(self.main_source)
+        lldbutil.run_to_source_breakpoint(self, '// Break here', self.main_source_spec)
+
+        self.complete_from_to('process signal ',
+                              'process signal SIG')
+        self.complete_from_to('process signal SIGA',
+                              ['SIGABRT',
+                               'SIGALRM'])
+
     def test_ambiguous_long_opt(self):
         self.completions_match('breakpoint modify --th',
                                ['--thread-id',
Index: lldb/source/Commands/CommandObjectProcess.cpp
===================================================================
--- lldb/source/Commands/CommandObjectProcess.cpp
+++ lldb/source/Commands/CommandObjectProcess.cpp
@@ -1034,6 +1034,20 @@
 
   ~CommandObjectProcessSignal() override = default;
 
+  void
+  HandleArgumentCompletion(CompletionRequest &request,
+                           OptionElementVector &opt_element_vector) override {
+    if (!m_exe_ctx.HasProcessScope() || request.GetCursorIndex() != 0)
+      return;
+
+    UnixSignalsSP signals = m_exe_ctx.GetProcessPtr()->GetUnixSignals();
+    int signo = signals->GetFirstSignalNumber();
+    while (signo != LLDB_INVALID_SIGNAL_NUMBER) {
+      request.AddCompletion(signals->GetSignalAsCString(signo), "");
+      signo = signals->GetNextSignalNumber(signo);
+    }
+  }
+
 protected:
   bool DoExecute(Args &command, CommandReturnObject &result) override {
     Process *process = m_exe_ctx.GetProcessPtr();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D75418.248862.patch
Type: text/x-patch
Size: 2223 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20200307/fa628fa8/attachment.bin>


More information about the lldb-commits mailing list