Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
127 lines (109 loc) · 4.43 KB

File metadata and controls

127 lines (109 loc) · 4.43 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
//-------------------------------------------------------------------------------------------------------
// Copyright (C) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------
#include "JsrtPch.h"
#ifdef ENABLE_SCRIPT_DEBUGGING
#include "JsrtDebugEventObject.h"
#include "RuntimeDebugPch.h"
#include "screrror.h" // For CompileScriptException
JsrtDebugEventObject::JsrtDebugEventObject(Js::ScriptContext *scriptContext)
{
Assert(scriptContext != nullptr);
this->scriptContext = scriptContext;
this->eventDataObject = scriptContext->GetLibrary()->CreateObject();
Assert(this->eventDataObject != nullptr);
}
JsrtDebugEventObject::~JsrtDebugEventObject()
{
this->eventDataObject = nullptr;
this->scriptContext = nullptr;
}
Js::DynamicObject* JsrtDebugEventObject::GetEventDataObject()
{
return this->eventDataObject;
}
JsrtDebugDocumentManager::JsrtDebugDocumentManager(JsrtDebugManager* jsrtDebugManager) :
breakpointDebugDocumentDictionary(nullptr)
{
Assert(jsrtDebugManager != nullptr);
this->jsrtDebugManager = jsrtDebugManager;
}
JsrtDebugDocumentManager::~JsrtDebugDocumentManager()
{
if (this->breakpointDebugDocumentDictionary != nullptr)
{
AssertMsg(this->breakpointDebugDocumentDictionary->Count() == 0, "Should have cleared all entries by now?");
Adelete(this->jsrtDebugManager->GetDebugObjectArena(), this->breakpointDebugDocumentDictionary);
this->breakpointDebugDocumentDictionary = nullptr;
}
this->jsrtDebugManager = nullptr;
}
void JsrtDebugDocumentManager::AddDocument(UINT bpId, Js::DebugDocument * debugDocument)
{
BreakpointDebugDocumentDictionary* breakpointDebugDocumentDictionary = this->GetBreakpointDictionary();
Assert(!breakpointDebugDocumentDictionary->ContainsKey(bpId));
breakpointDebugDocumentDictionary->Add(bpId, debugDocument);
}
void JsrtDebugDocumentManager::ClearDebugDocument(Js::ScriptContext * scriptContext)
{
if (scriptContext != nullptr)
{
scriptContext->MapScript([&](Js::Utf8SourceInfo* sourceInfo)
{
if (sourceInfo->HasDebugDocument())
{
Js::DebugDocument* debugDocument = sourceInfo->GetDebugDocument();
// Remove the debugdocument from breakpoint dictionary
if (this->breakpointDebugDocumentDictionary != nullptr)
{
this->breakpointDebugDocumentDictionary->MapAndRemoveIf([&](JsUtil::SimpleDictionaryEntry<UINT, Js::DebugDocument *> keyValue)
{
if (keyValue.Value() != nullptr && keyValue.Value() == debugDocument)
{
return true;
}
return false;
});
}
debugDocument->GetUtf8SourceInfo()->ClearDebugDocument();
HeapDelete(debugDocument);
debugDocument = nullptr;
}
});
}
}
void JsrtDebugDocumentManager::ClearBreakpointDebugDocumentDictionary()
{
if (this->breakpointDebugDocumentDictionary != nullptr)
{
this->breakpointDebugDocumentDictionary->Clear();
}
}
bool JsrtDebugDocumentManager::RemoveBreakpoint(UINT breakpointId)
{
if (this->breakpointDebugDocumentDictionary != nullptr)
{
BreakpointDebugDocumentDictionary* breakpointDebugDocumentDictionary = this->GetBreakpointDictionary();
Js::DebugDocument* debugDocument = nullptr;
if (breakpointDebugDocumentDictionary->TryGetValue(breakpointId, &debugDocument))
{
Js::StatementLocation statement;
if (debugDocument->FindBPStatementLocation(breakpointId, &statement))
{
debugDocument->SetBreakPoint(statement, BREAKPOINT_DELETED);
return true;
}
}
}
return false;
}
JsrtDebugDocumentManager::BreakpointDebugDocumentDictionary * JsrtDebugDocumentManager::GetBreakpointDictionary()
{
if (this->breakpointDebugDocumentDictionary == nullptr)
{
this->breakpointDebugDocumentDictionary = Anew(this->jsrtDebugManager->GetDebugObjectArena(), BreakpointDebugDocumentDictionary, this->jsrtDebugManager->GetDebugObjectArena(), 10);
}
return breakpointDebugDocumentDictionary;
}
#endif
Morty Proxy This is a proxified and sanitized view of the page, visit original site.