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 : uint16_t {
47};
48
49// The output structure filled up by GetStackSample API function.
50struct SampleInfo {
51 size_t frames_count; // Number of frames collected.
52 void* external_callback_entry; // External callback address if VM is
53 // executing an external callback.
54 void* context; // Incumbent native context address.
55 void* embedder_context; // Native context address for embedder state
56 StateTag vm_state; // Current VM state.
57 EmbedderStateTag embedder_state; // Current Embedder state
58};
59
61 const void* start = nullptr;
62 size_t length_in_bytes = 0;
63};
64
67};
68
73};
74
81 public:
112 static bool TryUnwindV8Frames(const JSEntryStubs& entry_stubs,
113 size_t code_pages_length,
114 const MemoryRange* code_pages,
115 RegisterState* register_state,
116 const void* stack_base);
117
127 static bool PCIsInV8(size_t code_pages_length, const MemoryRange* code_pages,
128 void* pc);
129};
130
131} // namespace v8
132
133#endif // INCLUDE_V8_UNWINDER_H_
Definition: v8-unwinder.h:80
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)
Definition: libplatform.h:15
EmbedderStateTag
Definition: v8-embedder-state-scope.h:22
StateTag
Definition: v8-unwinder.h:36
@ COMPILER
Definition: v8-unwinder.h:41
@ BYTECODE_COMPILER
Definition: v8-unwinder.h:40
@ EXTERNAL
Definition: v8-unwinder.h:43
@ GC
Definition: v8-unwinder.h:38
@ ATOMICS_WAIT
Definition: v8-unwinder.h:44
@ PARSER
Definition: v8-unwinder.h:39
@ LOGGING
Definition: v8-unwinder.h:46
@ IDLE
Definition: v8-unwinder.h:45
@ JS
Definition: v8-unwinder.h:37
@ OTHER
Definition: v8-unwinder.h:42
Definition: v8-unwinder.h:65
MemoryRange code
Definition: v8-unwinder.h:66
Definition: v8-unwinder.h:69
JSEntryStub js_entry_stub
Definition: v8-unwinder.h:70
JSEntryStub js_construct_entry_stub
Definition: v8-unwinder.h:71
JSEntryStub js_run_microtasks_entry_stub
Definition: v8-unwinder.h:72
Definition: v8-unwinder.h:60
size_t length_in_bytes
Definition: v8-unwinder.h:62
const void * start
Definition: v8-unwinder.h:61
Definition: v8-unwinder.h:21
RegisterState(const RegisterState &other)
void * lr
Definition: v8-unwinder.h:30
RegisterState & operator=(const RegisterState &other)
void * sp
Definition: v8-unwinder.h:28
void * pc
Definition: v8-unwinder.h:27
void * fp
Definition: v8-unwinder.h:29
std::unique_ptr< CalleeSavedRegisters > callee_saved
Definition: v8-unwinder.h:32
Definition: v8-unwinder.h:50
void * context
Definition: v8-unwinder.h:54
EmbedderStateTag embedder_state
Definition: v8-unwinder.h:57
void * embedder_context
Definition: v8-unwinder.h:55
size_t frames_count
Definition: v8-unwinder.h:51
void * external_callback_entry
Definition: v8-unwinder.h:52
StateTag vm_state
Definition: v8-unwinder.h:56
#define V8_EXPORT
Definition: v8config.h:793