Skip to content

Commit

Permalink
Incorporate review comments from PR #926
Browse files Browse the repository at this point in the history
  • Loading branch information
agarwal-sandeep committed May 11, 2016
1 parent cd9402e commit 2137d11
Show file tree
Hide file tree
Showing 25 changed files with 225 additions and 251 deletions.
4 changes: 2 additions & 2 deletions bin/ch/ChakraRtInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ class ChakraRTInterface
static JsErrorCode WINAPI JsDiagStartDebugging(JsRuntimeHandle runtimeHandle, JsDiagDebugEventCallback debugEventCallback, void* callbackState) { return m_jsApiHooks.pfJsrtDiagStartDebugging(runtimeHandle, debugEventCallback, callbackState); }
static JsErrorCode WINAPI JsDiagStopDebugging(JsRuntimeHandle runtimeHandle, void** callbackState) { return m_jsApiHooks.pfJsrtDiagStopDebugging(runtimeHandle, callbackState); }
static JsErrorCode WINAPI JsDiagGetSource(unsigned int scriptId, JsValueRef *source) { return m_jsApiHooks.pfJsrtDiagGetSource(scriptId, source); }
static JsErrorCode WINAPI JsDiagSetBreakpoint(unsigned int scriptId, unsigned int lineNumber, unsigned int columnNumber, JsValueRef *breakPoint) { return m_jsApiHooks.pfJsrtDiagSetBreakpoint(scriptId, lineNumber, columnNumber, breakPoint); }
static JsErrorCode WINAPI JsDiagSetBreakpoint(unsigned int scriptId, unsigned int lineNumber, unsigned int columnNumber, JsValueRef *breakpoint) { return m_jsApiHooks.pfJsrtDiagSetBreakpoint(scriptId, lineNumber, columnNumber, breakpoint); }
static JsErrorCode WINAPI JsDiagGetStackTrace(JsValueRef *stackTrace) { return m_jsApiHooks.pfJsrtDiagGetStackTrace(stackTrace); }
static JsErrorCode WINAPI JsDiagRequestAsyncBreak(JsRuntimeHandle runtimeHandle) { return m_jsApiHooks.pfJsrtDiagRequestAsyncBreak(runtimeHandle); }
static JsErrorCode WINAPI JsDiagGetBreakpoints(JsValueRef * breakpoints) { return m_jsApiHooks.pfJsrtDiagGetBreakpoints(breakpoints); }
Expand All @@ -252,7 +252,7 @@ class ChakraRTInterface
static JsErrorCode WINAPI JsDiagGetBreakOnException(JsRuntimeHandle runtimeHandle, JsDiagBreakOnExceptionAttributes * exceptionAttributes) { return m_jsApiHooks.pfJsrtDiagGetBreakOnException(runtimeHandle, exceptionAttributes); }
static JsErrorCode WINAPI JsDiagSetStepType(JsDiagStepType stepType) { return m_jsApiHooks.pfJsrtDiagSetStepType(stepType); }
static JsErrorCode WINAPI JsDiagGetScripts(JsValueRef * scriptsArray) { return m_jsApiHooks.pfJsrtDiagGetScripts(scriptsArray); }
static JsErrorCode WINAPI JsDiagGetFunctionPosition(JsValueRef value, JsValueRef * functionInfo) { return m_jsApiHooks.pfJsrtDiagGetFunctionPosition(value, functionInfo); }
static JsErrorCode WINAPI JsDiagGetFunctionPosition(JsValueRef value, JsValueRef * functionPosition) { return m_jsApiHooks.pfJsrtDiagGetFunctionPosition(value, functionPosition); }
static JsErrorCode WINAPI JsDiagGetStackProperties(unsigned int stackFrameIndex, JsValueRef * properties) { return m_jsApiHooks.pfJsrtDiagGetStackProperties(stackFrameIndex, properties); }
static JsErrorCode WINAPI JsDiagGetProperties(unsigned int objectHandle, unsigned int fromCount, unsigned int totalCount, JsValueRef * propertiesObject) { return m_jsApiHooks.pfJsrtDiagGetProperties(objectHandle, fromCount, totalCount, propertiesObject); }
static JsErrorCode WINAPI JsDiagGetObjectFromHandle(unsigned int handle, JsValueRef * handleObject) { return m_jsApiHooks.pfJsrtDiagGetObjectFromHandle(handle, handleObject); }
Expand Down
18 changes: 9 additions & 9 deletions bin/ch/DbgController.js
Original file line number Diff line number Diff line change
Expand Up @@ -772,15 +772,15 @@ var controllerObj = (function () {
internalPrint(baseline);
}
},
dumpFunctionInfo: function (funcInfo) {
if (!funcInfo) {
funcInfo = {};
dumpFunctionPosition: function (functionPosition) {
if (!functionPosition) {
functionPosition = {};
}
else {
funcInfo["fileName"] = filterFileName(funcInfo["fileName"]);
functionPosition["fileName"] = filterFileName(functionPosition["fileName"]);
}
recordEvent({
'functionInfo': funcInfo
'functionPosition': functionPosition
});
},
setInspectMaxStringLength: function (value) {
Expand All @@ -800,7 +800,7 @@ var controllerObj = (function () {
case 1:
return "JsDiagDebugEventCompileError";
case 2:
return "JsDiagDebugEventBreak";
return "JsDiagDebugEventBreakpoint";
case 3:
return "JsDiagDebugEventStepComplete";
case 4:
Expand Down Expand Up @@ -828,7 +828,7 @@ var controllerObj = (function () {
var stackTrace = callHostFunction(hostDebugObject.JsDiagGetScripts);
break;
case 2:
/*JsDiagDebugEventBreak*/
/*JsDiagDebugEventBreakpoint*/
case 3:
/*JsDiagDebugEventStepComplete*/
case 4:
Expand Down Expand Up @@ -929,8 +929,8 @@ function SetBaseline() {
function SetInspectMaxStringLength() {
return controllerObj.setInspectMaxStringLength.apply(controllerObj, arguments);
}
function DumpFunctionInfo() {
return controllerObj.dumpFunctionInfo.apply(controllerObj, arguments);
function DumpFunctionPosition() {
return controllerObj.dumpFunctionPosition.apply(controllerObj, arguments);
}


Expand Down
75 changes: 42 additions & 33 deletions bin/ch/Debugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@

#define MAX_BASELINE_SIZE (1024*1024*200)

void CHAKRA_CALLBACK Debugger::JsDiagDebugEventHandler(_In_ JsDiagDebugEvent debugEvent, _In_ JsValueRef eventData, _In_opt_ void* callbackState)
void CHAKRA_CALLBACK Debugger::DebugEventHandler(_In_ JsDiagDebugEvent debugEvent, _In_ JsValueRef eventData, _In_opt_ void* callbackState)
{
Debugger* debugger = (Debugger*)callbackState;
debugger->HandleDebugEvent(debugEvent, eventData);
}

JsValueRef Debugger::JsDiagGetSource(JsValueRef callee, bool isConstructCall, JsValueRef * arguments, unsigned short argumentCount, void * callbackState)
JsValueRef Debugger::GetSource(JsValueRef callee, bool isConstructCall, JsValueRef * arguments, unsigned short argumentCount, void * callbackState)
{
int scriptId;
JsValueRef source = JS_INVALID_REFERENCE;
Expand All @@ -26,7 +26,7 @@ JsValueRef Debugger::JsDiagGetSource(JsValueRef callee, bool isConstructCall, Js
return source;
}

JsValueRef Debugger::JsDiagSetBreakpoint(JsValueRef callee, bool isConstructCall, JsValueRef * arguments, unsigned short argumentCount, void * callbackState)
JsValueRef Debugger::SetBreakpoint(JsValueRef callee, bool isConstructCall, JsValueRef * arguments, unsigned short argumentCount, void * callbackState)
{
int scriptId;
int line;
Expand All @@ -45,21 +45,21 @@ JsValueRef Debugger::JsDiagSetBreakpoint(JsValueRef callee, bool isConstructCall
return bpObject;
}

JsValueRef Debugger::JsDiagGetStackTrace(JsValueRef callee, bool isConstructCall, JsValueRef * arguments, unsigned short argumentCount, void * callbackState)
JsValueRef Debugger::GetStackTrace(JsValueRef callee, bool isConstructCall, JsValueRef * arguments, unsigned short argumentCount, void * callbackState)
{
JsValueRef stackInfo = JS_INVALID_REFERENCE;
IfJsErrorFailLogAndRet(ChakraRTInterface::JsDiagGetStackTrace(&stackInfo));
return stackInfo;
}

JsValueRef Debugger::JsDiagGetBreakpoints(JsValueRef callee, bool isConstructCall, JsValueRef *arguments, unsigned short argumentCount, void *callbackState)
JsValueRef Debugger::GetBreakpoints(JsValueRef callee, bool isConstructCall, JsValueRef *arguments, unsigned short argumentCount, void *callbackState)
{
JsValueRef breakpoints = JS_INVALID_REFERENCE;
IfJsErrorFailLogAndRet(ChakraRTInterface::JsDiagGetBreakpoints(&breakpoints));
return breakpoints;
}

JsValueRef Debugger::JsDiagRemoveBreakpoint(JsValueRef callee, bool isConstructCall, JsValueRef *arguments, unsigned short argumentCount, void *callbackState)
JsValueRef Debugger::RemoveBreakpoint(JsValueRef callee, bool isConstructCall, JsValueRef *arguments, unsigned short argumentCount, void *callbackState)
{
int bpId;
if (argumentCount > 1)
Expand All @@ -74,7 +74,7 @@ JsValueRef Debugger::JsDiagRemoveBreakpoint(JsValueRef callee, bool isConstructC
return JS_INVALID_REFERENCE;
}

JsValueRef Debugger::JsDiagSetBreakOnException(JsValueRef callee, bool isConstructCall, JsValueRef *arguments, unsigned short argumentCount, void *callbackState)
JsValueRef Debugger::SetBreakOnException(JsValueRef callee, bool isConstructCall, JsValueRef *arguments, unsigned short argumentCount, void *callbackState)
{
int exceptionAttributes;

Expand All @@ -90,7 +90,7 @@ JsValueRef Debugger::JsDiagSetBreakOnException(JsValueRef callee, bool isConstru
return JS_INVALID_REFERENCE;
}

JsValueRef Debugger::JsDiagGetBreakOnException(JsValueRef callee, bool isConstructCall, JsValueRef *arguments, unsigned short argumentCount, void *callbackState)
JsValueRef Debugger::GetBreakOnException(JsValueRef callee, bool isConstructCall, JsValueRef *arguments, unsigned short argumentCount, void *callbackState)
{
JsDiagBreakOnExceptionAttributes exceptionAttributes;
IfJsErrorFailLogAndRet(ChakraRTInterface::JsDiagGetBreakOnException(Debugger::GetRuntime(), &exceptionAttributes));
Expand All @@ -100,7 +100,7 @@ JsValueRef Debugger::JsDiagGetBreakOnException(JsValueRef callee, bool isConstru
return exceptionAttributesRef;
}

JsValueRef Debugger::JsDiagSetStepType(JsValueRef callee, bool isConstructCall, JsValueRef *arguments, unsigned short argumentCount, void *callbackState)
JsValueRef Debugger::SetStepType(JsValueRef callee, bool isConstructCall, JsValueRef *arguments, unsigned short argumentCount, void *callbackState)
{
int stepType;

Expand All @@ -113,14 +113,14 @@ JsValueRef Debugger::JsDiagSetStepType(JsValueRef callee, bool isConstructCall,
return JS_INVALID_REFERENCE;
}

JsValueRef Debugger::JsDiagGetScripts(JsValueRef callee, bool isConstructCall, JsValueRef *arguments, unsigned short argumentCount, void *callbackState)
JsValueRef Debugger::GetScripts(JsValueRef callee, bool isConstructCall, JsValueRef *arguments, unsigned short argumentCount, void *callbackState)
{
JsValueRef sourcesList = JS_INVALID_REFERENCE;
IfJsErrorFailLogAndRet(ChakraRTInterface::JsDiagGetScripts(&sourcesList));
return sourcesList;
}

JsValueRef Debugger::JsDiagGetStackProperties(JsValueRef callee, bool isConstructCall, JsValueRef *arguments, unsigned short argumentCount, void *callbackState)
JsValueRef Debugger::GetStackProperties(JsValueRef callee, bool isConstructCall, JsValueRef *arguments, unsigned short argumentCount, void *callbackState)
{
JsValueRef properties = JS_INVALID_REFERENCE;
int stackFrameIndex;
Expand All @@ -134,7 +134,7 @@ JsValueRef Debugger::JsDiagGetStackProperties(JsValueRef callee, bool isConstruc
return properties;
}

JsValueRef Debugger::JsDiagGetProperties(JsValueRef callee, bool isConstructCall, JsValueRef *arguments, unsigned short argumentCount, void *callbackState)
JsValueRef Debugger::GetProperties(JsValueRef callee, bool isConstructCall, JsValueRef *arguments, unsigned short argumentCount, void *callbackState)
{
JsValueRef properties = JS_INVALID_REFERENCE;
int objectHandle;
Expand All @@ -152,7 +152,7 @@ JsValueRef Debugger::JsDiagGetProperties(JsValueRef callee, bool isConstructCall
return properties;
}

JsValueRef Debugger::JsDiagGetObjectFromHandle(JsValueRef callee, bool isConstructCall, JsValueRef *arguments, unsigned short argumentCount, void *callbackState)
JsValueRef Debugger::GetObjectFromHandle(JsValueRef callee, bool isConstructCall, JsValueRef *arguments, unsigned short argumentCount, void *callbackState)
{
JsValueRef properties = JS_INVALID_REFERENCE;
int objectHandle;
Expand All @@ -166,7 +166,7 @@ JsValueRef Debugger::JsDiagGetObjectFromHandle(JsValueRef callee, bool isConstru
return properties;
}

JsValueRef Debugger::JsDiagEvaluate(JsValueRef callee, bool isConstructCall, JsValueRef *arguments, unsigned short argumentCount, void *callbackState)
JsValueRef Debugger::Evaluate(JsValueRef callee, bool isConstructCall, JsValueRef *arguments, unsigned short argumentCount, void *callbackState)
{
int stackFrameIndex;
JsValueRef result = JS_INVALID_REFERENCE;
Expand All @@ -188,7 +188,7 @@ Debugger::Debugger(JsRuntimeHandle runtime)
{
this->m_runtime = runtime;
this->m_context = JS_INVALID_REFERENCE;
this->isDetached = true;
this->m_isDetached = true;
}

Debugger::~Debugger()
Expand Down Expand Up @@ -273,19 +273,19 @@ bool Debugger::Initialize()
bool Debugger::InstallDebugCallbacks(JsValueRef hostDebugObject)
{
HRESULT hr = S_OK;
IfFalseGo(WScriptJsrt::InstallObjectsOnObject(hostDebugObject, _u("JsDiagGetSource"), Debugger::JsDiagGetSource));
IfFalseGo(WScriptJsrt::InstallObjectsOnObject(hostDebugObject, _u("JsDiagSetBreakpoint"), Debugger::JsDiagSetBreakpoint));
IfFalseGo(WScriptJsrt::InstallObjectsOnObject(hostDebugObject, _u("JsDiagGetStackTrace"), Debugger::JsDiagGetStackTrace));
IfFalseGo(WScriptJsrt::InstallObjectsOnObject(hostDebugObject, _u("JsDiagGetBreakpoints"), Debugger::JsDiagGetBreakpoints));
IfFalseGo(WScriptJsrt::InstallObjectsOnObject(hostDebugObject, _u("JsDiagRemoveBreakpoint"), Debugger::JsDiagRemoveBreakpoint));
IfFalseGo(WScriptJsrt::InstallObjectsOnObject(hostDebugObject, _u("JsDiagSetBreakOnException"), Debugger::JsDiagSetBreakOnException));
IfFalseGo(WScriptJsrt::InstallObjectsOnObject(hostDebugObject, _u("JsDiagGetBreakOnException"), Debugger::JsDiagGetBreakOnException));
IfFalseGo(WScriptJsrt::InstallObjectsOnObject(hostDebugObject, _u("JsDiagSetStepType"), Debugger::JsDiagSetStepType));
IfFalseGo(WScriptJsrt::InstallObjectsOnObject(hostDebugObject, _u("JsDiagGetScripts"), Debugger::JsDiagGetScripts));
IfFalseGo(WScriptJsrt::InstallObjectsOnObject(hostDebugObject, _u("JsDiagGetStackProperties"), Debugger::JsDiagGetStackProperties));
IfFalseGo(WScriptJsrt::InstallObjectsOnObject(hostDebugObject, _u("JsDiagGetProperties"), Debugger::JsDiagGetProperties));
IfFalseGo(WScriptJsrt::InstallObjectsOnObject(hostDebugObject, _u("JsDiagGetObjectFromHandle"), Debugger::JsDiagGetObjectFromHandle));
IfFalseGo(WScriptJsrt::InstallObjectsOnObject(hostDebugObject, _u("JsDiagEvaluate"), Debugger::JsDiagEvaluate));
IfFalseGo(WScriptJsrt::InstallObjectsOnObject(hostDebugObject, _u("JsDiagGetSource"), Debugger::GetSource));
IfFalseGo(WScriptJsrt::InstallObjectsOnObject(hostDebugObject, _u("JsDiagSetBreakpoint"), Debugger::SetBreakpoint));
IfFalseGo(WScriptJsrt::InstallObjectsOnObject(hostDebugObject, _u("JsDiagGetStackTrace"), Debugger::GetStackTrace));
IfFalseGo(WScriptJsrt::InstallObjectsOnObject(hostDebugObject, _u("JsDiagGetBreakpoints"), Debugger::GetBreakpoints));
IfFalseGo(WScriptJsrt::InstallObjectsOnObject(hostDebugObject, _u("JsDiagRemoveBreakpoint"), Debugger::RemoveBreakpoint));
IfFalseGo(WScriptJsrt::InstallObjectsOnObject(hostDebugObject, _u("JsDiagSetBreakOnException"), Debugger::SetBreakOnException));
IfFalseGo(WScriptJsrt::InstallObjectsOnObject(hostDebugObject, _u("JsDiagGetBreakOnException"), Debugger::GetBreakOnException));
IfFalseGo(WScriptJsrt::InstallObjectsOnObject(hostDebugObject, _u("JsDiagSetStepType"), Debugger::SetStepType));
IfFalseGo(WScriptJsrt::InstallObjectsOnObject(hostDebugObject, _u("JsDiagGetScripts"), Debugger::GetScripts));
IfFalseGo(WScriptJsrt::InstallObjectsOnObject(hostDebugObject, _u("JsDiagGetStackProperties"), Debugger::GetStackProperties));
IfFalseGo(WScriptJsrt::InstallObjectsOnObject(hostDebugObject, _u("JsDiagGetProperties"), Debugger::GetProperties));
IfFalseGo(WScriptJsrt::InstallObjectsOnObject(hostDebugObject, _u("JsDiagGetObjectFromHandle"), Debugger::GetObjectFromHandle));
IfFalseGo(WScriptJsrt::InstallObjectsOnObject(hostDebugObject, _u("JsDiagEvaluate"), Debugger::Evaluate));
Error:
return hr != S_OK;
}
Expand Down Expand Up @@ -342,11 +342,20 @@ bool Debugger::SetBaseline()
}
Error:
if (script)
{
delete[] script;
}

if (wideScript)
{
delete[] wideScript;
}

if (file)
{
fclose(file);
}

return hr == S_OK;
}

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

bool Debugger::DumpFunctionInfo(JsValueRef functionInfo)
bool Debugger::DumpFunctionPosition(JsValueRef functionPosition)
{
return this->CallFunctionNoResult(_u("DumpFunctionInfo"), functionInfo);
return this->CallFunctionNoResult(_u("DumpFunctionPosition"), functionPosition);
}

bool Debugger::StartDebugging(JsRuntimeHandle runtime)
{
IfJsrtErrorFailLogAndRetFalse(ChakraRTInterface::JsDiagStartDebugging(runtime, Debugger::JsDiagDebugEventHandler, this));
IfJsrtErrorFailLogAndRetFalse(ChakraRTInterface::JsDiagStartDebugging(runtime, Debugger::DebugEventHandler, this));

this->isDetached = false;
this->m_isDetached = false;

return true;
}
Expand All @@ -429,7 +438,7 @@ bool Debugger::StopDebugging(JsRuntimeHandle runtime)

Assert(callbackState == this);

this->isDetached = true;
this->m_isDetached = true;

return true;
}
Expand Down
Loading

0 comments on commit 2137d11

Please sign in to comment.