JDevlieghere created this revision.
JDevlieghere added reviewers: vsk, labath.
Herald added a reviewer: jfb.
Herald added a project: LLDB.
JDevlieghere added a subscriber: friss.
Herald added a subscriber: dexonsmith.
JDevlieghere updated this revision to Diff 229212.
JDevlieghere added a comment.
vsk accepted this revision.
This revision is now accepted and ready to land.

Fold `ToolName` into `printHelp`


vsk added a comment.

Looks good to me!


I noticed that currently we are printing LLVM's pretty stack trace
twice. The reason is that we're calling PrintStackTraceOnErrorSignal in
addition to InitLLVM, which besides some other useful things, also
register LLVM's pretty stack trace handler.


https://reviews.llvm.org/D70216

Files:
  lldb/tools/driver/Driver.cpp


Index: lldb/tools/driver/Driver.cpp
===================================================================
--- lldb/tools/driver/Driver.cpp
+++ lldb/tools/driver/Driver.cpp
@@ -22,7 +22,6 @@
 #include "llvm/Support/Format.h"
 #include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/Path.h"
-#include "llvm/Support/PrettyStackTrace.h"
 #include "llvm/Support/Process.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/WithColor.h"
@@ -809,13 +808,10 @@
 
 int main(int argc, char const *argv[])
 {
+  // Setup LLVM signal handlers and make sure we call llvm_shutdown() on
+  // destruction.
   llvm::InitLLVM IL(argc, argv);
 
-  // Print stack trace on crash.
-  llvm::StringRef ToolName = llvm::sys::path::filename(argv[0]);
-  llvm::sys::PrintStackTraceOnErrorSignal(ToolName);
-  llvm::PrettyStackTraceProgram X(argc, argv);
-
   // Parse arguments.
   LLDBOptTable T;
   unsigned MAI;
@@ -824,7 +820,7 @@
   opt::InputArgList input_args = T.ParseArgs(arg_arr, MAI, MAC);
 
   if (input_args.hasArg(OPT_help)) {
-    printHelp(T, ToolName);
+    printHelp(T, llvm::sys::path::filename(argv[0]));
     return 0;
   }
 


Index: lldb/tools/driver/Driver.cpp
===================================================================
--- lldb/tools/driver/Driver.cpp
+++ lldb/tools/driver/Driver.cpp
@@ -22,7 +22,6 @@
 #include "llvm/Support/Format.h"
 #include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/Path.h"
-#include "llvm/Support/PrettyStackTrace.h"
 #include "llvm/Support/Process.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/WithColor.h"
@@ -809,13 +808,10 @@
 
 int main(int argc, char const *argv[])
 {
+  // Setup LLVM signal handlers and make sure we call llvm_shutdown() on
+  // destruction.
   llvm::InitLLVM IL(argc, argv);
 
-  // Print stack trace on crash.
-  llvm::StringRef ToolName = llvm::sys::path::filename(argv[0]);
-  llvm::sys::PrintStackTraceOnErrorSignal(ToolName);
-  llvm::PrettyStackTraceProgram X(argc, argv);
-
   // Parse arguments.
   LLDBOptTable T;
   unsigned MAI;
@@ -824,7 +820,7 @@
   opt::InputArgList input_args = T.ParseArgs(arg_arr, MAI, MAC);
 
   if (input_args.hasArg(OPT_help)) {
-    printHelp(T, ToolName);
+    printHelp(T, llvm::sys::path::filename(argv[0]));
     return 0;
   }
 
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to