Skip to content

Commit b67342e

Browse files
committed
Support: enable backtraces on Windows
Some platforms, e.g. Windows, support backtraces but don't have BACKTRACE. Checking for BACKTRACE prevents Windows from having backtraces. Patch by Jason Mittertreiner! llvm-svn: 354951
1 parent 7d3986e commit b67342e

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

llvm/lib/Support/PrettyStackTrace.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ using namespace llvm;
3333
// If backtrace support is not enabled, compile out support for pretty stack
3434
// traces. This has the secondary effect of not requiring thread local storage
3535
// when backtrace support is disabled.
36-
#if defined(HAVE_BACKTRACE) && ENABLE_BACKTRACES
36+
#if ENABLE_BACKTRACES
3737

3838
// We need a thread local pointer to manage the stack of our stack trace
3939
// objects, but we *really* cannot tolerate destructors running and do not want
@@ -127,19 +127,18 @@ static void CrashHandler(void *) {
127127
#endif
128128
}
129129

130-
// defined(HAVE_BACKTRACE) && ENABLE_BACKTRACES
131-
#endif
130+
#endif // ENABLE_BACKTRACES
132131

133132
PrettyStackTraceEntry::PrettyStackTraceEntry() {
134-
#if defined(HAVE_BACKTRACE) && ENABLE_BACKTRACES
133+
#if ENABLE_BACKTRACES
135134
// Link ourselves.
136135
NextEntry = PrettyStackTraceHead;
137136
PrettyStackTraceHead = this;
138137
#endif
139138
}
140139

141140
PrettyStackTraceEntry::~PrettyStackTraceEntry() {
142-
#if defined(HAVE_BACKTRACE) && ENABLE_BACKTRACES
141+
#if ENABLE_BACKTRACES
143142
assert(PrettyStackTraceHead == this &&
144143
"Pretty stack trace entry destruction is out of order");
145144
PrettyStackTraceHead = NextEntry;
@@ -174,31 +173,31 @@ void PrettyStackTraceProgram::print(raw_ostream &OS) const {
174173
OS << '\n';
175174
}
176175

177-
#if defined(HAVE_BACKTRACE) && ENABLE_BACKTRACES
176+
#if ENABLE_BACKTRACES
178177
static bool RegisterCrashPrinter() {
179178
sys::AddSignalHandler(CrashHandler, nullptr);
180179
return false;
181180
}
182181
#endif
183182

184183
void llvm::EnablePrettyStackTrace() {
185-
#if defined(HAVE_BACKTRACE) && ENABLE_BACKTRACES
184+
#if ENABLE_BACKTRACES
186185
// The first time this is called, we register the crash printer.
187186
static bool HandlerRegistered = RegisterCrashPrinter();
188187
(void)HandlerRegistered;
189188
#endif
190189
}
191190

192191
const void *llvm::SavePrettyStackState() {
193-
#if defined(HAVE_BACKTRACE) && ENABLE_BACKTRACES
192+
#if ENABLE_BACKTRACES
194193
return PrettyStackTraceHead;
195194
#else
196195
return nullptr;
197196
#endif
198197
}
199198

200199
void llvm::RestorePrettyStackState(const void *Top) {
201-
#if defined(HAVE_BACKTRACE) && ENABLE_BACKTRACES
200+
#if ENABLE_BACKTRACES
202201
PrettyStackTraceHead =
203202
static_cast<PrettyStackTraceEntry *>(const_cast<void *>(Top));
204203
#endif

0 commit comments

Comments
 (0)