[Lldb-commits] [lldb] 2bba1c2 - tab completion for process signal

Raphael Isemann via lldb-commits lldb-commits at lists.llvm.org
Fri Mar 6 17:05:41 PST 2020


Author: Raphael Isemann
Date: 2020-03-06T17:05:25-08:00
New Revision: 2bba1c22e77a67bc6c245fbd4fa74160d33be564

URL: https://github.com/llvm/llvm-project/commit/2bba1c22e77a67bc6c245fbd4fa74160d33be564
DIFF: https://github.com/llvm/llvm-project/commit/2bba1c22e77a67bc6c245fbd4fa74160d33be564.diff

LOG: tab completion for process signal

Summary: Provide a list of Unix signals for the tap completion for command "process signal".

Reviewers: teemperor

Subscribers: labath, jingham, JDevlieghere, lldb-commits

Tags: #lldb

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

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/lldb/source/Commands/CommandObjectProcess.cpp b/lldb/source/Commands/CommandObjectProcess.cpp
index 504aec406d1f..20bbf95dca82 100644
--- a/lldb/source/Commands/CommandObjectProcess.cpp
+++ b/lldb/source/Commands/CommandObjectProcess.cpp
@@ -1034,6 +1034,20 @@ class CommandObjectProcessSignal : public CommandObjectParsed {
 
   ~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();

diff  --git a/lldb/test/API/functionalities/completion/TestCompletion.py b/lldb/test/API/functionalities/completion/TestCompletion.py
index 1156650c78f8..c2d3b919f1de 100644
--- a/lldb/test/API/functionalities/completion/TestCompletion.py
+++ b/lldb/test/API/functionalities/completion/TestCompletion.py
@@ -85,6 +85,23 @@ def test_process_launch_arch(self):
                               ['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',


        


More information about the lldb-commits mailing list