forked from chakra-core/ChakraCore
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDiagStackFrame.h
More file actions
128 lines (111 loc) · 5.42 KB
/
DiagStackFrame.h
File metadata and controls
128 lines (111 loc) · 5.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
//-------------------------------------------------------------------------------------------------------
// Copyright (C) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------
#pragma once
namespace Js
{
class DiagNativeStackFrame;
//
// Unified stack frame used by debugger (F12, inside VS)
// -- interpreter or native stack frame.
//
class DiagStackFrame
{
public:
virtual ~DiagStackFrame() {}
virtual JavascriptFunction* GetJavascriptFunction() = 0;
virtual int GetByteCodeOffset() = 0;
virtual DWORD_PTR GetStackAddress() = 0;
virtual Var GetRegValue(RegSlot slotId, bool allowTemp = false) = 0;
virtual Var GetNonVarRegValue(RegSlot slotId) = 0;
virtual void SetRegValue(RegSlot slotId, Var value) = 0;
virtual Var GetArgumentsObject() = 0;
virtual Var CreateHeapArguments() = 0;
virtual ScriptContext* GetScriptContext();
virtual PCWSTR GetDisplayName();
virtual bool IsInterpreterFrame();
virtual InterpreterStackFrame* AsInterpreterFrame();
virtual ArenaAllocator * GetArena();
virtual FrameDisplay * GetFrameDisplay();
virtual Var GetScopeObjectFromFrameDisplay(uint index);
virtual Var GetRootObject();
virtual Var GetInnerScopeFromRegSlot(RegSlot location);
bool IsTopFrame();
void SetIsTopFrame();
ScriptFunction* GetScriptFunction();
FunctionBody* GetFunction();
BOOL IsStrictMode();
BOOL IsThisAvailable();
Js::Var GetThisFromFrame(Js::IDiagObjectAddress ** ppOutAddress, Js::IDiagObjectModelWalkerBase * localsWalker = nullptr);
// This function will try to populate obj and address field of the ResolvedObject.
void TryFetchValueAndAddress(const char16 *source, int sourceLength, Js::ResolvedObject * pObj);
Js::ScriptFunction* TryGetFunctionForEval(Js::ScriptContext* scriptContext, const char16 *source, int sourceLength, BOOL isLibraryCode = FALSE);
void EvaluateImmediate(const char16 *source, int sourceLength, BOOL isLibraryCode, Js::ResolvedObject * pObj);
Js::Var DoEval(Js::ScriptFunction* pfuncScript);
protected:
DiagStackFrame();
private:
bool isTopFrame;
};
class DiagInterpreterStackFrame : public DiagStackFrame
{
InterpreterStackFrame* m_interpreterFrame;
public:
DiagInterpreterStackFrame(InterpreterStackFrame* frame);
virtual JavascriptFunction* GetJavascriptFunction() override;
virtual ScriptContext* GetScriptContext() override;
virtual int GetByteCodeOffset() override;
virtual DWORD_PTR GetStackAddress() override;
virtual bool IsInterpreterFrame() override;
virtual InterpreterStackFrame* AsInterpreterFrame() override;
virtual Var GetRegValue(RegSlot slotId, bool allowTemp = false) override;
virtual Var GetNonVarRegValue(RegSlot slotId) override;
virtual void SetRegValue(RegSlot slotId, Var value) override;
virtual Var GetArgumentsObject() override;
virtual Var CreateHeapArguments() override;
virtual FrameDisplay * GetFrameDisplay() override;
virtual Var GetInnerScopeFromRegSlot(RegSlot location) override;
};
#if ENABLE_NATIVE_CODEGEN
class DiagNativeStackFrame : public DiagStackFrame
{
ScriptFunction* m_function;
int m_byteCodeOffset;
void* m_stackAddr;
int32 m_localVarSlotsOffset; // the offset on the native stack frame where the locals are residing.
int32 m_localVarChangedOffset; // The offset which stores if any locals is changed from the debugger.
static const int32 InvalidOffset = -1;
public:
DiagNativeStackFrame(ScriptFunction* function, int byteCodeOffset, void* stackAddr, void *codeAddr);
virtual JavascriptFunction* GetJavascriptFunction() override;
virtual ScriptContext* GetScriptContext() override;
virtual int GetByteCodeOffset() override;
virtual DWORD_PTR GetStackAddress() override;
virtual Var GetRegValue(RegSlot slotId, bool allowTemp = false) override;
virtual Var GetNonVarRegValue(RegSlot slotId) override;
virtual void SetRegValue(RegSlot slotId, Var value) override;
virtual Var GetArgumentsObject() override;
virtual Var CreateHeapArguments() override;
private:
Var * GetSlotOffsetLocation(RegSlot slotId, bool allowTemp = false);
};
#endif
class DiagRuntimeStackFrame : public DiagStackFrame
{
JavascriptFunction* m_function;
PCWSTR m_displayName;
void* m_stackAddr;
public:
DiagRuntimeStackFrame(JavascriptFunction* function, PCWSTR displayName, void* stackAddr);
virtual JavascriptFunction* GetJavascriptFunction() override;
virtual int GetByteCodeOffset() override;
virtual DWORD_PTR GetStackAddress() override;
virtual Var GetRegValue(RegSlot slotId, bool allowTemp = false) override;
virtual Var GetNonVarRegValue(RegSlot slotId) override;
virtual void SetRegValue(RegSlot slotId, Var value) override;
virtual Var GetArgumentsObject() override;
virtual Var CreateHeapArguments() override;
virtual PCWSTR GetDisplayName() override;
};
}