From: Joerg Sonnenberger Date: Fri, 30 Sep 2016 20:04:24 +0000 (+0000) Subject: Convert ENABLE_BACKTRACES into a 0/1 definition. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0e3cc3c67c8572676b561b8c542a4af0baf473e7;p=platform%2Fupstream%2Fllvm.git Convert ENABLE_BACKTRACES into a 0/1 definition. llvm-svn: 282918 --- diff --git a/llvm/include/llvm/Config/config.h.cmake b/llvm/include/llvm/Config/config.h.cmake index bac98dd..eafab76 100644 --- a/llvm/include/llvm/Config/config.h.cmake +++ b/llvm/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/llvm/lib/Support/PrettyStackTrace.cpp b/llvm/lib/Support/PrettyStackTrace.cpp index ebad67b..845745c 100644 --- a/llvm/lib/Support/PrettyStackTrace.cpp +++ b/llvm/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/llvm/lib/Support/Unix/Signals.inc b/llvm/lib/Support/Unix/Signals.inc index 3d921fd..d709d2b 100644 --- a/llvm/lib/Support/Unix/Signals.inc +++ b/llvm/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)