LLVM  10.0.0svn
Namespaces | Functions | Variables
PrettyStackTrace.cpp File Reference
#include "llvm/Support/PrettyStackTrace.h"
#include "llvm-c/ErrorHandling.h"
#include "llvm/ADT/SmallString.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"
#include <atomic>
#include <cstdarg>
#include <cstdio>
#include <tuple>
Include dependency graph for PrettyStackTrace.cpp:

Go to the source code of this file.


 This class represents lattice values for constants.


PrettyStackTraceEntryllvm::ReverseStackTrace (PrettyStackTraceEntry *Head)
static void PrintStack (raw_ostream &OS)
static LLVM_ATTRIBUTE_NOINLINE void PrintCurStackTrace (raw_ostream &OS)
 Print the current stack trace to the specified stream. More...
static void setCrashLogMessage (const char *msg) LLVM_ATTRIBUTE_UNUSED
static void CrashHandler (void *)
 This callback is run if a fatal signal is delivered to the process, it prints the pretty stack trace. More...
static void printForSigInfoIfNeeded ()
static bool RegisterCrashPrinter ()
void LLVMEnablePrettyStackTrace ()
 Enable LLVM's built-in stack trace code. More...


static LLVM_THREAD_LOCAL PrettyStackTraceEntryPrettyStackTraceHead = nullptr
static volatile std::atomic< unsignedGlobalSigInfoGenerationCounter
static LLVM_THREAD_LOCAL unsigned ThreadLocalSigInfoGenerationCounter = 0

Function Documentation

◆ CrashHandler()

static void CrashHandler ( void *  )

This callback is run if a fatal signal is delivered to the process, it prints the pretty stack trace.

Definition at line 146 of file PrettyStackTrace.cpp.

References llvm::errs(), PrintCurStackTrace(), and setCrashLogMessage().

Referenced by RegisterCrashPrinter().

◆ LLVMEnablePrettyStackTrace()

void LLVMEnablePrettyStackTrace ( void  )

Enable LLVM's built-in stack trace code.

This intercepts the OS's crash signals and prints which component of LLVM you were in at the time if the crash.

Definition at line 298 of file PrettyStackTrace.cpp.

References llvm::EnablePrettyStackTrace().

◆ PrintCurStackTrace()

static LLVM_ATTRIBUTE_NOINLINE void PrintCurStackTrace ( raw_ostream OS)

Print the current stack trace to the specified stream.

Marked NOINLINE so it can be called from debuggers.

Definition at line 93 of file PrettyStackTrace.cpp.

References llvm::raw_ostream::flush(), LLVM_ATTRIBUTE_UNUSED, PrettyStackTraceHead, PrintStack(), and setCrashLogMessage().

Referenced by CrashHandler(), and printForSigInfoIfNeeded().

◆ printForSigInfoIfNeeded()

static void printForSigInfoIfNeeded ( )

◆ PrintStack()

static void PrintStack ( raw_ostream OS)

Definition at line 72 of file PrettyStackTrace.cpp.

References PrettyStackTraceHead, and llvm::ReverseStackTrace().

Referenced by PrintCurStackTrace().

◆ RegisterCrashPrinter()

static bool RegisterCrashPrinter ( )

Definition at line 247 of file PrettyStackTrace.cpp.

References llvm::sys::AddSignalHandler(), and CrashHandler().

Referenced by llvm::EnablePrettyStackTrace().

◆ setCrashLogMessage()

static void setCrashLogMessage ( const char msg)

Definition at line 125 of file PrettyStackTrace.cpp.

Referenced by CrashHandler(), and PrintCurStackTrace().

Variable Documentation

◆ GlobalSigInfoGenerationCounter

volatile std::atomic<unsigned> GlobalSigInfoGenerationCounter
Initial value:

Definition at line 58 of file PrettyStackTrace.cpp.

Referenced by llvm::EnablePrettyStackTraceOnSigInfoForThisThread(), and printForSigInfoIfNeeded().

◆ PrettyStackTraceHead

LLVM_THREAD_LOCAL PrettyStackTraceEntry* PrettyStackTraceHead = nullptr

◆ ThreadLocalSigInfoGenerationCounter

LLVM_THREAD_LOCAL unsigned ThreadLocalSigInfoGenerationCounter = 0