PrettyStackTrace.cpp (208954) | PrettyStackTrace.cpp (210299) |
---|---|
1//===- PrettyStackTrace.cpp - Pretty Crash Handling -----------------------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9// 10// This file defines some helpful functions for dealing with the possibility of 11// Unix signals occuring while your program is running. 12// 13//===----------------------------------------------------------------------===// 14 | 1//===- PrettyStackTrace.cpp - Pretty Crash Handling -----------------------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9// 10// This file defines some helpful functions for dealing with the possibility of 11// Unix signals occuring while your program is running. 12// 13//===----------------------------------------------------------------------===// 14 |
15#include "llvm/Config/config.h" // Get autoconf configuration settings |
|
15#include "llvm/Support/PrettyStackTrace.h" 16#include "llvm/Support/raw_ostream.h" 17#include "llvm/System/Signals.h" 18#include "llvm/System/ThreadLocal.h" 19#include "llvm/ADT/SmallString.h" | 16#include "llvm/Support/PrettyStackTrace.h" 17#include "llvm/Support/raw_ostream.h" 18#include "llvm/System/Signals.h" 19#include "llvm/System/ThreadLocal.h" 20#include "llvm/ADT/SmallString.h" |
21 22#ifdef HAVE_CRASHREPORTERCLIENT_H 23#include <CrashReporterClient.h> 24#endif 25 |
|
20using namespace llvm; 21 22namespace llvm { 23 bool DisablePrettyStackTrace = false; 24} 25 26// FIXME: This should be thread local when llvm supports threads. 27static sys::ThreadLocal<const PrettyStackTraceEntry> PrettyStackTraceHead; --- 15 unchanged lines hidden (view full) --- 43 44 // If there are pretty stack frames registered, walk and emit them. 45 OS << "Stack dump:\n"; 46 47 PrintStack(PrettyStackTraceHead.get(), OS); 48 OS.flush(); 49} 50 | 26using namespace llvm; 27 28namespace llvm { 29 bool DisablePrettyStackTrace = false; 30} 31 32// FIXME: This should be thread local when llvm supports threads. 33static sys::ThreadLocal<const PrettyStackTraceEntry> PrettyStackTraceHead; --- 15 unchanged lines hidden (view full) --- 49 50 // If there are pretty stack frames registered, walk and emit them. 51 OS << "Stack dump:\n"; 52 53 PrintStack(PrettyStackTraceHead.get(), OS); 54 OS.flush(); 55} 56 |
51// Integrate with crash reporter. 52#ifdef __APPLE__ | 57// Integrate with crash reporter libraries. 58#if defined (__APPLE__) && defined (HAVE_CRASHREPORTERCLIENT_H) 59// If any clients of llvm try to link to libCrashReporterClient.a themselves, 60// only one crash info struct will be used. 61extern "C" { 62CRASH_REPORTER_CLIENT_HIDDEN 63struct crashreporter_annotations_t gCRAnnotations 64 __attribute__((section("__DATA," CRASHREPORTER_ANNOTATIONS_SECTION))) 65 = { CRASHREPORTER_ANNOTATIONS_VERSION, 0, 0, 0, 0 }; 66} 67#elif defined (__APPLE__) |
53static const char *__crashreporter_info__ = 0; 54asm(".desc ___crashreporter_info__, 0x10"); 55#endif 56 57 58/// CrashHandler - This callback is run if a fatal signal is delivered to the 59/// process, it prints the pretty stack trace. 60static void CrashHandler(void *Cookie) { --- 5 unchanged lines hidden (view full) --- 66 // put it into __crashreporter_info__. 67 SmallString<2048> TmpStr; 68 { 69 raw_svector_ostream Stream(TmpStr); 70 PrintCurStackTrace(Stream); 71 } 72 73 if (!TmpStr.empty()) { | 68static const char *__crashreporter_info__ = 0; 69asm(".desc ___crashreporter_info__, 0x10"); 70#endif 71 72 73/// CrashHandler - This callback is run if a fatal signal is delivered to the 74/// process, it prints the pretty stack trace. 75static void CrashHandler(void *Cookie) { --- 5 unchanged lines hidden (view full) --- 81 // put it into __crashreporter_info__. 82 SmallString<2048> TmpStr; 83 { 84 raw_svector_ostream Stream(TmpStr); 85 PrintCurStackTrace(Stream); 86 } 87 88 if (!TmpStr.empty()) { |
89#ifndef HAVE_CRASHREPORTERCLIENT_H |
|
74 __crashreporter_info__ = strdup(std::string(TmpStr.str()).c_str()); | 90 __crashreporter_info__ = strdup(std::string(TmpStr.str()).c_str()); |
91#else 92 CRSetCrashLogMessage(std::string(TmpStr.str()).c_str()); 93#endif |
|
75 errs() << TmpStr.str(); 76 } 77 78#endif 79} 80 81static bool RegisterCrashPrinter() { 82 if (!DisablePrettyStackTrace) --- 32 unchanged lines hidden --- | 94 errs() << TmpStr.str(); 95 } 96 97#endif 98} 99 100static bool RegisterCrashPrinter() { 101 if (!DisablePrettyStackTrace) --- 32 unchanged lines hidden --- |