rdar://problem/11140741
authorJohnny Chen <johnny.chen@apple.com>
Fri, 18 May 2012 00:51:36 +0000 (00:51 +0000)
committerJohnny Chen <johnny.chen@apple.com>
Fri, 18 May 2012 00:51:36 +0000 (00:51 +0000)
For "process attach", make the success criterion as the inferior changes its state to eStateStopped.
Otherwise, mark it as a failure and say so.

llvm-svn: 157036

lldb/source/Commands/CommandObjectProcess.cpp

index 0dbf54f..3958af5 100644 (file)
@@ -541,8 +541,18 @@ public:
                     StateType state = process->WaitForProcessToStop (NULL);
                     
                     result.SetDidChangeProcessState (true);
-                    result.AppendMessageWithFormat ("Process %llu %s\n", process->GetID(), StateAsCString (state));
-                    result.SetStatus (eReturnStatusSuccessFinishNoResult);
+
+                    if (state == eStateStopped)
+                    {
+                        result.AppendMessageWithFormat ("Process %llu %s\n", process->GetID(), StateAsCString (state));
+                        result.SetStatus (eReturnStatusSuccessFinishNoResult);
+                    }
+                    else
+                    {
+                        result.AppendError ("attach failed: process did not stop (no such process or permission problem?)");
+                        result.SetStatus (eReturnStatusFailed);
+                        return false;                
+                    }
                 }
             }
         }