v8  8.4.371(node14.15.0)
V8 is Google's open source JavaScript engine
Unwinder Class Reference

#include <v8.h>

Static Public Member Functions

static bool TryUnwindV8Frames (const UnwindState &unwind_state, RegisterState *register_state, const void *stack_base)
 
static bool TryUnwindV8Frames (const JSEntryStubs &entry_stubs, size_t code_pages_length, const MemoryRange *code_pages, RegisterState *register_state, const void *stack_base)
 
static bool PCIsInV8 (const UnwindState &unwind_state, void *pc)
 
static bool PCIsInV8 (size_t code_pages_length, const MemoryRange *code_pages, void *pc)
 

Detailed Description

Various helpers for skipping over V8 frames in a given stack.

The unwinder API is only supported on the x64, ARM64 and ARM32 architectures.

Definition at line 10611 of file v8.h.

Member Function Documentation

◆ PCIsInV8() [1/2]

static bool PCIsInV8 ( const UnwindState unwind_state,
void *  pc 
)
static

Whether the PC is within the V8 code range represented by code_range or embedded_code_range in |unwind_state|.

If this returns false, then calling UnwindV8Frames() with the same PC and unwind_state will always fail. If it returns true, then unwinding may (but not necessarily) be successful.

◆ PCIsInV8() [2/2]

static bool PCIsInV8 ( size_t  code_pages_length,
const MemoryRange code_pages,
void *  pc 
)
static

The same as above, but is available on x64, ARM64 and ARM32. See the comment on TryUnwindV8Frames.

◆ TryUnwindV8Frames() [1/2]

static bool TryUnwindV8Frames ( const JSEntryStubs entry_stubs,
size_t  code_pages_length,
const MemoryRange code_pages,
RegisterState register_state,
const void *  stack_base 
)
static

The same as above, but is available on x64, ARM64 and ARM32.

Parameters
code_pagesA list of all of the ranges in which V8 has allocated executable code. The caller should obtain this list by calling Isolate::CopyCodePages() during the same interrupt/thread suspension that captures the stack.

◆ TryUnwindV8Frames() [2/2]

static bool TryUnwindV8Frames ( const UnwindState unwind_state,
RegisterState register_state,
const void *  stack_base 
)
static

Attempt to unwind the stack to the most recent C++ frame. This function is signal-safe and does not access any V8 state and thus doesn't require an Isolate.

The unwinder needs to know the location of the JS Entry Stub (a piece of code that is run when C++ code calls into generated JS code). This is used for edge cases where the current frame is being constructed or torn down when the stack sample occurs.

The unwinder also needs the virtual memory range of all possible V8 code objects. There are two ranges required - the heap code range and the range for code embedded in the binary. The V8 API provides all required inputs via an UnwindState object through the Isolate::GetUnwindState() API. These values will not change after Isolate initialization, so the same |unwind_state| can be used for multiple calls.

Parameters
unwind_stateInput state for the Isolate that the stack comes from.
register_stateThe current registers. This is an in-out param that will be overwritten with the register values after unwinding, on success.
stack_baseThe resulting stack pointer and frame pointer values are bounds-checked against the stack_base and the original stack pointer value to ensure that they are valid locations in the given stack. If these values or any intermediate frame pointer values used during unwinding are ever out of these bounds, unwinding will fail.
Returns
True on success.

The documentation for this class was generated from the following file: