Change various llvm utilities to use PrettyStackTraceProgram in
[oota-llvm.git] / tools / llvm-ranlib / llvm-ranlib.cpp
index cd17be890a2413f9559e944f16b20806b1326c8b..72106104c0067f22f8b93ab5e6b0334db212aab6 100644 (file)
@@ -15,6 +15,7 @@
 #include "llvm/Bitcode/Archive.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/ManagedStatic.h"
+#include "llvm/Support/PrettyStackTrace.h"
 #include "llvm/System/Signals.h"
 #include <iostream>
 #include <iomanip>
@@ -42,7 +43,11 @@ void printSymbolTable(Archive* TheArchive) {
 }
 
 int main(int argc, char **argv) {
-  llvm_shutdown_obj X;  // Call llvm_shutdown() on exit.
+  // Print a stack trace if we signal out.
+  llvm::sys::PrintStackTraceOnErrorSignal();
+  llvm::PrettyStackTraceProgram X(argc, argv);
+  
+  llvm_shutdown_obj Y;  // Call llvm_shutdown() on exit.
 
   // Have the command line options parsed and handle things
   // like --help and --version.
@@ -52,9 +57,6 @@ int main(int argc, char **argv) {
     "  to an LLVM archive file."
   );
 
-  // Print a stack trace if we signal out.
-  sys::PrintStackTraceOnErrorSignal();
-
   int exitCode = 0;
 
   // Make sure we don't exit with "unhandled exception".