Index: lldb/source/Commands/CommandObjectProcess.cpp =================================================================== --- lldb/source/Commands/CommandObjectProcess.cpp +++ lldb/source/Commands/CommandObjectProcess.cpp @@ -357,6 +357,26 @@ interpreter, CommandCompletions::eProcessPluginCompletion, request, nullptr); break; + + case 'p': + PlatformSP platform_sp(interpreter.GetPlatform(true)); + if (!platform_sp) + return; + ProcessInstanceInfoList process_infos; + ProcessInstanceInfoMatch match_info; + platform_sp->FindProcesses(match_info, process_infos); + const size_t num_matches = process_infos.size(); + if (num_matches == 0) + return; + for (size_t i = 0; i < num_matches; ++i) { + const llvm::StringRef process_name = + process_infos[i].GetNameAsStringRef(); + if (process_name.empty()) + continue; + request.TryCompleteCurrentArg( + std::to_string(process_infos[i].GetProcessID()), process_name); + } + break; } } Index: lldb/test/API/functionalities/completion/TestCompletion.py =================================================================== --- lldb/test/API/functionalities/completion/TestCompletion.py +++ lldb/test/API/functionalities/completion/TestCompletion.py @@ -5,6 +5,7 @@ import os +from multiprocessing import Process import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * @@ -92,6 +93,17 @@ self.complete_from_to('process ' + subcommand + ' mac', 'process ' + subcommand + ' mach-o-core') + def test_process_attach_dash_p(self): + def test(): + while True: + pass + + p = Process(target=test) + p.daemon = True + p.start() + self.complete_from_to('process attach -p ', [str(p.pid)]) + p.terminate() + def test_process_signal(self): # The tab completion for "process signal" won't work without a running process. self.complete_from_to('process signal ',