18 #include "llvm/Config/config.h" 28 #ifdef HAVE_CRASHREPORTERCLIENT_H 29 #include <CrashReporterClient.h> 37 #if defined(HAVE_BACKTRACE) && ENABLE_BACKTRACES 49 std::tie(Prev, Head, Head->NextEntry) =
50 std::make_tuple(Head, Head->NextEntry, Prev);
77 OS <<
"Stack dump:\n";
84 #if defined (__APPLE__) && defined(HAVE_CRASHREPORTERCLIENT_H) 88 CRASH_REPORTER_CLIENT_HIDDEN
89 struct crashreporter_annotations_t gCRAnnotations
90 __attribute__((section("__DATA," CRASHREPORTER_ANNOTATIONS_SECTION)))
91 #if CRASHREPORTER_ANNOTATIONS_VERSION < 5
92 = { CRASHREPORTER_ANNOTATIONS_VERSION, 0, 0, 0, 0, 0, 0 };
94 = { CRASHREPORTER_ANNOTATIONS_VERSION, 0, 0, 0, 0, 0, 0, 0 };
97 #elif defined(__APPLE__) && HAVE_CRASHREPORTER_INFO 98 extern "C" const char *__crashreporter_info__
99 __attribute__((visibility(
"hidden"))) = 0;
100 asm(
".desc ___crashreporter_info__, 0x10");
118 if (!TmpStr.
empty()) {
119 #ifdef HAVE_CRASHREPORTERCLIENT_H 121 (void)CRSetCrashLogMessage(TmpStr.
c_str());
122 #elif HAVE_CRASHREPORTER_INFO 123 __crashreporter_info__ = strdup(TmpStr.
c_str());
135 #if defined(HAVE_BACKTRACE) && ENABLE_BACKTRACES 143 #if defined(HAVE_BACKTRACE) && ENABLE_BACKTRACES 145 "Pretty stack trace entry destruction is out of order");
154 va_start(AP, Format);
155 const int SizeOrError = vsnprintf(
nullptr, 0, Format, AP);
157 if (SizeOrError < 0) {
161 const int Size = SizeOrError + 1;
163 va_start(AP, Format);
171 OS <<
"Program arguments: ";
173 for (
unsigned i = 0, e = ArgC; i != e; ++i)
174 OS << ArgV[i] <<
' ';
178 #if defined(HAVE_BACKTRACE) && ENABLE_BACKTRACES 186 #if defined(HAVE_BACKTRACE) && ENABLE_BACKTRACES 189 (void)HandlerRegistered;
194 #if defined(HAVE_BACKTRACE) && ENABLE_BACKTRACES 202 #if defined(HAVE_BACKTRACE) && ENABLE_BACKTRACES void RestorePrettyStackState(const void *State)
Restores the topmost element of the "pretty" stack state to State, which should come from a previous ...
raw_ostream & errs()
This returns a reference to a raw_ostream for standard error.
This class represents lattice values for constants.
A raw_ostream that writes to an SmallVector or SmallString.
This class provides an abstraction for a timeout around an operation that must complete in a given am...
void EnablePrettyStackTrace()
StringRef str() const
Explicit conversion to StringRef.
#define LLVM_THREAD_LOCAL
LLVM_THREAD_LOCAL A thread-local storage specifier which can be used with globals, extern globals, and static globals.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
void LLVMEnablePrettyStackTrace()
Enable LLVM's built-in stack trace code.
static void PrintCurStackTrace(raw_ostream &OS)
PrintCurStackTrace - Print the current stack trace to the specified stream.
PrettyStackTraceEntry - This class is used to represent a frame of the "pretty" stack trace that is d...
virtual ~PrettyStackTraceEntry()
const void * SavePrettyStackState()
Returns the topmost element of the "pretty" stack state.
static void PrintStack(raw_ostream &OS)
static LLVM_THREAD_LOCAL PrettyStackTraceEntry * PrettyStackTraceHead
static bool RegisterCrashPrinter()
void print(raw_ostream &OS) const override
print - Emit information about this stack frame to OS.
static void CrashHandler(void *)
CrashHandler - This callback is run if a fatal signal is delivered to the process, it prints the pretty stack trace.
void print(raw_ostream &OS) const override
print - Emit information about this stack frame to OS.
PrettyStackTraceEntry * ReverseStackTrace(PrettyStackTraceEntry *Head)
LLVM_NODISCARD bool empty() const
void AddSignalHandler(SignalHandlerCallback FnPtr, void *Cookie)
Add a function to be called when an abort/kill signal is delivered to the process.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This class implements an extremely fast bulk output stream that can only output to a stream...
const PrettyStackTraceEntry * getNextEntry() const
getNextEntry - Return the next entry in the list of frames.