diff options
author | Chris Lattner <sabre@nondot.org> | 2009-03-05 07:03:49 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-03-05 07:03:49 +0000 |
commit | d56786f79a00fd47a805a17276853ffd9dc4e921 (patch) | |
tree | fee22133622ca3a24e5612610b454d4b4afe3650 /lib/Support | |
parent | fcba7cd630f0d974ae5ade4c1e74d6fc55e8764e (diff) | |
download | external_llvm-d56786f79a00fd47a805a17276853ffd9dc4e921.zip external_llvm-d56786f79a00fd47a805a17276853ffd9dc4e921.tar.gz external_llvm-d56786f79a00fd47a805a17276853ffd9dc4e921.tar.bz2 |
Daniel wanted the stack printed upside down. Perhaps he
feels a kinship to machine stacks that grow down. Now we get
stuff like this:
Stack dump:
0. Program arguments: clang clang_crash_Iw2Osj.mi
1. /Developer/SDKs/MacOSX10.5.sdk/usr/lib/gcc/i686-apple-darwin9/4.0.1/include/xmmintrin.h:624:1: parsing function body '_mm_cvtpi16_ps'
2. /Developer/SDKs/MacOSX10.5.sdk/usr/lib/gcc/i686-apple-darwin9/4.0.1/include/xmmintrin.h:624:1: in compound statement ('{}')
Abort
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66145 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support')
-rw-r--r-- | lib/Support/PrettyStackTrace.cpp | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/lib/Support/PrettyStackTrace.cpp b/lib/Support/PrettyStackTrace.cpp index 0a51404..1462ef0 100644 --- a/lib/Support/PrettyStackTrace.cpp +++ b/lib/Support/PrettyStackTrace.cpp @@ -20,19 +20,27 @@ using namespace llvm; // FIXME: This should be thread local when llvm supports threads. static const PrettyStackTraceEntry *PrettyStackTraceHead = 0; +static unsigned PrintStack(const PrettyStackTraceEntry *Entry, raw_ostream &OS){ + unsigned NextID = 0; + if (Entry->getNextEntry()) + NextID = PrintStack(Entry->getNextEntry(), OS); + OS << NextID << ".\t"; + Entry->print(OS); + + return NextID+1; +} + /// CrashHandler - This callback is run if a fatal signal is delivered to the /// process, it prints the pretty stack trace. static void CrashHandler(void *Cookie) { + // Don't print an empty trace. + if (PrettyStackTraceHead == 0) return; + // If there are pretty stack frames registered, walk and emit them. raw_ostream &OS = errs(); OS << "Stack dump:\n"; - unsigned i = 0; - for (const PrettyStackTraceEntry *Entry = PrettyStackTraceHead; Entry; - Entry = Entry->getNextEntry(), ++i) { - OS << i << ".\t"; - Entry->print(OS); - } + PrintStack(PrettyStackTraceHead, OS); OS.flush(); } |