diff --git a/lldb/source/Commands/CommandObjectProcess.cpp b/lldb/source/Commands/CommandObjectProcess.cpp --- a/lldb/source/Commands/CommandObjectProcess.cpp +++ b/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(); diff --git a/lldb/test/API/functionalities/completion/TestCompletion.py b/lldb/test/API/functionalities/completion/TestCompletion.py --- a/lldb/test/API/functionalities/completion/TestCompletion.py +++ b/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',