diff --git a/include/llvm/Support/PrettyStackTrace.h b/include/llvm/Support/PrettyStackTrace.h index 909d286f28b..0db84e1a14c 100644 --- a/include/llvm/Support/PrettyStackTrace.h +++ b/include/llvm/Support/PrettyStackTrace.h @@ -18,6 +18,12 @@ namespace llvm { class raw_ostream; + + /// DisablePrettyStackTrace - Set this to true to disable this module. This + /// might be neccessary if the host application installs its own signal + /// handlers which conflict with the ones installed by this module. + /// Defaults to false. + extern bool DisablePrettyStackTrace; /// PrettyStackTraceEntry - This class is used to represent a frame of the /// "pretty" stack trace that is dumped when a program crashes. You can define diff --git a/lib/Support/PrettyStackTrace.cpp b/lib/Support/PrettyStackTrace.cpp index 14290a1284f..536d9b023fc 100644 --- a/lib/Support/PrettyStackTrace.cpp +++ b/lib/Support/PrettyStackTrace.cpp @@ -19,6 +19,10 @@ #include "llvm/ADT/SmallString.h" using namespace llvm; +namespace llvm { + bool DisablePrettyStackTrace = false; +} + // FIXME: This should be thread local when llvm supports threads. static sys::ThreadLocal PrettyStackTraceHead; @@ -75,7 +79,8 @@ static void CrashHandler(void *Cookie) { } static bool RegisterCrashPrinter() { - sys::AddSignalHandler(CrashHandler, 0); + if (!DisablePrettyStackTrace) + sys::AddSignalHandler(CrashHandler, 0); return false; }