diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp index 7ea69a320cfa..bbd18b94c120 100644 --- a/lldb/source/Interpreter/CommandInterpreter.cpp +++ b/lldb/source/Interpreter/CommandInterpreter.cpp @@ -132,12 +132,18 @@ CommandInterpreter::Initialize () AddAlias ("exit", cmd_obj_sp); } - cmd_obj_sp = GetCommandSPExact ("process attach", false); + cmd_obj_sp = GetCommandSPExact ("_regexp-attach",false); if (cmd_obj_sp) { AddAlias ("attach", cmd_obj_sp); } + cmd_obj_sp = GetCommandSPExact ("process detach",false); + if (cmd_obj_sp) + { + AddAlias ("detach", cmd_obj_sp); + } + cmd_obj_sp = GetCommandSPExact ("process continue", false); if (cmd_obj_sp) { @@ -380,6 +386,21 @@ CommandInterpreter::LoadCommandDictionary () } } + std::auto_ptr + attach_regex_cmd_ap(new CommandObjectRegexCommand (*this, + "_regexp-attach", + "Attach to a process id if in decimal, otherwise treat the argument as a process name to attach to.", + "_regexp-attach []\n_regexp-attach []", 2)); + if (attach_regex_cmd_ap.get()) + { + if (attach_regex_cmd_ap->AddRegexCommand("^([0-9]+)$", "process attach --pid %1") && + attach_regex_cmd_ap->AddRegexCommand("^(.*[^[:space:]])[[:space:]]*$", "process attach --name '%1'")) + { + CommandObjectSP attach_regex_cmd_sp(attach_regex_cmd_ap.release()); + m_command_dict[attach_regex_cmd_sp->GetCommandName ()] = attach_regex_cmd_sp; + } + } + std::auto_ptr down_regex_cmd_ap(new CommandObjectRegexCommand (*this, "_regexp-down", diff --git a/lldb/test/functionalities/completion/TestCompletion.py b/lldb/test/functionalities/completion/TestCompletion.py index f5c171be52c5..8967a2204da5 100644 --- a/lldb/test/functionalities/completion/TestCompletion.py +++ b/lldb/test/functionalities/completion/TestCompletion.py @@ -18,6 +18,14 @@ class CommandLineCompletionTestCase(TestBase): os.remove("child_send.txt") os.remove("child_read.txt") + def test_at(self): + """Test that 'at' completes to 'attach '.""" + self.complete_from_to('at', 'attach ') + + def test_de(self): + """Test that 'de' completes to 'detach '.""" + self.complete_from_to('de', 'detach ') + def test_process_attach_dash_dash_con(self): """Test that 'process attach --con' completes to 'process attach --continue '.""" self.complete_from_to('process attach --con', 'process attach --continue ')