aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2009-06-25 23:31:33 +0000
committerOwen Anderson <resistor@mac.com>2009-06-25 23:31:33 +0000
commit202699a84659976a41b866409e7a48434f0ffd26 (patch)
tree86423af67917b45bab26e18cc909b41b231ed3f6 /lib
parent35483cba357e7163a6351ed958740f06ecc5e406 (diff)
downloadexternal_llvm-202699a84659976a41b866409e7a48434f0ffd26.zip
external_llvm-202699a84659976a41b866409e7a48434f0ffd26.tar.gz
external_llvm-202699a84659976a41b866409e7a48434f0ffd26.tar.bz2
Support thread-local pretty stack traces.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74227 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Support/PrettyStackTrace.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/lib/Support/PrettyStackTrace.cpp b/lib/Support/PrettyStackTrace.cpp
index c111c5e..14290a1 100644
--- a/lib/Support/PrettyStackTrace.cpp
+++ b/lib/Support/PrettyStackTrace.cpp
@@ -15,11 +15,12 @@
#include "llvm/Support/PrettyStackTrace.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/System/Signals.h"
+#include "llvm/System/ThreadLocal.h"
#include "llvm/ADT/SmallString.h"
using namespace llvm;
// FIXME: This should be thread local when llvm supports threads.
-static const PrettyStackTraceEntry *PrettyStackTraceHead = 0;
+static sys::ThreadLocal<const PrettyStackTraceEntry> PrettyStackTraceHead;
static unsigned PrintStack(const PrettyStackTraceEntry *Entry, raw_ostream &OS){
unsigned NextID = 0;
@@ -34,12 +35,12 @@ static unsigned PrintStack(const PrettyStackTraceEntry *Entry, raw_ostream &OS){
/// PrintCurStackTrace - Print the current stack trace to the specified stream.
static void PrintCurStackTrace(raw_ostream &OS) {
// Don't print an empty trace.
- if (PrettyStackTraceHead == 0) return;
+ if (PrettyStackTraceHead.get() == 0) return;
// If there are pretty stack frames registered, walk and emit them.
OS << "Stack dump:\n";
- PrintStack(PrettyStackTraceHead, OS);
+ PrintStack(PrettyStackTraceHead.get(), OS);
OS.flush();
}
@@ -84,14 +85,14 @@ PrettyStackTraceEntry::PrettyStackTraceEntry() {
HandlerRegistered = HandlerRegistered;
// Link ourselves.
- NextEntry = PrettyStackTraceHead;
- PrettyStackTraceHead = this;
+ NextEntry = PrettyStackTraceHead.get();
+ PrettyStackTraceHead.set(this);
}
PrettyStackTraceEntry::~PrettyStackTraceEntry() {
- assert(PrettyStackTraceHead == this &&
+ assert(PrettyStackTraceHead.get() == this &&
"Pretty stack trace entry destruction is out of order");
- PrettyStackTraceHead = getNextEntry();
+ PrettyStackTraceHead.set(getNextEntry());
}
void PrettyStackTraceString::print(raw_ostream &OS) const {