#include "gwp_asan/common.h"
#include "gwp_asan/crash_handler.h"
#include "gwp_asan/guarded_pool_allocator.h"
#include "gwp_asan/optional/segv_handler.h"
#include "gwp_asan/options.h"
#ifndef __STDC_FORMAT_MACROS
#define __STDC_FORMAT_MACROS …
#endif
#include <assert.h>
#include <inttypes.h>
#include <signal.h>
#include <stdio.h>
AllocationMetadata;
Error;
GuardedPoolAllocator;
Printf_t;
PrintBacktrace_t;
SegvBacktrace_t;
namespace {
struct ScopedEndOfReportDecorator { … };
void printHeader(Error E, uintptr_t AccessPtr,
const gwp_asan::AllocationMetadata *Metadata,
Printf_t Printf) { … }
static bool HasReportedBadPoolAccess = …;
static const char *kUnknownCrashText = …;
void dumpReport(uintptr_t ErrorPtr, const gwp_asan::AllocatorState *State,
const gwp_asan::AllocationMetadata *Metadata,
SegvBacktrace_t SegvBacktrace, Printf_t Printf,
PrintBacktrace_t PrintBacktrace, void *Context) { … }
struct sigaction PreviousHandler;
bool SignalHandlerInstalled;
bool RecoverableSignal;
gwp_asan::GuardedPoolAllocator *GPAForSignalHandler;
Printf_t PrintfForSignalHandler;
PrintBacktrace_t PrintBacktraceForSignalHandler;
SegvBacktrace_t BacktraceForSignalHandler;
static void sigSegvHandler(int sig, siginfo_t *info, void *ucontext) { … }
}
namespace gwp_asan {
namespace segv_handler {
void installSignalHandlers(gwp_asan::GuardedPoolAllocator *GPA, Printf_t Printf,
PrintBacktrace_t PrintBacktrace,
SegvBacktrace_t SegvBacktrace, bool Recoverable) { … }
void uninstallSignalHandlers() { … }
}
}