[llvm] r234353 - Add boolean to PrintStackTraceOnErrorSignal to disable crash reporting.

Pete Cooper peter_cooper at apple.com
Tue Apr 7 13:43:23 PDT 2015


Author: pete
Date: Tue Apr  7 15:43:23 2015
New Revision: 234353

URL: http://llvm.org/viewvc/llvm-project?rev=234353&view=rev
Log:
Add boolean to PrintStackTraceOnErrorSignal to disable crash reporting.

The current crash reporting on Mac OS is only disabled via an environment variable.
This adds a boolean (default false) which can also disable crash reporting.

The only client right now is the unittests which don't ever want crash reporting, but do want to detect killed programs.

Reduces the time to run the APFloat unittests on my machine from

[----------] 47 tests from APFloatTest (51250 ms total)

to

[----------] 47 tests from APFloatTest (765 ms total)

Reviewed by Reid Kleckner and Justin Bogner

Modified:
    llvm/trunk/include/llvm/Support/Signals.h
    llvm/trunk/lib/Support/Unix/Signals.inc
    llvm/trunk/lib/Support/Windows/Signals.inc
    llvm/trunk/utils/unittest/UnitTestMain/TestMain.cpp

Modified: llvm/trunk/include/llvm/Support/Signals.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Signals.h?rev=234353&r1=234352&r2=234353&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/Signals.h (original)
+++ llvm/trunk/include/llvm/Support/Signals.h Tue Apr  7 15:43:23 2015
@@ -39,7 +39,7 @@ namespace sys {
   /// When an error signal (such as SIBABRT or SIGSEGV) is delivered to the
   /// process, print a stack trace and then exit.
   /// @brief Print a stack trace if a fatal signal occurs.
-  void PrintStackTraceOnErrorSignal();
+  void PrintStackTraceOnErrorSignal(bool DisableCrashReporting = false);
 
   /// Disable all system dialog boxes that appear when the process crashes.
   void DisableSystemDialogsOnCrash();

Modified: llvm/trunk/lib/Support/Unix/Signals.inc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Unix/Signals.inc?rev=234353&r1=234352&r2=234353&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Unix/Signals.inc (original)
+++ llvm/trunk/lib/Support/Unix/Signals.inc Tue Apr  7 15:43:23 2015
@@ -486,12 +486,12 @@ void llvm::sys::DisableSystemDialogsOnCr
 
 /// PrintStackTraceOnErrorSignal - When an error signal (such as SIGABRT or
 /// SIGSEGV) is delivered to the process, print a stack trace and then exit.
-void llvm::sys::PrintStackTraceOnErrorSignal() {
+void llvm::sys::PrintStackTraceOnErrorSignal(bool DisableCrashReporting) {
   AddSignalHandler(PrintStackTraceSignalHandler, nullptr);
 
 #if defined(__APPLE__) && defined(ENABLE_CRASH_OVERRIDES)
   // Environment variable to disable any kind of crash dialog.
-  if (getenv("LLVM_DISABLE_CRASH_REPORT")) {
+  if (DisableCrashReporting || getenv("LLVM_DISABLE_CRASH_REPORT")) {
     mach_port_t self = mach_task_self();
 
     exception_mask_t mask = EXC_MASK_CRASH;

Modified: llvm/trunk/lib/Support/Windows/Signals.inc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Windows/Signals.inc?rev=234353&r1=234352&r2=234353&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Windows/Signals.inc (original)
+++ llvm/trunk/lib/Support/Windows/Signals.inc Tue Apr  7 15:43:23 2015
@@ -389,7 +389,7 @@ void sys::DisableSystemDialogsOnCrash()
 
 /// PrintStackTraceOnErrorSignal - When an error signal (such as SIBABRT or
 /// SIGSEGV) is delivered to the process, print a stack trace and then exit.
-void sys::PrintStackTraceOnErrorSignal() {
+void sys::PrintStackTraceOnErrorSignal(bool DisableCrashReporting) {
   DisableSystemDialogsOnCrash();
   RegisterHandler();
   LeaveCriticalSection(&CriticalSection);

Modified: llvm/trunk/utils/unittest/UnitTestMain/TestMain.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/unittest/UnitTestMain/TestMain.cpp?rev=234353&r1=234352&r2=234353&view=diff
==============================================================================
--- llvm/trunk/utils/unittest/UnitTestMain/TestMain.cpp (original)
+++ llvm/trunk/utils/unittest/UnitTestMain/TestMain.cpp Tue Apr  7 15:43:23 2015
@@ -23,7 +23,7 @@
 const char *TestMainArgv0;
 
 int main(int argc, char **argv) {
-  llvm::sys::PrintStackTraceOnErrorSignal();
+  llvm::sys::PrintStackTraceOnErrorSignal(true /* Disable crash reporting */);
   testing::InitGoogleTest(&argc, argv);
   llvm::cl::ParseCommandLineOptions(argc, argv);
 





More information about the llvm-commits mailing list