[PATCH] Compile out all pretty stack trace support when LLVM is built without support for backtraces.
Owen Anderson
resistor at mac.com
Wed Jan 28 22:04:21 PST 2015
Hi chandlerc,
This change uses the existing build configuration parameter ENABLE_BACKTRACE to compile out all pretty stack trace support when backtraces are disabled.
This has the nice secondary effect of allowing LLVM to continue to build for targets without __thread or thread_local support to continue to work so long as they build without support for backtraces.
http://reviews.llvm.org/D7242
Files:
lib/Support/PrettyStackTrace.cpp
Index: lib/Support/PrettyStackTrace.cpp
===================================================================
--- lib/Support/PrettyStackTrace.cpp
+++ lib/Support/PrettyStackTrace.cpp
@@ -32,13 +32,16 @@
// thread-local variable. Some day, we should be able to use a limited subset
// of C++11's thread_local, but compilers aren't up for it today.
// FIXME: This should be moved to a Compiler.h abstraction.
+#if ENABLE_BACKTRACE
#ifdef _MSC_VER // MSVC supports this with a __declspec.
static __declspec(thread) const PrettyStackTraceEntry
*PrettyStackTraceHead = nullptr;
#else // Clang, GCC, and all compatible compilers tend to use __thread.
static __thread const PrettyStackTraceEntry *PrettyStackTraceHead = nullptr;
#endif
+#endif
+#if ENABLE_BACKTRACE
static unsigned PrintStack(const PrettyStackTraceEntry *Entry, raw_ostream &OS){
unsigned NextID = 0;
if (Entry->getNextEntry())
@@ -107,17 +110,22 @@
#endif
}
+#endif
PrettyStackTraceEntry::PrettyStackTraceEntry() {
+#if ENABLE_BACKTRACE
// Link ourselves.
NextEntry = PrettyStackTraceHead;
PrettyStackTraceHead = this;
+#endif
}
PrettyStackTraceEntry::~PrettyStackTraceEntry() {
+#if ENABLE_BACKTRACE
assert(PrettyStackTraceHead == this &&
"Pretty stack trace entry destruction is out of order");
PrettyStackTraceHead = getNextEntry();
+#endif
}
void PrettyStackTraceString::print(raw_ostream &OS) const {
@@ -132,17 +140,23 @@
OS << '\n';
}
+#if ENABLE_BACKTRACE
static bool RegisterCrashPrinter() {
sys::AddSignalHandler(CrashHandler, nullptr);
return false;
}
+#endif
void llvm::EnablePrettyStackTrace() {
+#if ENABLE_BACKTRACE
// The first time this is called, we register the crash printer.
static bool HandlerRegistered = RegisterCrashPrinter();
(void)HandlerRegistered;
+#endif
}
void LLVMEnablePrettyStackTrace() {
+#if ENABLE_BACKTRACE
EnablePrettyStackTrace();
+#endif
}
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D7242.18938.patch
Type: text/x-patch
Size: 1939 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150129/f56f2810/attachment.bin>
More information about the llvm-commits
mailing list