#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "chrome/renderer/v8_unwinder.h"
#include <algorithm>
#include <memory>
#include <utility>
#include "base/check_op.h"
#include "build/build_config.h"
#include "v8/include/v8-isolate.h"
#if defined(ARCH_CPU_ARM_FAMILY) && defined(ARCH_CPU_32_BITS)
#define V8_TARGET_ARCH_ARM …
#include "v8/include/v8-unwinder-state.h"
#endif
namespace {
class V8Module : public base::ModuleCache::Module { … };
struct MemoryRangeModuleCompare { … };
v8::MemoryRange GetEmbeddedCodeRange(v8::Isolate* isolate) { … }
void CopyCalleeSavedRegisterFromRegisterContext(
const base::RegisterContext& register_context,
v8::CalleeSavedRegisters* callee_saved_registers) { … }
void CopyCalleeSavedRegisterToRegisterContext(
const v8::CalleeSavedRegisters* callee_saved_registers,
base::RegisterContext& register_context) { … }
}
V8Unwinder::V8Unwinder(v8::Isolate* isolate)
: … { … }
V8Unwinder::~V8Unwinder() = default;
void V8Unwinder::InitializeModules() { … }
std::unique_ptr<base::UnwinderStateCapture>
V8Unwinder::CreateUnwinderStateCapture() { … }
void V8Unwinder::OnStackCapture(base::UnwinderStateCapture* capture_state) { … }
void V8Unwinder::UpdateModules(base::UnwinderStateCapture* capture_state) { … }
bool V8Unwinder::CanUnwindFrom(const base::Frame& current_frame) const { … }
base::UnwindResult V8Unwinder::TryUnwind(
base::UnwinderStateCapture* capture_state,
base::RegisterContext* thread_context,
uintptr_t stack_top,
std::vector<base::Frame>* stack) { … }
size_t V8Unwinder::CopyCodePages(size_t capacity, v8::MemoryRange* code_pages) { … }
const char V8Unwinder::kV8EmbeddedCodeRangeBuildId[] = …;
const char V8Unwinder::kV8CodeRangeBuildId[] = …;
V8Unwinder::MemoryRanges::MemoryRanges(size_t size)
: … { … }
V8Unwinder::MemoryRanges::MemoryRanges::~MemoryRanges() = default;
void V8Unwinder::MemoryRanges::ShrinkSize(size_t size) { … }
bool V8Unwinder::ModuleCompare::operator()(
const base::ModuleCache::Module* a,
const base::ModuleCache::Module* b) const { … }