17 #include "llvm/Config/config.h" 29 #ifdef HAVE_CRASHREPORTERCLIENT_H 30 #include <CrashReporterClient.h> 66 std::tie(Prev, Head, Head->NextEntry) =
67 std::make_tuple(Head, Head->NextEntry, Prev);
98 OS <<
"Stack dump:\n";
105 #if defined (__APPLE__) && defined(HAVE_CRASHREPORTERCLIENT_H) 109 CRASH_REPORTER_CLIENT_HIDDEN
110 struct crashreporter_annotations_t gCRAnnotations
111 __attribute__((section("__DATA," CRASHREPORTER_ANNOTATIONS_SECTION)))
112 #if CRASHREPORTER_ANNOTATIONS_VERSION < 5
113 = { CRASHREPORTER_ANNOTATIONS_VERSION, 0, 0, 0, 0, 0, 0 };
115 = { CRASHREPORTER_ANNOTATIONS_VERSION, 0, 0, 0, 0, 0, 0, 0 };
118 #elif defined(__APPLE__) && HAVE_CRASHREPORTER_INFO 119 extern "C" const char *__crashreporter_info__
120 __attribute__((visibility(
"hidden"))) = 0;
121 asm(
".desc ___crashreporter_info__, 0x10");
126 #ifdef HAVE_CRASHREPORTERCLIENT_H 127 (void)CRSetCrashLogMessage(msg);
128 #elif HAVE_CRASHREPORTER_INFO 129 __crashreporter_info__ = msg;
133 std::atomic_signal_fence(std::memory_order_seq_cst);
138 using CrashHandlerStringStorage =
139 std::aligned_storage<
sizeof(CrashHandlerString),
140 alignof(CrashHandlerString)>
::type;
141 static CrashHandlerStringStorage crashHandlerStringStorage;
161 auto &crashHandlerString =
162 *
new (&crashHandlerStringStorage) CrashHandlerString;
176 if (!crashHandlerString.empty()) {
178 errs() << crashHandlerString.str();
185 unsigned CurrentSigInfoGeneration =
196 #endif // ENABLE_BACKTRACES 199 #if ENABLE_BACKTRACES 209 #if ENABLE_BACKTRACES 211 "Pretty stack trace entry destruction is out of order");
222 va_start(AP, Format);
223 const int SizeOrError = vsnprintf(
nullptr, 0, Format, AP);
225 if (SizeOrError < 0) {
229 const int Size = SizeOrError + 1;
231 va_start(AP, Format);
239 OS <<
"Program arguments: ";
241 for (
unsigned i = 0,
e = ArgC; i !=
e; ++i)
242 OS << ArgV[i] <<
' ';
246 #if ENABLE_BACKTRACES 254 #if ENABLE_BACKTRACES 257 (void)HandlerRegistered;
262 #if ENABLE_BACKTRACES 269 static bool HandlerRegistered = []{
275 (void)HandlerRegistered;
284 #if ENABLE_BACKTRACES 292 #if 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.
static void printForSigInfoIfNeeded()
static LLVM_THREAD_LOCAL unsigned ThreadLocalSigInfoGenerationCounter
A raw_ostream that writes to an SmallVector or SmallString.
static volatile std::atomic< unsigned > GlobalSigInfoGenerationCounter
This class provides an abstraction for a timeout around an operation that must complete in a given am...
void EnablePrettyStackTrace()
Enables dumping a "pretty" stack trace when the program crashes.
void SetInfoSignalFunction(void(*Handler)())
Registers a function to be called when an "info" signal is delivered to the process.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
#define LLVM_THREAD_LOCAL
LLVM_THREAD_LOCAL A thread-local storage specifier which can be used with globals, extern globals, and static globals.
static LLVM_ATTRIBUTE_NOINLINE void PrintCurStackTrace(raw_ostream &OS)
Print the current stack trace to the specified stream.
#define LLVM_ATTRIBUTE_UNUSED
void LLVMEnablePrettyStackTrace()
Enable LLVM's built-in stack trace code.
static void setCrashLogMessage(const char *msg) LLVM_ATTRIBUTE_UNUSED
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)
#define LLVM_ATTRIBUTE_NOINLINE
LLVM_ATTRIBUTE_NOINLINE - On compilers where we have a directive to do so, mark a method "not for inl...
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.
A utility class that uses RAII to save and restore the value of a variable.
static void CrashHandler(void *)
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.
void EnablePrettyStackTraceOnSigInfoForThisThread(bool ShouldEnable=true)
Enables (or disables) dumping a "pretty" stack trace when the user sends SIGINFO or SIGUSR1 to the cu...
PrettyStackTraceEntry * ReverseStackTrace(PrettyStackTraceEntry *Head)
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 file provides utility classes that use RAII to save and restore values.
This class implements an extremely fast bulk output stream that can only output to a stream...