v8 10.2.154 (node 18.16.0)
V8 is Google's open source JavaScript engine
Loading...
Searching...
No Matches
v8-unwinder.h
Go to the documentation of this file.
1// Copyright 2021 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef INCLUDE_V8_UNWINDER_H_
6#define INCLUDE_V8_UNWINDER_H_
7
8#include <memory>
9
10#include "v8-embedder-state-scope.h" // NOLINT(build/include_directory)
11#include "v8config.h" // NOLINT(build/include_directory)
12
13namespace v8 {
14// Holds the callee saved registers needed for the stack unwinder. It is the
15// empty struct if no registers are required. Implemented in
16// include/v8-unwinder-state.h.
17struct CalleeSavedRegisters;
18
19// A RegisterState represents the current state of registers used
20// by the sampling profiler API.
26
27 void* pc; // Instruction pointer.
28 void* sp; // Stack pointer.
29 void* fp; // Frame pointer.
30 void* lr; // Link register (or nullptr on platforms without a link register).
31 // Callee saved registers (or null if no callee saved registers were stored)
32 std::unique_ptr<CalleeSavedRegisters> callee_saved;
33};
34
35// A StateTag represents a possible state of the VM.
36enum StateTag : int {
45 IDLE
46};
47
48// The output structure filled up by GetStackSample API function.
49struct SampleInfo {
50 size_t frames_count; // Number of frames collected.
51 void* external_callback_entry; // External callback address if VM is
52 // executing an external callback.
53 void* context; // Incumbent native context address.
54 void* embedder_context; // Native context address for embedder state
55 StateTag vm_state; // Current VM state.
56 EmbedderStateTag embedder_state; // Current Embedder state
57};
58
60 const void* start = nullptr;
61 size_t length_in_bytes = 0;
62};
63
66};
67
72};
73
80 public:
111 static bool TryUnwindV8Frames(const JSEntryStubs& entry_stubs,
112 size_t code_pages_length,
113 const MemoryRange* code_pages,
114 RegisterState* register_state,
115 const void* stack_base);
116
126 static bool PCIsInV8(size_t code_pages_length, const MemoryRange* code_pages,
127 void* pc);
128};
129
130} // namespace v8
131
132#endif // INCLUDE_V8_UNWINDER_H_
static bool PCIsInV8(size_t code_pages_length, const MemoryRange *code_pages, void *pc)
static bool TryUnwindV8Frames(const JSEntryStubs &entry_stubs, size_t code_pages_length, const MemoryRange *code_pages, RegisterState *register_state, const void *stack_base)
StateTag
Definition v8-unwinder.h:36
@ PARSER
Definition v8-unwinder.h:39
@ COMPILER
Definition v8-unwinder.h:41
@ EXTERNAL
Definition v8-unwinder.h:43
@ JS
Definition v8-unwinder.h:37
@ BYTECODE_COMPILER
Definition v8-unwinder.h:40
@ OTHER
Definition v8-unwinder.h:42
@ GC
Definition v8-unwinder.h:38
@ ATOMICS_WAIT
Definition v8-unwinder.h:44
@ IDLE
Definition v8-unwinder.h:45
Definition v8-unwinder.h:64
MemoryRange code
Definition v8-unwinder.h:65
Definition v8-unwinder.h:68
JSEntryStub js_construct_entry_stub
Definition v8-unwinder.h:70
JSEntryStub js_entry_stub
Definition v8-unwinder.h:69
JSEntryStub js_run_microtasks_entry_stub
Definition v8-unwinder.h:71
const void * start
Definition v8-unwinder.h:60
size_t length_in_bytes
Definition v8-unwinder.h:61
std::unique_ptr< CalleeSavedRegisters > callee_saved
Definition v8-unwinder.h:32
RegisterState(const RegisterState &other)
RegisterState & operator=(const RegisterState &other)
EmbedderStateTag embedder_state
Definition v8-unwinder.h:56
void * embedder_context
Definition v8-unwinder.h:54
StateTag vm_state
Definition v8-unwinder.h:55
void * external_callback_entry
Definition v8-unwinder.h:51
size_t frames_count
Definition v8-unwinder.h:50
#define V8_EXPORT
Definition v8config.h:578