18 #include "llvm/Config/config.h"
27 #ifdef HAVE_CRASHREPORTERCLIENT_H
28 #include <CrashReporterClient.h>
36 #if defined(HAVE_BACKTRACE) && ENABLE_BACKTRACES
48 std::tie(Prev, Head, Head->NextEntry) =
49 std::make_tuple(Head, Head->NextEntry, Prev);
76 OS <<
"Stack dump:\n";
83 #if defined (__APPLE__) && defined(HAVE_CRASHREPORTERCLIENT_H)
87 CRASH_REPORTER_CLIENT_HIDDEN
88 struct crashreporter_annotations_t gCRAnnotations
89 __attribute__((section("__DATA," CRASHREPORTER_ANNOTATIONS_SECTION)))
90 = { CRASHREPORTER_ANNOTATIONS_VERSION, 0, 0, 0, 0, 0, 0 };
92 #elif defined(__APPLE__) && HAVE_CRASHREPORTER_INFO
93 extern "C" const char *__crashreporter_info__
95 asm(
".desc ___crashreporter_info__, 0x10");
113 if (!TmpStr.
empty()) {
114 #ifdef HAVE_CRASHREPORTERCLIENT_H
116 (void)CRSetCrashLogMessage(std::string(TmpStr.
str()).
c_str());
117 #elif HAVE_CRASHREPORTER_INFO
118 __crashreporter_info__ = strdup(std::string(TmpStr.
str()).
c_str());
130 #if defined(HAVE_BACKTRACE) && ENABLE_BACKTRACES
138 #if defined(HAVE_BACKTRACE) && ENABLE_BACKTRACES
140 "Pretty stack trace entry destruction is out of order");
149 va_start(AP, Format);
150 const int SizeOrError = vsnprintf(
nullptr, 0, Format, AP);
152 if (SizeOrError < 0) {
156 const int Size = SizeOrError + 1;
158 va_start(AP, Format);
166 OS <<
"Program arguments: ";
168 for (
unsigned i = 0, e = ArgC;
i != e; ++
i)
169 OS << ArgV[
i] <<
' ';
173 #if defined(HAVE_BACKTRACE) && ENABLE_BACKTRACES
181 #if defined(HAVE_BACKTRACE) && ENABLE_BACKTRACES
184 (void)HandlerRegistered;
189 #if defined(HAVE_BACKTRACE) && ENABLE_BACKTRACES
197 #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.
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()
const PrettyStackTraceEntry * getNextEntry() const
getNextEntry - Return the next entry in the list of frames.
__attribute__((weak)) int LLVMFuzzerInitialize(int *argc
LLVM_NODISCARD bool empty() const
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
#define LLVM_THREAD_LOCAL
LLVM_THREAD_LOCAL
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()
SmallVectorImpl< T >::const_pointer c_str(SmallVectorImpl< T > &str)
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.
StringRef str() const
Explicit conversion to StringRef.
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.
pointer data()
Return a pointer to the vector's buffer, even if empty().
PrettyStackTraceEntry * ReverseStackTrace(PrettyStackTraceEntry *Head)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This class implements an extremely fast bulk output stream that can only output to a stream...
void AddSignalHandler(void(*FnPtr)(void *), void *Cookie)
AddSignalHandler - Add a function to be called when an abort/kill signal is delivered to the process...