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 = { CRASHREPORTER_ANNOTATIONS_VERSION, 0, 0, 0, 0, 0, 0 };
93 #elif defined(__APPLE__) && HAVE_CRASHREPORTER_INFO
94 extern "C" const char *__crashreporter_info__
96 asm(
".desc ___crashreporter_info__, 0x10");
114 if (!TmpStr.
empty()) {
115 #ifdef HAVE_CRASHREPORTERCLIENT_H
117 (void)CRSetCrashLogMessage(std::string(TmpStr.
str()).
c_str());
118 #elif HAVE_CRASHREPORTER_INFO
119 __crashreporter_info__ = strdup(std::string(TmpStr.
str()).
c_str());
131 #if defined(HAVE_BACKTRACE) && ENABLE_BACKTRACES
139 #if defined(HAVE_BACKTRACE) && ENABLE_BACKTRACES
141 "Pretty stack trace entry destruction is out of order");
150 va_start(AP, Format);
151 const int SizeOrError = vsnprintf(
nullptr, 0, Format, AP);
153 if (SizeOrError < 0) {
157 const int Size = SizeOrError + 1;
159 va_start(AP, Format);
167 OS <<
"Program arguments: ";
169 for (
unsigned i = 0, e = ArgC; i != e; ++i)
170 OS << ArgV[i] <<
' ';
174 #if defined(HAVE_BACKTRACE) && ENABLE_BACKTRACES
182 #if defined(HAVE_BACKTRACE) && ENABLE_BACKTRACES
185 (void)HandlerRegistered;
190 #if defined(HAVE_BACKTRACE) && ENABLE_BACKTRACES
198 #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.
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
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...