forked from OSchip/llvm-project
Use 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. llvm-svn: 227423
This commit is contained in:
parent
99cd1fb012
commit
9253bb933a
|
@ -27,6 +27,11 @@
|
||||||
|
|
||||||
using namespace llvm;
|
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 ENABLE_BACKTRACE
|
||||||
|
|
||||||
// We need a thread local pointer to manage the stack of our stack trace
|
// 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
|
// objects, but we *really* cannot tolerate destructors running and do not want
|
||||||
// to pay any overhead of synchronizing. As a consequence, we use a raw
|
// to pay any overhead of synchronizing. As a consequence, we use a raw
|
||||||
|
@ -103,16 +108,23 @@ static void CrashHandler(void *) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ENABLE_BACKTRACE
|
||||||
|
#endif
|
||||||
|
|
||||||
PrettyStackTraceEntry::PrettyStackTraceEntry() {
|
PrettyStackTraceEntry::PrettyStackTraceEntry() {
|
||||||
|
#if ENABLE_BACKTRACE
|
||||||
// Link ourselves.
|
// Link ourselves.
|
||||||
NextEntry = PrettyStackTraceHead;
|
NextEntry = PrettyStackTraceHead;
|
||||||
PrettyStackTraceHead = this;
|
PrettyStackTraceHead = this;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
PrettyStackTraceEntry::~PrettyStackTraceEntry() {
|
PrettyStackTraceEntry::~PrettyStackTraceEntry() {
|
||||||
|
#if ENABLE_BACKTRACE
|
||||||
assert(PrettyStackTraceHead == this &&
|
assert(PrettyStackTraceHead == this &&
|
||||||
"Pretty stack trace entry destruction is out of order");
|
"Pretty stack trace entry destruction is out of order");
|
||||||
PrettyStackTraceHead = getNextEntry();
|
PrettyStackTraceHead = getNextEntry();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrettyStackTraceString::print(raw_ostream &OS) const {
|
void PrettyStackTraceString::print(raw_ostream &OS) const {
|
||||||
|
@ -127,15 +139,19 @@ void PrettyStackTraceProgram::print(raw_ostream &OS) const {
|
||||||
OS << '\n';
|
OS << '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if ENABLE_BACKTRACE
|
||||||
static bool RegisterCrashPrinter() {
|
static bool RegisterCrashPrinter() {
|
||||||
sys::AddSignalHandler(CrashHandler, nullptr);
|
sys::AddSignalHandler(CrashHandler, nullptr);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void llvm::EnablePrettyStackTrace() {
|
void llvm::EnablePrettyStackTrace() {
|
||||||
|
#if ENABLE_BACKTRACE
|
||||||
// The first time this is called, we register the crash printer.
|
// The first time this is called, we register the crash printer.
|
||||||
static bool HandlerRegistered = RegisterCrashPrinter();
|
static bool HandlerRegistered = RegisterCrashPrinter();
|
||||||
(void)HandlerRegistered;
|
(void)HandlerRegistered;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void LLVMEnablePrettyStackTrace() {
|
void LLVMEnablePrettyStackTrace() {
|
||||||
|
|
Loading…
Reference in New Issue