[Lldb-commits] [lldb] r162573 - in /lldb/trunk: source/Interpreter/CommandInterpreter.cpp test/functionalities/completion/TestCompletion.py

Johnny Chen johnny.chen at apple.com
Fri Aug 24 11:15:45 PDT 2012


Author: johnny
Date: Fri Aug 24 13:15:45 2012
New Revision: 162573

URL: http://llvm.org/viewvc/llvm-project?rev=162573&view=rev
Log:
rdar://problem/11811338

Add 'attach <pid>|<process-name>' command to lldb, as well as 'detach' which is an alias of 'process detach'.
Add two completion test cases for "attach" and "detach".

Modified:
    lldb/trunk/source/Interpreter/CommandInterpreter.cpp
    lldb/trunk/test/functionalities/completion/TestCompletion.py

Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandInterpreter.cpp?rev=162573&r1=162572&r2=162573&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/CommandInterpreter.cpp (original)
+++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp Fri Aug 24 13:15:45 2012
@@ -132,12 +132,18 @@
         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)
     {
@@ -381,6 +387,21 @@
     }
 
     std::auto_ptr<CommandObjectRegexCommand>
+    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 [<pid>]\n_regexp-attach [<process-name>]", 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<CommandObjectRegexCommand>
     down_regex_cmd_ap(new CommandObjectRegexCommand (*this,
                                                      "_regexp-down",
                                                      "Go down \"n\" frames in the stack (1 frame by default).",

Modified: lldb/trunk/test/functionalities/completion/TestCompletion.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/completion/TestCompletion.py?rev=162573&r1=162572&r2=162573&view=diff
==============================================================================
--- lldb/trunk/test/functionalities/completion/TestCompletion.py (original)
+++ lldb/trunk/test/functionalities/completion/TestCompletion.py Fri Aug 24 13:15:45 2012
@@ -18,6 +18,14 @@
         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 ')





More information about the lldb-commits mailing list