Go to the documentation of this file.
16 #include "llvm/Config/config.h"
34 #ifdef HAVE_CRASHREPORTERCLIENT_H
35 #include <CrashReporterClient.h>
41 "PLEASE submit a bug report to " BUG_REPORT_URL
42 " and include the crash backtrace.\n";
75 std::tie(Prev, Head, Head->NextEntry) =
76 std::make_tuple(Head, Head->NextEntry, Prev);
90 Entry = Entry->getNextEntry()) {
107 OS <<
"Stack dump:\n";
114 #if defined (__APPLE__) && defined(HAVE_CRASHREPORTERCLIENT_H)
118 CRASH_REPORTER_CLIENT_HIDDEN
119 struct crashreporter_annotations_t gCRAnnotations
120 __attribute__((section("
__DATA," CRASHREPORTER_ANNOTATIONS_SECTION)))
121 #
if CRASHREPORTER_ANNOTATIONS_VERSION < 5
122 = { CRASHREPORTER_ANNOTATIONS_VERSION, 0, 0, 0, 0, 0, 0 };
124 = { CRASHREPORTER_ANNOTATIONS_VERSION, 0, 0, 0, 0, 0, 0, 0 };
127 #elif defined(__APPLE__) && HAVE_CRASHREPORTER_INFO
128 extern "C" const char *__crashreporter_info__
129 __attribute__((visibility(
"hidden"))) = 0;
130 asm(
".desc ___crashreporter_info__, 0x10");
135 #ifdef HAVE_CRASHREPORTERCLIENT_H
136 (void)CRSetCrashLogMessage(msg);
137 #elif HAVE_CRASHREPORTER_INFO
138 __crashreporter_info__ = msg;
142 std::atomic_signal_fence(std::memory_order_seq_cst);
147 using CrashHandlerStringStorage =
148 std::aligned_storage<
sizeof(CrashHandlerString),
149 alignof(CrashHandlerString)>
::type;
150 static CrashHandlerStringStorage crashHandlerStringStorage;
172 auto &crashHandlerString =
173 *
new (&crashHandlerStringStorage) CrashHandlerString;
187 if (!crashHandlerString.empty()) {
189 errs() << crashHandlerString.str();
196 unsigned CurrentSigInfoGeneration =
207 #endif // ENABLE_BACKTRACES
218 #if ENABLE_BACKTRACES
228 #if ENABLE_BACKTRACES
230 "Pretty stack trace entry destruction is out of order");
242 const int SizeOrError = vsnprintf(
nullptr, 0,
Format, AP);
244 if (SizeOrError < 0) {
248 const int Size = SizeOrError + 1;
258 OS <<
"Program arguments: ";
260 for (
int I = 0;
I < ArgC; ++
I) {
261 const bool HaveSpace = ::strchr(ArgV[
I],
' ');
273 #if ENABLE_BACKTRACES
281 #if ENABLE_BACKTRACES
284 (void)HandlerRegistered;
289 #if ENABLE_BACKTRACES
296 static bool HandlerRegistered = []{
302 (void)HandlerRegistered;
311 #if ENABLE_BACKTRACES
319 #if ENABLE_BACKTRACES
void EnablePrettyStackTraceOnSigInfoForThisThread(bool ShouldEnable=true)
Enables (or disables) dumping a "pretty" stack trace when the user sends SIGINFO or SIGUSR1 to the cu...
This is an optimization pass for GlobalISel generic memory operations.
static const char * BugReportMsg
void LLVMEnablePrettyStackTrace()
Enable LLVM's built-in stack trace code.
raw_ostream & write_escaped(StringRef Str, bool UseHexEscapes=false)
Output Str, turning '\', '\t', ' ', '"', and anything that doesn't satisfy llvm::isPrint into an esca...
static void CrashHandler(void *)
This callback is run if a fatal signal is delivered to the process, it prints the pretty stack trace.
raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
#define LLVM_ATTRIBUTE_UNUSED
void RestorePrettyStackState(const void *State)
Restores the topmost element of the "pretty" stack state to State, which should come from a previous ...
PrettyStackTraceEntry - This class is used to represent a frame of the "pretty" stack trace that is d...
#define LLVM_THREAD_LOCAL
\macro LLVM_THREAD_LOCAL A thread-local storage specifier which can be used with globals,...
void SetInfoSignalFunction(void(*Handler)())
Registers a function to be called when an "info" signal is delivered to the process.
void print(raw_ostream &OS) const override
print - Emit information about this stack frame to OS.
PrettyStackTraceEntry * ReverseStackTrace(PrettyStackTraceEntry *Head)
static void PrintStack(raw_ostream &OS)
This class implements an extremely fast bulk output stream that can only output to a stream.
static volatile std::atomic< unsigned > GlobalSigInfoGenerationCounter
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
virtual ~PrettyStackTraceEntry()
static LLVM_THREAD_LOCAL unsigned ThreadLocalSigInfoGenerationCounter
AMD64 Optimization Manual has some nice information about optimizing integer multiplication by a constant How much of it applies to Intel s X86 implementation There are definite trade offs to xmm0 cvttss2siq rdx jb L3 subss xmm0 rax cvttss2siq rdx xorq rdx rax ret instead of xmm1 cvttss2siq rcx movaps xmm2 subss xmm2 cvttss2siq rax rdx xorq rax ucomiss xmm0 cmovb rax ret Seems like the jb branch has high likelihood of being taken It would have saved a few instructions It s not possible to reference and DH registers in an instruction requiring REX prefix divb and mulb both produce results in AH If isel emits a CopyFromReg which gets turned into a movb and that can be allocated a r8b r15b To get around isel emits a CopyFromReg from AX and then right shift it down by and truncate it It s not pretty but it works We need some register allocation magic to make the hack go which would often require a callee saved register Callees usually need to keep this value live for most of their body so it doesn t add a significant burden on them We currently implement this in however this is suboptimal because it means that it would be quite awkward to implement the optimization for callers A better implementation would be to relax the LLVM IR rules for sret arguments to allow a function with an sret argument to have a non void return type
const void * SavePrettyStackState()
Returns the topmost element of the "pretty" stack state.
void print(raw_ostream &OS) const override
print - Emit information about this stack frame to OS.
the multiplication has a latency of four as opposed to two cycles for the movl lea variant It appears gcc place string data with linkonce linkage in section coalesced instead of section __DATA
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())
static bool RegisterCrashPrinter()
if(llvm_vc STREQUAL "") set(fake_version_inc "$
A utility class that uses RAII to save and restore the value of a variable.
static void setCrashLogMessage(const char *msg) LLVM_ATTRIBUTE_UNUSED
const CustomOperand< const MCSubtargetInfo & > Msg[]
void setBugReportMsg(const char *Msg)
Replaces the generic bug report message that is output upon a crash.
static LLVM_ATTRIBUTE_NOINLINE void PrintCurStackTrace(raw_ostream &OS)
Print the current stack trace to the specified stream.
const char * getBugReportMsg()
Get the bug report message that will be output upon a crash.
#define LLVM_ATTRIBUTE_NOINLINE
LLVM_ATTRIBUTE_NOINLINE - On compilers where we have a directive to do so, mark a method "not for inl...
static void printForSigInfoIfNeeded()
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...
static LLVM_THREAD_LOCAL PrettyStackTraceEntry * PrettyStackTraceHead
void EnablePrettyStackTrace()
Enables dumping a "pretty" stack trace when the program crashes.