From 2bf78b4d6c5ec84e82b9e5cd4a394975f554cce0 Mon Sep 17 00:00:00 2001 From: Joerg Sonnenberger Date: Fri, 30 Sep 2016 20:04:24 +0000 Subject: [PATCH] Convert ENABLE_BACKTRACES into a 0/1 definition. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@282918 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Config/config.h.cmake | 4 ++-- lib/Support/PrettyStackTrace.cpp | 16 ++++++++-------- lib/Support/Unix/Signals.inc | 8 ++++---- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/include/llvm/Config/config.h.cmake b/include/llvm/Config/config.h.cmake index bac98dd8d51..eafab762dae 100644 --- a/include/llvm/Config/config.h.cmake +++ b/include/llvm/Config/config.h.cmake @@ -7,8 +7,8 @@ /* Bug report URL. */ #define BUG_REPORT_URL "${BUG_REPORT_URL}" -/* Define if you want backtraces on crash */ -#cmakedefine ENABLE_BACKTRACES +/* Define to 1 to enable backtraces, and to 0 otherwise. */ +#cmakedefine01 ENABLE_BACKTRACES /* Define to enable crash overrides */ #cmakedefine ENABLE_CRASH_OVERRIDES diff --git a/lib/Support/PrettyStackTrace.cpp b/lib/Support/PrettyStackTrace.cpp index ebad67bb8dc..845745ced69 100644 --- a/lib/Support/PrettyStackTrace.cpp +++ b/lib/Support/PrettyStackTrace.cpp @@ -32,7 +32,7 @@ using namespace llvm; // If backtrace support is not enabled, compile out support for pretty stack // traces. This has the secondary effect of not requiring thread local storage // when backtrace support is disabled. -#if defined(HAVE_BACKTRACE) && defined(ENABLE_BACKTRACES) +#if defined(HAVE_BACKTRACE) && ENABLE_BACKTRACES // We need a thread local pointer to manage the stack of our stack trace // objects, but we *really* cannot tolerate destructors running and do not want @@ -122,11 +122,11 @@ static void CrashHandler(void *) { #endif } -// defined(HAVE_BACKTRACE) && defined(ENABLE_BACKTRACES) +// defined(HAVE_BACKTRACE) && ENABLE_BACKTRACES #endif PrettyStackTraceEntry::PrettyStackTraceEntry() { -#if defined(HAVE_BACKTRACE) && defined(ENABLE_BACKTRACES) +#if defined(HAVE_BACKTRACE) && ENABLE_BACKTRACES // Link ourselves. NextEntry = PrettyStackTraceHead; PrettyStackTraceHead = this; @@ -134,7 +134,7 @@ PrettyStackTraceEntry::PrettyStackTraceEntry() { } PrettyStackTraceEntry::~PrettyStackTraceEntry() { -#if defined(HAVE_BACKTRACE) && defined(ENABLE_BACKTRACES) +#if defined(HAVE_BACKTRACE) && ENABLE_BACKTRACES assert(PrettyStackTraceHead == this && "Pretty stack trace entry destruction is out of order"); PrettyStackTraceHead = NextEntry; @@ -153,7 +153,7 @@ void PrettyStackTraceProgram::print(raw_ostream &OS) const { OS << '\n'; } -#if defined(HAVE_BACKTRACE) && defined(ENABLE_BACKTRACES) +#if defined(HAVE_BACKTRACE) && ENABLE_BACKTRACES static bool RegisterCrashPrinter() { sys::AddSignalHandler(CrashHandler, nullptr); return false; @@ -161,7 +161,7 @@ static bool RegisterCrashPrinter() { #endif void llvm::EnablePrettyStackTrace() { -#if defined(HAVE_BACKTRACE) && defined(ENABLE_BACKTRACES) +#if defined(HAVE_BACKTRACE) && ENABLE_BACKTRACES // The first time this is called, we register the crash printer. static bool HandlerRegistered = RegisterCrashPrinter(); (void)HandlerRegistered; @@ -169,7 +169,7 @@ void llvm::EnablePrettyStackTrace() { } const void *llvm::SavePrettyStackState() { -#if defined(HAVE_BACKTRACE) && defined(ENABLE_BACKTRACES) +#if defined(HAVE_BACKTRACE) && ENABLE_BACKTRACES return PrettyStackTraceHead; #else return nullptr; @@ -177,7 +177,7 @@ const void *llvm::SavePrettyStackState() { } void llvm::RestorePrettyStackState(const void *Top) { -#if defined(HAVE_BACKTRACE) && defined(ENABLE_BACKTRACES) +#if defined(HAVE_BACKTRACE) && ENABLE_BACKTRACES PrettyStackTraceHead = static_cast(const_cast(Top)); #endif diff --git a/lib/Support/Unix/Signals.inc b/lib/Support/Unix/Signals.inc index 3d921fd2e87..d709d2b133d 100644 --- a/lib/Support/Unix/Signals.inc +++ b/lib/Support/Unix/Signals.inc @@ -298,7 +298,7 @@ void llvm::sys::AddSignalHandler(void (*FnPtr)(void *), void *Cookie) { RegisterHandlers(); } -#if defined(HAVE_BACKTRACE) && defined(ENABLE_BACKTRACES) && HAVE_LINK_H && \ +#if defined(HAVE_BACKTRACE) && ENABLE_BACKTRACES && HAVE_LINK_H && \ (defined(__linux__) || defined(__FreeBSD__) || \ defined(__FreeBSD_kernel__) || defined(__NetBSD__)) struct DlIteratePhdrData { @@ -353,9 +353,9 @@ static bool findModulesAndOffsets(void **StackTrace, int Depth, StringSaver &StrPool) { return false; } -#endif // defined(HAVE_BACKTRACE) && defined(ENABLE_BACKTRACES) && ... +#endif // defined(HAVE_BACKTRACE) && ENABLE_BACKTRACES && ... -#if defined(ENABLE_BACKTRACES) && defined(HAVE__UNWIND_BACKTRACE) +#if ENABLE_BACKTRACES && defined(HAVE__UNWIND_BACKTRACE) static int unwindBacktrace(void **StackTrace, int MaxEntries) { if (MaxEntries < 0) return 0; @@ -393,7 +393,7 @@ static int unwindBacktrace(void **StackTrace, int MaxEntries) { // On glibc systems we have the 'backtrace' function, which works nicely, but // doesn't demangle symbols. void llvm::sys::PrintStackTrace(raw_ostream &OS) { -#if defined(ENABLE_BACKTRACES) +#if ENABLE_BACKTRACES static void *StackTrace[256]; int depth = 0; #if defined(HAVE_BACKTRACE) -- 2.11.0