Sometimes when launching through a shell, we can run into cases where the /bin/sh or /usr/bin/arch can crash the process due to security measures. Now we correctly report when a process exited in the process of launching so we can show the reason why it crashed instead of just showing “initial process state wasn't stopped: exited”.

llvm-svn: 207700
diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index 33d3323..fa1b70f 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -2434,6 +2434,27 @@
                     error = error2;
                 }
             }
+            else if (state == eStateExited)
+            {
+                bool with_shell = launch_info.GetShell();
+                const int exit_status = m_process_sp->GetExitStatus();
+                const char *exit_desc = m_process_sp->GetExitDescription();
+#define LAUNCH_SHELL_MESSAGE "\n'r' and 'run' are aliases that default to launching through a shell.\nTry launching without going through a shell by using 'process launch'."
+                if (exit_desc && exit_desc[0])
+                {
+                    if (with_shell)
+                        error.SetErrorStringWithFormat ("process exited with status %i (%s)" LAUNCH_SHELL_MESSAGE, exit_status, exit_desc);
+                    else
+                        error.SetErrorStringWithFormat ("process exited with status %i (%s)", exit_status, exit_desc);
+                }
+                else
+                {
+                    if (with_shell)
+                        error.SetErrorStringWithFormat ("process exited with status %i" LAUNCH_SHELL_MESSAGE, exit_status);
+                    else
+                        error.SetErrorStringWithFormat ("process exited with status %i", exit_status);
+                }
+            }
             else
             {
                 error.SetErrorStringWithFormat ("initial process state wasn't stopped: %s", StateAsCString(state));