[Lldb-commits] [lldb] r157361 - in /lldb/trunk: include/lldb/Target/Process.h source/Commands/CommandObjectProcess.cpp test/functionalities/completion/TestCompletion.py

Johnny Chen johnny.chen at apple.com
Wed May 23 17:43:00 PDT 2012


Author: johnny
Date: Wed May 23 19:43:00 2012
New Revision: 157361

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

Supports the use-case scenario of immediately continuing the process once attached.
Add a simple completion test case from "process attach --con" to "process attach --continue ".

Modified:
    lldb/trunk/include/lldb/Target/Process.h
    lldb/trunk/source/Commands/CommandObjectProcess.cpp
    lldb/trunk/test/functionalities/completion/TestCompletion.py

Modified: lldb/trunk/include/lldb/Target/Process.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=157361&r1=157360&r2=157361&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Process.h (original)
+++ lldb/trunk/include/lldb/Target/Process.h Wed May 23 19:43:00 2012
@@ -794,7 +794,8 @@
         ProcessInstanceInfo(),
         m_plugin_name (),
         m_resume_count (0),
-        m_wait_for_launch (false)
+        m_wait_for_launch (false),
+        m_continue_once_attached (false)
     {
     }
 
@@ -802,7 +803,8 @@
         ProcessInstanceInfo(),
         m_plugin_name (),
         m_resume_count (0),
-        m_wait_for_launch (false)
+        m_wait_for_launch (false),
+        m_continue_once_attached (false)
     {
         ProcessInfo::operator= (launch_info);
         SetProcessPluginName (launch_info.GetProcessPluginName());
@@ -821,6 +823,18 @@
         m_wait_for_launch = b;
     }
 
+    bool
+    GetContinueOnceAttached () const
+    {
+        return m_continue_once_attached;
+    }
+    
+    void
+    SetContinueOnceAttached (bool b)
+    {
+        m_continue_once_attached = b;
+    }
+
     uint32_t
     GetResumeCount () const
     {
@@ -874,6 +888,7 @@
     std::string m_plugin_name;
     uint32_t m_resume_count; // How many times do we resume after launching
     bool m_wait_for_launch;
+    bool m_continue_once_attached; // Supports the use-case scenario of immediately continuing the process once attached.
 };
 
 class ProcessLaunchCommandOptions : public Options

Modified: lldb/trunk/source/Commands/CommandObjectProcess.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectProcess.cpp?rev=157361&r1=157360&r2=157361&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectProcess.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectProcess.cpp Wed May 23 19:43:00 2012
@@ -320,6 +320,10 @@
             bool success = false;
             switch (short_option)
             {
+                case 'c':
+                    attach_info.SetContinueOnceAttached(true);
+                    break;
+
                 case 'p':   
                     {
                         lldb::pid_t pid = Args::StringToUInt32 (option_arg, LLDB_INVALID_PROCESS_ID, 0, &success);
@@ -591,6 +595,10 @@
                 result.AppendWarningWithFormat("Architecture changed from %s to %s.\n", 
                                                 old_arch_spec.GetArchitectureName(), target->GetArchitecture().GetArchitectureName());
             }
+
+            // This supports the use-case scenario of immediately continuing the process once attached.
+            if (m_options.attach_info.GetContinueOnceAttached())
+                m_interpreter.HandleCommand("process continue", false, result);
         }
         return result.Succeeded();
     }
@@ -610,10 +618,11 @@
 OptionDefinition
 CommandObjectProcessAttach::CommandOptions::g_option_table[] =
 {
-{ LLDB_OPT_SET_ALL, false, "plugin", 'P', required_argument, NULL, 0, eArgTypePlugin,        "Name of the process plugin you want to use."},
-{ LLDB_OPT_SET_1,   false, "pid",    'p', required_argument, NULL, 0, eArgTypePid,           "The process ID of an existing process to attach to."},
-{ LLDB_OPT_SET_2,   false, "name",   'n', required_argument, NULL, 0, eArgTypeProcessName,  "The name of the process to attach to."},
-{ LLDB_OPT_SET_2,   false, "waitfor",'w', no_argument,       NULL, 0, eArgTypeNone,              "Wait for the the process with <process-name> to launch."},
+{ LLDB_OPT_SET_ALL, false, "continue",'c', no_argument,       NULL, 0, eArgTypeNone,         "Immediately continue the process once attached."},
+{ LLDB_OPT_SET_ALL, false, "plugin",  'P', required_argument, NULL, 0, eArgTypePlugin,       "Name of the process plugin you want to use."},
+{ LLDB_OPT_SET_1,   false, "pid",     'p', required_argument, NULL, 0, eArgTypePid,          "The process ID of an existing process to attach to."},
+{ LLDB_OPT_SET_2,   false, "name",    'n', required_argument, NULL, 0, eArgTypeProcessName,  "The name of the process to attach to."},
+{ LLDB_OPT_SET_2,   false, "waitfor", 'w', no_argument,       NULL, 0, eArgTypeNone,         "Wait for the the process with <process-name> to launch."},
 { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
 };
 

Modified: lldb/trunk/test/functionalities/completion/TestCompletion.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/completion/TestCompletion.py?rev=157361&r1=157360&r2=157361&view=diff
==============================================================================
--- lldb/trunk/test/functionalities/completion/TestCompletion.py (original)
+++ lldb/trunk/test/functionalities/completion/TestCompletion.py Wed May 23 19:43:00 2012
@@ -18,6 +18,10 @@
         system(["/bin/sh", "-c", "rm -f child_send.txt"])
         system(["/bin/sh", "-c", "rm -f child_read.txt"])
 
+    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 ')
+
     # <rdar://problem/11052829>
     def test_infinite_loop_while_completing(self):
         """Test that 'process print hello\' completes to itself and does not infinite loop."""





More information about the lldb-commits mailing list