Give better information about how the passes crash
authorChris Lattner <sabre@nondot.org>
Mon, 2 Jun 2003 04:54:16 +0000 (04:54 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 2 Jun 2003 04:54:16 +0000 (04:54 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@6532 91177308-0d34-0410-b5e6-96231b3b80d8

tools/bugpoint/OptimizerDriver.cpp

index fefca73795157d2cb82b0d1ea530704fdb9a108c..d6beef541bd4f3f51d9cde79de1f6a6b2ed2d6f5 100644 (file)
@@ -133,8 +133,23 @@ bool BugDriver::runPasses(const std::vector<const PassInfo*> &Passes,
   if (DeleteOutput)
     removeFile(OutputFilename);
 
-  if (!Quiet) std::cout << (Status ? "Crashed!\n" : "Success!\n");
+  bool ExitedOK = WIFEXITED(Status) && WEXITSTATUS(Status) == 0;
+  
+  if (!Quiet) {
+    if (ExitedOK)
+      std::cout << "Success!\n";
+    else if (WIFEXITED(Status))
+      std::cout << "Exited with error code '" << WEXITSTATUS(Status) << "'\n";
+    else if (WIFSIGNALED(Status))
+      std::cout << "Crashed with signal #" << WTERMSIG(Status) << "\n";
+#ifdef WCOREDUMP
+    else if (WCOREDUMP(Status))
+      std::cout << "Dumped core\n";
+#endif
+    else
+      std::cout << "Failed for unknown reason!\n";
+  }
 
   // Was the child successful?
-  return Status != 0;
+  return !ExitedOK;
 }