mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-09-07 16:54:48 +00:00
Support thread-local pretty stack traces.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74227 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
438d3946af
commit
0b49c32c56
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user