#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "components/gwp_asan/crash_handler/crash_analyzer.h"
#include <stddef.h>
#include <algorithm>
#include <limits>
#include <memory>
#include <optional>
#include <string>
#include <vector>
#include "base/logging.h"
#include "base/metrics/histogram_macros.h"
#include "base/process/process_metrics.h"
#include "base/strings/string_number_conversions.h"
#include "build/build_config.h"
#include "components/gwp_asan/common/allocator_state.h"
#include "components/gwp_asan/common/crash_key_name.h"
#include "components/gwp_asan/common/pack_stack_trace.h"
#include "components/gwp_asan/crash_handler/crash.pb.h"
#include "third_party/crashpad/crashpad/client/annotation.h"
#include "third_party/crashpad/crashpad/snapshot/cpu_architecture.h"
#include "third_party/crashpad/crashpad/snapshot/cpu_context.h"
#include "third_party/crashpad/crashpad/snapshot/exception_snapshot.h"
#include "third_party/crashpad/crashpad/snapshot/module_snapshot.h"
#include "third_party/crashpad/crashpad/snapshot/process_snapshot.h"
#include "third_party/crashpad/crashpad/util/process/process_memory.h"
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID)
#include <signal.h>
#elif BUILDFLAG(IS_APPLE)
#include <mach/exception_types.h>
#elif BUILDFLAG(IS_WIN)
#include <windows.h>
#endif
namespace gwp_asan {
namespace internal {
namespace {
void ReportHistogram(Crash_Allocator allocator,
GwpAsanCrashAnalysisResult result) { … }
}
GetMetadataReturnType;
bool CrashAnalyzer::GetExceptionInfo(
const crashpad::ProcessSnapshot& process_snapshot,
gwp_asan::Crash* proto) { … }
crashpad::VMAddress CrashAnalyzer::GetAccessAddress(
const crashpad::ExceptionSnapshot& exception) { … }
crashpad::VMAddress CrashAnalyzer::GetStateAddress(
const crashpad::ProcessSnapshot& process_snapshot,
const char* annotation_name) { … }
template <typename T>
bool CrashAnalyzer::GetState(const crashpad::ProcessSnapshot& process_snapshot,
const char* crash_key,
Crash_Allocator allocator,
T* state) { … }
bool CrashAnalyzer::AnalyzeLightweightDetectorCrash(
const crashpad::ProcessSnapshot& process_snapshot,
gwp_asan::Crash* proto) { … }
bool CrashAnalyzer::AnalyzeCrashedAllocator(
const crashpad::ProcessSnapshot& process_snapshot,
const char* crash_key,
Crash_Allocator allocator,
gwp_asan::Crash* proto) { … }
void CrashAnalyzer::ReadAllocationInfo(
const uint8_t* stack_trace,
size_t stack_trace_offset,
const AllocationInfo& slot_info,
gwp_asan::Crash_AllocationInfo* proto_info) { … }
Crash_Mode CrashAnalyzer::LightweightDetectorModeToGwpAsanMode(
LightweightDetectorMode mode) { … }
}
}