From 90bb3f3706cdf4e26df5e2c977d9232ba7b89c4e Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Thu, 16 Jul 2009 06:17:45 +0000 Subject: [PATCH] add a knob to turn off PrettyStackTrace globally. Patch by Zoltan Varga! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75897 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/PrettyStackTrace.h | 6 ++++++ lib/Support/PrettyStackTrace.cpp | 7 ++++++- 2 files changed, 12 insertions(+), 1 deletion(-) 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; } -- 2.34.1