#include "llvm/Support/PrettyStackTrace.h"
#include "llvm-c/ErrorHandling.h"
#include "llvm/Config/config.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/SaveAndRestore.h"
#include "llvm/Support/Signals.h"
#include "llvm/Support/Watchdog.h"
#include "llvm/Support/raw_ostream.h"
#ifdef __APPLE__
#include "llvm/ADT/SmallString.h"
#endif
#include <atomic>
#include <cassert>
#include <cstdarg>
#include <cstdio>
#include <cstring>
#include <tuple>
#ifdef HAVE_CRASHREPORTERCLIENT_H
#include <CrashReporterClient.h>
#endif
usingnamespacellvm;
static const char *BugReportMsg = …;
#if ENABLE_BACKTRACES
static LLVM_THREAD_LOCAL PrettyStackTraceEntry *PrettyStackTraceHead = …;
static volatile std::atomic<unsigned> GlobalSigInfoGenerationCounter = …;
static LLVM_THREAD_LOCAL unsigned ThreadLocalSigInfoGenerationCounter = …;
namespace llvm {
PrettyStackTraceEntry *ReverseStackTrace(PrettyStackTraceEntry *Head) { … }
}
static void PrintStack(raw_ostream &OS) { … }
LLVM_ATTRIBUTE_NOINLINE
static void PrintCurStackTrace(raw_ostream &OS) { … }
#if defined (__APPLE__) && defined(HAVE_CRASHREPORTERCLIENT_H)
extern "C" {
CRASH_REPORTER_CLIENT_HIDDEN
struct crashreporter_annotations_t gCRAnnotations
__attribute__((section("__DATA," CRASHREPORTER_ANNOTATIONS_SECTION)))
#if CRASHREPORTER_ANNOTATIONS_VERSION < 5
= { CRASHREPORTER_ANNOTATIONS_VERSION, 0, 0, 0, 0, 0, 0 };
#else
= { CRASHREPORTER_ANNOTATIONS_VERSION, 0, 0, 0, 0, 0, 0, 0 };
#endif
}
#elif defined(__APPLE__) && HAVE_CRASHREPORTER_INFO
extern "C" const char *__crashreporter_info__
__attribute__((visibility("hidden"))) = 0;
asm(".desc ___crashreporter_info__, 0x10");
#endif
static void setCrashLogMessage(const char *msg) LLVM_ATTRIBUTE_UNUSED;
static void setCrashLogMessage(const char *msg) { … }
#ifdef __APPLE__
using CrashHandlerString = SmallString<2048>;
using CrashHandlerStringStorage = std::byte[sizeof(CrashHandlerString)];
alignas(CrashHandlerString) static CrashHandlerStringStorage
crashHandlerStringStorage;
#endif
static void CrashHandler(void *) { … }
static void printForSigInfoIfNeeded() { … }
#endif
void llvm::setBugReportMsg(const char *Msg) { … }
const char *llvm::getBugReportMsg() { … }
PrettyStackTraceEntry::PrettyStackTraceEntry() { … }
PrettyStackTraceEntry::~PrettyStackTraceEntry() { … }
void PrettyStackTraceString::print(raw_ostream &OS) const { … }
PrettyStackTraceFormat::PrettyStackTraceFormat(const char *Format, ...) { … }
void PrettyStackTraceFormat::print(raw_ostream &OS) const { … }
void PrettyStackTraceProgram::print(raw_ostream &OS) const { … }
#if ENABLE_BACKTRACES
static bool RegisterCrashPrinter() { … }
#endif
void llvm::EnablePrettyStackTrace() { … }
void llvm::EnablePrettyStackTraceOnSigInfoForThisThread(bool ShouldEnable) { … }
const void *llvm::SavePrettyStackState() { … }
void llvm::RestorePrettyStackState(const void *Top) { … }
void LLVMEnablePrettyStackTrace() { … }