Skip to content

Commit 2137d11

Browse files
Incorporate review comments from PR #926
1 parent cd9402e commit 2137d11

25 files changed

+225
-251
lines changed

bin/ch/ChakraRtInterface.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ class ChakraRTInterface
243243
static JsErrorCode WINAPI JsDiagStartDebugging(JsRuntimeHandle runtimeHandle, JsDiagDebugEventCallback debugEventCallback, void* callbackState) { return m_jsApiHooks.pfJsrtDiagStartDebugging(runtimeHandle, debugEventCallback, callbackState); }
244244
static JsErrorCode WINAPI JsDiagStopDebugging(JsRuntimeHandle runtimeHandle, void** callbackState) { return m_jsApiHooks.pfJsrtDiagStopDebugging(runtimeHandle, callbackState); }
245245
static JsErrorCode WINAPI JsDiagGetSource(unsigned int scriptId, JsValueRef *source) { return m_jsApiHooks.pfJsrtDiagGetSource(scriptId, source); }
246-
static JsErrorCode WINAPI JsDiagSetBreakpoint(unsigned int scriptId, unsigned int lineNumber, unsigned int columnNumber, JsValueRef *breakPoint) { return m_jsApiHooks.pfJsrtDiagSetBreakpoint(scriptId, lineNumber, columnNumber, breakPoint); }
246+
static JsErrorCode WINAPI JsDiagSetBreakpoint(unsigned int scriptId, unsigned int lineNumber, unsigned int columnNumber, JsValueRef *breakpoint) { return m_jsApiHooks.pfJsrtDiagSetBreakpoint(scriptId, lineNumber, columnNumber, breakpoint); }
247247
static JsErrorCode WINAPI JsDiagGetStackTrace(JsValueRef *stackTrace) { return m_jsApiHooks.pfJsrtDiagGetStackTrace(stackTrace); }
248248
static JsErrorCode WINAPI JsDiagRequestAsyncBreak(JsRuntimeHandle runtimeHandle) { return m_jsApiHooks.pfJsrtDiagRequestAsyncBreak(runtimeHandle); }
249249
static JsErrorCode WINAPI JsDiagGetBreakpoints(JsValueRef * breakpoints) { return m_jsApiHooks.pfJsrtDiagGetBreakpoints(breakpoints); }
@@ -252,7 +252,7 @@ class ChakraRTInterface
252252
static JsErrorCode WINAPI JsDiagGetBreakOnException(JsRuntimeHandle runtimeHandle, JsDiagBreakOnExceptionAttributes * exceptionAttributes) { return m_jsApiHooks.pfJsrtDiagGetBreakOnException(runtimeHandle, exceptionAttributes); }
253253
static JsErrorCode WINAPI JsDiagSetStepType(JsDiagStepType stepType) { return m_jsApiHooks.pfJsrtDiagSetStepType(stepType); }
254254
static JsErrorCode WINAPI JsDiagGetScripts(JsValueRef * scriptsArray) { return m_jsApiHooks.pfJsrtDiagGetScripts(scriptsArray); }
255-
static JsErrorCode WINAPI JsDiagGetFunctionPosition(JsValueRef value, JsValueRef * functionInfo) { return m_jsApiHooks.pfJsrtDiagGetFunctionPosition(value, functionInfo); }
255+
static JsErrorCode WINAPI JsDiagGetFunctionPosition(JsValueRef value, JsValueRef * functionPosition) { return m_jsApiHooks.pfJsrtDiagGetFunctionPosition(value, functionPosition); }
256256
static JsErrorCode WINAPI JsDiagGetStackProperties(unsigned int stackFrameIndex, JsValueRef * properties) { return m_jsApiHooks.pfJsrtDiagGetStackProperties(stackFrameIndex, properties); }
257257
static JsErrorCode WINAPI JsDiagGetProperties(unsigned int objectHandle, unsigned int fromCount, unsigned int totalCount, JsValueRef * propertiesObject) { return m_jsApiHooks.pfJsrtDiagGetProperties(objectHandle, fromCount, totalCount, propertiesObject); }
258258
static JsErrorCode WINAPI JsDiagGetObjectFromHandle(unsigned int handle, JsValueRef * handleObject) { return m_jsApiHooks.pfJsrtDiagGetObjectFromHandle(handle, handleObject); }

bin/ch/DbgController.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -772,15 +772,15 @@ var controllerObj = (function () {
772772
internalPrint(baseline);
773773
}
774774
},
775-
dumpFunctionInfo: function (funcInfo) {
776-
if (!funcInfo) {
777-
funcInfo = {};
775+
dumpFunctionPosition: function (functionPosition) {
776+
if (!functionPosition) {
777+
functionPosition = {};
778778
}
779779
else {
780-
funcInfo["fileName"] = filterFileName(funcInfo["fileName"]);
780+
functionPosition["fileName"] = filterFileName(functionPosition["fileName"]);
781781
}
782782
recordEvent({
783-
'functionInfo': funcInfo
783+
'functionPosition': functionPosition
784784
});
785785
},
786786
setInspectMaxStringLength: function (value) {
@@ -800,7 +800,7 @@ var controllerObj = (function () {
800800
case 1:
801801
return "JsDiagDebugEventCompileError";
802802
case 2:
803-
return "JsDiagDebugEventBreak";
803+
return "JsDiagDebugEventBreakpoint";
804804
case 3:
805805
return "JsDiagDebugEventStepComplete";
806806
case 4:
@@ -828,7 +828,7 @@ var controllerObj = (function () {
828828
var stackTrace = callHostFunction(hostDebugObject.JsDiagGetScripts);
829829
break;
830830
case 2:
831-
/*JsDiagDebugEventBreak*/
831+
/*JsDiagDebugEventBreakpoint*/
832832
case 3:
833833
/*JsDiagDebugEventStepComplete*/
834834
case 4:
@@ -929,8 +929,8 @@ function SetBaseline() {
929929
function SetInspectMaxStringLength() {
930930
return controllerObj.setInspectMaxStringLength.apply(controllerObj, arguments);
931931
}
932-
function DumpFunctionInfo() {
933-
return controllerObj.dumpFunctionInfo.apply(controllerObj, arguments);
932+
function DumpFunctionPosition() {
933+
return controllerObj.dumpFunctionPosition.apply(controllerObj, arguments);
934934
}
935935

936936

bin/ch/Debugger.cpp

Lines changed: 42 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66

77
#define MAX_BASELINE_SIZE (1024*1024*200)
88

9-
void CHAKRA_CALLBACK Debugger::JsDiagDebugEventHandler(_In_ JsDiagDebugEvent debugEvent, _In_ JsValueRef eventData, _In_opt_ void* callbackState)
9+
void CHAKRA_CALLBACK Debugger::DebugEventHandler(_In_ JsDiagDebugEvent debugEvent, _In_ JsValueRef eventData, _In_opt_ void* callbackState)
1010
{
1111
Debugger* debugger = (Debugger*)callbackState;
1212
debugger->HandleDebugEvent(debugEvent, eventData);
1313
}
1414

15-
JsValueRef Debugger::JsDiagGetSource(JsValueRef callee, bool isConstructCall, JsValueRef * arguments, unsigned short argumentCount, void * callbackState)
15+
JsValueRef Debugger::GetSource(JsValueRef callee, bool isConstructCall, JsValueRef * arguments, unsigned short argumentCount, void * callbackState)
1616
{
1717
int scriptId;
1818
JsValueRef source = JS_INVALID_REFERENCE;
@@ -26,7 +26,7 @@ JsValueRef Debugger::JsDiagGetSource(JsValueRef callee, bool isConstructCall, Js
2626
return source;
2727
}
2828

29-
JsValueRef Debugger::JsDiagSetBreakpoint(JsValueRef callee, bool isConstructCall, JsValueRef * arguments, unsigned short argumentCount, void * callbackState)
29+
JsValueRef Debugger::SetBreakpoint(JsValueRef callee, bool isConstructCall, JsValueRef * arguments, unsigned short argumentCount, void * callbackState)
3030
{
3131
int scriptId;
3232
int line;
@@ -45,21 +45,21 @@ JsValueRef Debugger::JsDiagSetBreakpoint(JsValueRef callee, bool isConstructCall
4545
return bpObject;
4646
}
4747

48-
JsValueRef Debugger::JsDiagGetStackTrace(JsValueRef callee, bool isConstructCall, JsValueRef * arguments, unsigned short argumentCount, void * callbackState)
48+
JsValueRef Debugger::GetStackTrace(JsValueRef callee, bool isConstructCall, JsValueRef * arguments, unsigned short argumentCount, void * callbackState)
4949
{
5050
JsValueRef stackInfo = JS_INVALID_REFERENCE;
5151
IfJsErrorFailLogAndRet(ChakraRTInterface::JsDiagGetStackTrace(&stackInfo));
5252
return stackInfo;
5353
}
5454

55-
JsValueRef Debugger::JsDiagGetBreakpoints(JsValueRef callee, bool isConstructCall, JsValueRef *arguments, unsigned short argumentCount, void *callbackState)
55+
JsValueRef Debugger::GetBreakpoints(JsValueRef callee, bool isConstructCall, JsValueRef *arguments, unsigned short argumentCount, void *callbackState)
5656
{
5757
JsValueRef breakpoints = JS_INVALID_REFERENCE;
5858
IfJsErrorFailLogAndRet(ChakraRTInterface::JsDiagGetBreakpoints(&breakpoints));
5959
return breakpoints;
6060
}
6161

62-
JsValueRef Debugger::JsDiagRemoveBreakpoint(JsValueRef callee, bool isConstructCall, JsValueRef *arguments, unsigned short argumentCount, void *callbackState)
62+
JsValueRef Debugger::RemoveBreakpoint(JsValueRef callee, bool isConstructCall, JsValueRef *arguments, unsigned short argumentCount, void *callbackState)
6363
{
6464
int bpId;
6565
if (argumentCount > 1)
@@ -74,7 +74,7 @@ JsValueRef Debugger::JsDiagRemoveBreakpoint(JsValueRef callee, bool isConstructC
7474
return JS_INVALID_REFERENCE;
7575
}
7676

77-
JsValueRef Debugger::JsDiagSetBreakOnException(JsValueRef callee, bool isConstructCall, JsValueRef *arguments, unsigned short argumentCount, void *callbackState)
77+
JsValueRef Debugger::SetBreakOnException(JsValueRef callee, bool isConstructCall, JsValueRef *arguments, unsigned short argumentCount, void *callbackState)
7878
{
7979
int exceptionAttributes;
8080

@@ -90,7 +90,7 @@ JsValueRef Debugger::JsDiagSetBreakOnException(JsValueRef callee, bool isConstru
9090
return JS_INVALID_REFERENCE;
9191
}
9292

93-
JsValueRef Debugger::JsDiagGetBreakOnException(JsValueRef callee, bool isConstructCall, JsValueRef *arguments, unsigned short argumentCount, void *callbackState)
93+
JsValueRef Debugger::GetBreakOnException(JsValueRef callee, bool isConstructCall, JsValueRef *arguments, unsigned short argumentCount, void *callbackState)
9494
{
9595
JsDiagBreakOnExceptionAttributes exceptionAttributes;
9696
IfJsErrorFailLogAndRet(ChakraRTInterface::JsDiagGetBreakOnException(Debugger::GetRuntime(), &exceptionAttributes));
@@ -100,7 +100,7 @@ JsValueRef Debugger::JsDiagGetBreakOnException(JsValueRef callee, bool isConstru
100100
return exceptionAttributesRef;
101101
}
102102

103-
JsValueRef Debugger::JsDiagSetStepType(JsValueRef callee, bool isConstructCall, JsValueRef *arguments, unsigned short argumentCount, void *callbackState)
103+
JsValueRef Debugger::SetStepType(JsValueRef callee, bool isConstructCall, JsValueRef *arguments, unsigned short argumentCount, void *callbackState)
104104
{
105105
int stepType;
106106

@@ -113,14 +113,14 @@ JsValueRef Debugger::JsDiagSetStepType(JsValueRef callee, bool isConstructCall,
113113
return JS_INVALID_REFERENCE;
114114
}
115115

116-
JsValueRef Debugger::JsDiagGetScripts(JsValueRef callee, bool isConstructCall, JsValueRef *arguments, unsigned short argumentCount, void *callbackState)
116+
JsValueRef Debugger::GetScripts(JsValueRef callee, bool isConstructCall, JsValueRef *arguments, unsigned short argumentCount, void *callbackState)
117117
{
118118
JsValueRef sourcesList = JS_INVALID_REFERENCE;
119119
IfJsErrorFailLogAndRet(ChakraRTInterface::JsDiagGetScripts(&sourcesList));
120120
return sourcesList;
121121
}
122122

123-
JsValueRef Debugger::JsDiagGetStackProperties(JsValueRef callee, bool isConstructCall, JsValueRef *arguments, unsigned short argumentCount, void *callbackState)
123+
JsValueRef Debugger::GetStackProperties(JsValueRef callee, bool isConstructCall, JsValueRef *arguments, unsigned short argumentCount, void *callbackState)
124124
{
125125
JsValueRef properties = JS_INVALID_REFERENCE;
126126
int stackFrameIndex;
@@ -134,7 +134,7 @@ JsValueRef Debugger::JsDiagGetStackProperties(JsValueRef callee, bool isConstruc
134134
return properties;
135135
}
136136

137-
JsValueRef Debugger::JsDiagGetProperties(JsValueRef callee, bool isConstructCall, JsValueRef *arguments, unsigned short argumentCount, void *callbackState)
137+
JsValueRef Debugger::GetProperties(JsValueRef callee, bool isConstructCall, JsValueRef *arguments, unsigned short argumentCount, void *callbackState)
138138
{
139139
JsValueRef properties = JS_INVALID_REFERENCE;
140140
int objectHandle;
@@ -152,7 +152,7 @@ JsValueRef Debugger::JsDiagGetProperties(JsValueRef callee, bool isConstructCall
152152
return properties;
153153
}
154154

155-
JsValueRef Debugger::JsDiagGetObjectFromHandle(JsValueRef callee, bool isConstructCall, JsValueRef *arguments, unsigned short argumentCount, void *callbackState)
155+
JsValueRef Debugger::GetObjectFromHandle(JsValueRef callee, bool isConstructCall, JsValueRef *arguments, unsigned short argumentCount, void *callbackState)
156156
{
157157
JsValueRef properties = JS_INVALID_REFERENCE;
158158
int objectHandle;
@@ -166,7 +166,7 @@ JsValueRef Debugger::JsDiagGetObjectFromHandle(JsValueRef callee, bool isConstru
166166
return properties;
167167
}
168168

169-
JsValueRef Debugger::JsDiagEvaluate(JsValueRef callee, bool isConstructCall, JsValueRef *arguments, unsigned short argumentCount, void *callbackState)
169+
JsValueRef Debugger::Evaluate(JsValueRef callee, bool isConstructCall, JsValueRef *arguments, unsigned short argumentCount, void *callbackState)
170170
{
171171
int stackFrameIndex;
172172
JsValueRef result = JS_INVALID_REFERENCE;
@@ -188,7 +188,7 @@ Debugger::Debugger(JsRuntimeHandle runtime)
188188
{
189189
this->m_runtime = runtime;
190190
this->m_context = JS_INVALID_REFERENCE;
191-
this->isDetached = true;
191+
this->m_isDetached = true;
192192
}
193193

194194
Debugger::~Debugger()
@@ -273,19 +273,19 @@ bool Debugger::Initialize()
273273
bool Debugger::InstallDebugCallbacks(JsValueRef hostDebugObject)
274274
{
275275
HRESULT hr = S_OK;
276-
IfFalseGo(WScriptJsrt::InstallObjectsOnObject(hostDebugObject, _u("JsDiagGetSource"), Debugger::JsDiagGetSource));
277-
IfFalseGo(WScriptJsrt::InstallObjectsOnObject(hostDebugObject, _u("JsDiagSetBreakpoint"), Debugger::JsDiagSetBreakpoint));
278-
IfFalseGo(WScriptJsrt::InstallObjectsOnObject(hostDebugObject, _u("JsDiagGetStackTrace"), Debugger::JsDiagGetStackTrace));
279-
IfFalseGo(WScriptJsrt::InstallObjectsOnObject(hostDebugObject, _u("JsDiagGetBreakpoints"), Debugger::JsDiagGetBreakpoints));
280-
IfFalseGo(WScriptJsrt::InstallObjectsOnObject(hostDebugObject, _u("JsDiagRemoveBreakpoint"), Debugger::JsDiagRemoveBreakpoint));
281-
IfFalseGo(WScriptJsrt::InstallObjectsOnObject(hostDebugObject, _u("JsDiagSetBreakOnException"), Debugger::JsDiagSetBreakOnException));
282-
IfFalseGo(WScriptJsrt::InstallObjectsOnObject(hostDebugObject, _u("JsDiagGetBreakOnException"), Debugger::JsDiagGetBreakOnException));
283-
IfFalseGo(WScriptJsrt::InstallObjectsOnObject(hostDebugObject, _u("JsDiagSetStepType"), Debugger::JsDiagSetStepType));
284-
IfFalseGo(WScriptJsrt::InstallObjectsOnObject(hostDebugObject, _u("JsDiagGetScripts"), Debugger::JsDiagGetScripts));
285-
IfFalseGo(WScriptJsrt::InstallObjectsOnObject(hostDebugObject, _u("JsDiagGetStackProperties"), Debugger::JsDiagGetStackProperties));
286-
IfFalseGo(WScriptJsrt::InstallObjectsOnObject(hostDebugObject, _u("JsDiagGetProperties"), Debugger::JsDiagGetProperties));
287-
IfFalseGo(WScriptJsrt::InstallObjectsOnObject(hostDebugObject, _u("JsDiagGetObjectFromHandle"), Debugger::JsDiagGetObjectFromHandle));
288-
IfFalseGo(WScriptJsrt::InstallObjectsOnObject(hostDebugObject, _u("JsDiagEvaluate"), Debugger::JsDiagEvaluate));
276+
IfFalseGo(WScriptJsrt::InstallObjectsOnObject(hostDebugObject, _u("JsDiagGetSource"), Debugger::GetSource));
277+
IfFalseGo(WScriptJsrt::InstallObjectsOnObject(hostDebugObject, _u("JsDiagSetBreakpoint"), Debugger::SetBreakpoint));
278+
IfFalseGo(WScriptJsrt::InstallObjectsOnObject(hostDebugObject, _u("JsDiagGetStackTrace"), Debugger::GetStackTrace));
279+
IfFalseGo(WScriptJsrt::InstallObjectsOnObject(hostDebugObject, _u("JsDiagGetBreakpoints"), Debugger::GetBreakpoints));
280+
IfFalseGo(WScriptJsrt::InstallObjectsOnObject(hostDebugObject, _u("JsDiagRemoveBreakpoint"), Debugger::RemoveBreakpoint));
281+
IfFalseGo(WScriptJsrt::InstallObjectsOnObject(hostDebugObject, _u("JsDiagSetBreakOnException"), Debugger::SetBreakOnException));
282+
IfFalseGo(WScriptJsrt::InstallObjectsOnObject(hostDebugObject, _u("JsDiagGetBreakOnException"), Debugger::GetBreakOnException));
283+
IfFalseGo(WScriptJsrt::InstallObjectsOnObject(hostDebugObject, _u("JsDiagSetStepType"), Debugger::SetStepType));
284+
IfFalseGo(WScriptJsrt::InstallObjectsOnObject(hostDebugObject, _u("JsDiagGetScripts"), Debugger::GetScripts));
285+
IfFalseGo(WScriptJsrt::InstallObjectsOnObject(hostDebugObject, _u("JsDiagGetStackProperties"), Debugger::GetStackProperties));
286+
IfFalseGo(WScriptJsrt::InstallObjectsOnObject(hostDebugObject, _u("JsDiagGetProperties"), Debugger::GetProperties));
287+
IfFalseGo(WScriptJsrt::InstallObjectsOnObject(hostDebugObject, _u("JsDiagGetObjectFromHandle"), Debugger::GetObjectFromHandle));
288+
IfFalseGo(WScriptJsrt::InstallObjectsOnObject(hostDebugObject, _u("JsDiagEvaluate"), Debugger::Evaluate));
289289
Error:
290290
return hr != S_OK;
291291
}
@@ -342,11 +342,20 @@ bool Debugger::SetBaseline()
342342
}
343343
Error:
344344
if (script)
345+
{
345346
delete[] script;
347+
}
348+
346349
if (wideScript)
350+
{
347351
delete[] wideScript;
352+
}
353+
348354
if (file)
355+
{
349356
fclose(file);
357+
}
358+
350359
return hr == S_OK;
351360
}
352361

@@ -408,16 +417,16 @@ bool Debugger::CallFunctionNoResult(char16 const * functionName, JsValueRef arg1
408417
return this->CallFunction(functionName, &result, arg1, arg2);
409418
}
410419

411-
bool Debugger::DumpFunctionInfo(JsValueRef functionInfo)
420+
bool Debugger::DumpFunctionPosition(JsValueRef functionPosition)
412421
{
413-
return this->CallFunctionNoResult(_u("DumpFunctionInfo"), functionInfo);
422+
return this->CallFunctionNoResult(_u("DumpFunctionPosition"), functionPosition);
414423
}
415424

416425
bool Debugger::StartDebugging(JsRuntimeHandle runtime)
417426
{
418-
IfJsrtErrorFailLogAndRetFalse(ChakraRTInterface::JsDiagStartDebugging(runtime, Debugger::JsDiagDebugEventHandler, this));
427+
IfJsrtErrorFailLogAndRetFalse(ChakraRTInterface::JsDiagStartDebugging(runtime, Debugger::DebugEventHandler, this));
419428

420-
this->isDetached = false;
429+
this->m_isDetached = false;
421430

422431
return true;
423432
}
@@ -429,7 +438,7 @@ bool Debugger::StopDebugging(JsRuntimeHandle runtime)
429438

430439
Assert(callbackState == this);
431440

432-
this->isDetached = true;
441+
this->m_isDetached = true;
433442

434443
return true;
435444
}

0 commit comments

Comments
 (0)