chromium/chrome/renderer/v8_unwinder.cc

// Copyright 2019 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/40285824): Remove this and convert code to safer constructs.
#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)
// V8 requires the embedder to establish the architecture define.
#define V8_TARGET_ARCH_ARM
#include "v8/include/v8-unwinder-state.h"
#endif

namespace {

class V8Module : public base::ModuleCache::Module {};

// Heterogeneous comparator for MemoryRanges and Modules. Compares on both
// base address and size because the module sizes can be updated while the
// base address remains the same.
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) {}

}  // namespace

V8Unwinder::V8Unwinder(v8::Isolate* isolate)
    :{}

V8Unwinder::~V8Unwinder() = default;

void V8Unwinder::InitializeModules() {}

std::unique_ptr<base::UnwinderStateCapture>
V8Unwinder::CreateUnwinderStateCapture() {}

// IMPORTANT NOTE: to avoid deadlock this function must not invoke any
// non-reentrant code that is also invoked by the target thread. In particular,
// no heap allocation or deallocation is permitted, including indirectly via use
// of DCHECK/CHECK or other logging statements.
void V8Unwinder::OnStackCapture(base::UnwinderStateCapture* capture_state) {}

// Update the modules based on what was recorded in |code_ranges_|. The singular
// embedded code range was already added in in InitializeModules(). It is
// preserved by the algorithm below, which is why kNonEmbedded is
// unconditionally passed when creating new modules.
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) {}

// Synthetic build ids to use for V8 modules. The difference is in the digit
// after the leading 5's.
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 {}