// 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 ENABLE_BACKTRACE
+#if defined(HAVE_BACKTRACE) && defined(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
#endif
}
-// ENABLE_BACKTRACE
+// defined(HAVE_BACKTRACE) && defined(ENABLE_BACKTRACES)
#endif
PrettyStackTraceEntry::PrettyStackTraceEntry() {
-#if ENABLE_BACKTRACE
+#if defined(HAVE_BACKTRACE) && defined(ENABLE_BACKTRACES)
// Link ourselves.
NextEntry = PrettyStackTraceHead;
PrettyStackTraceHead = this;
}
PrettyStackTraceEntry::~PrettyStackTraceEntry() {
-#if ENABLE_BACKTRACE
+#if defined(HAVE_BACKTRACE) && defined(ENABLE_BACKTRACES)
assert(PrettyStackTraceHead == this &&
"Pretty stack trace entry destruction is out of order");
PrettyStackTraceHead = getNextEntry();
OS << '\n';
}
-#if ENABLE_BACKTRACE
+#if defined(HAVE_BACKTRACE) && defined(ENABLE_BACKTRACES)
static bool RegisterCrashPrinter() {
sys::AddSignalHandler(CrashHandler, nullptr);
return false;
#endif
void llvm::EnablePrettyStackTrace() {
-#if ENABLE_BACKTRACE
+#if defined(HAVE_BACKTRACE) && defined(ENABLE_BACKTRACES)
// The first time this is called, we register the crash printer.
static bool HandlerRegistered = RegisterCrashPrinter();
(void)HandlerRegistered;
#endif
}
+const void* llvm::SavePrettyStackState() {
+#if defined(HAVE_BACKTRACE) && defined(ENABLE_BACKTRACES)
+ return PrettyStackTraceHead;
+#else
+ return nullptr;
+#endif
+}
+
+void llvm::RestorePrettyStackState(const void* Top) {
+#if defined(HAVE_BACKTRACE) && defined(ENABLE_BACKTRACES)
+ PrettyStackTraceHead = (const PrettyStackTraceEntry*)Top;
+#endif
+}
+
void LLVMEnablePrettyStackTrace() {
EnablePrettyStackTrace();
}