[Lldb-commits] [lldb] r121396 - /lldb/trunk/source/Commands/CommandObjectProcess.cpp

Jim Ingham jingham at apple.com
Thu Dec 9 10:58:16 PST 2010


Author: jingham
Date: Thu Dec  9 12:58:16 2010
New Revision: 121396

URL: http://llvm.org/viewvc/llvm-project?rev=121396&view=rev
Log:
process launch now asks to kill the current process if it is alive, and if you affirm, does so for you.
Also added #pragma mark for the command objects defined in the file.

Modified:
    lldb/trunk/source/Commands/CommandObjectProcess.cpp

Modified: lldb/trunk/source/Commands/CommandObjectProcess.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectProcess.cpp?rev=121396&r1=121395&r2=121396&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectProcess.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectProcess.cpp Thu Dec  9 12:58:16 2010
@@ -29,7 +29,7 @@
 //-------------------------------------------------------------------------
 // CommandObjectProcessLaunch
 //-------------------------------------------------------------------------
-
+#pragma mark CommandObjectProjectLaunch
 class CommandObjectProcessLaunch : public CommandObject
 {
 public:
@@ -163,13 +163,29 @@
 
         Process *process = m_interpreter.GetDebugger().GetExecutionContext().process;
         if (process && process->IsAlive())
-        {
-            result.AppendErrorWithFormat ("Process %u is currently being debugged, kill the process before running again.\n",
-                                          process->GetID());
-            result.SetStatus (eReturnStatusFailed);
-            return false;
+        {        
+            if (!m_interpreter.Confirm ("There is a running process, kill it and restart?", true))
+            {
+                result.AppendErrorWithFormat ("Process %u is currently being debugged, restart cancelled.\n",
+                                              process->GetID());
+                result.SetStatus (eReturnStatusFailed);
+                return false;
+            }
+            else
+            {
+                Error error (process->Destroy());
+                if (error.Success())
+                {
+                    result.SetStatus (eReturnStatusSuccessFinishResult);
+                }
+                else
+                {
+                    result.AppendErrorWithFormat ("Failed to kill process: %s\n", error.AsCString());
+                    result.SetStatus (eReturnStatusFailed);
+                }
+            }
         }
-
+        
         const char *plugin_name;
         if (!m_options.plugin_name.empty())
             plugin_name = m_options.plugin_name.c_str();
@@ -357,7 +373,7 @@
 //-------------------------------------------------------------------------
 // CommandObjectProcessAttach
 //-------------------------------------------------------------------------
-
+#pragma mark CommandObjectProcessAttach
 class CommandObjectProcessAttach : public CommandObject
 {
 public:
@@ -737,6 +753,7 @@
 //-------------------------------------------------------------------------
 // CommandObjectProcessContinue
 //-------------------------------------------------------------------------
+#pragma mark CommandObjectProcessContinue
 
 class CommandObjectProcessContinue : public CommandObject
 {
@@ -824,6 +841,7 @@
 //-------------------------------------------------------------------------
 // CommandObjectProcessDetach
 //-------------------------------------------------------------------------
+#pragma mark CommandObjectProcessDetach
 
 class CommandObjectProcessDetach : public CommandObject
 {
@@ -873,6 +891,7 @@
 //-------------------------------------------------------------------------
 // CommandObjectProcessLoad
 //-------------------------------------------------------------------------
+#pragma mark CommandObjectProcessLoad
 
 class CommandObjectProcessLoad : public CommandObject
 {
@@ -930,6 +949,7 @@
 //-------------------------------------------------------------------------
 // CommandObjectProcessUnload
 //-------------------------------------------------------------------------
+#pragma mark CommandObjectProcessUnload
 
 class CommandObjectProcessUnload : public CommandObject
 {
@@ -995,6 +1015,7 @@
 //-------------------------------------------------------------------------
 // CommandObjectProcessSignal
 //-------------------------------------------------------------------------
+#pragma mark CommandObjectProcessSignal
 
 class CommandObjectProcessSignal : public CommandObject
 {
@@ -1079,6 +1100,7 @@
 //-------------------------------------------------------------------------
 // CommandObjectProcessInterrupt
 //-------------------------------------------------------------------------
+#pragma mark CommandObjectProcessInterrupt
 
 class CommandObjectProcessInterrupt : public CommandObject
 {
@@ -1141,6 +1163,7 @@
 //-------------------------------------------------------------------------
 // CommandObjectProcessKill
 //-------------------------------------------------------------------------
+#pragma mark CommandObjectProcessKill
 
 class CommandObjectProcessKill : public CommandObject
 {
@@ -1198,6 +1221,8 @@
 //-------------------------------------------------------------------------
 // CommandObjectProcessStatus
 //-------------------------------------------------------------------------
+#pragma mark CommandObjectProcessStatus
+
 class CommandObjectProcessStatus : public CommandObject
 {
 public:
@@ -1274,6 +1299,7 @@
 //-------------------------------------------------------------------------
 // CommandObjectProcessHandle
 //-------------------------------------------------------------------------
+#pragma mark CommandObjectProcessHandle
 
 class CommandObjectProcessHandle : public CommandObject
 {





More information about the lldb-commits mailing list