JsValueRef Debugger::GetBreakOnException(JsValueRef callee, bool isConstructCall, JsValueRef *arguments, unsigned short argumentCount, void *callbackState) { JsDiagBreakOnExceptionAttributes exceptionAttributes; IfJsErrorFailLogAndRet(ChakraRTInterface::JsDiagGetBreakOnException(Debugger::GetRuntime(), &exceptionAttributes)); JsValueRef exceptionAttributesRef; IfJsErrorFailLogAndRet(ChakraRTInterface::JsDoubleToNumber((double)exceptionAttributes, &exceptionAttributesRef)); return exceptionAttributesRef; }
JsValueRef Debugger::SetStepType(JsValueRef callee, bool isConstructCall, JsValueRef *arguments, unsigned short argumentCount, void *callbackState) { int stepType; if (argumentCount > 1) { IfJsErrorFailLogAndRet(ChakraRTInterface::JsNumberToInt(arguments[1], &stepType)); IfJsErrorFailLogAndRet(ChakraRTInterface::JsDiagSetStepType((JsDiagStepType)stepType)); } return JS_INVALID_REFERENCE; }
JsValueRef Debugger::GetObjectFromHandle(JsValueRef callee, bool isConstructCall, JsValueRef *arguments, unsigned short argumentCount, void *callbackState) { JsValueRef properties = JS_INVALID_REFERENCE; int objectHandle; if (argumentCount > 1) { IfJsErrorFailLogAndRet(ChakraRTInterface::JsNumberToInt(arguments[1], &objectHandle)); IfJsErrorFailLogAndRet(ChakraRTInterface::JsDiagGetObjectFromHandle(objectHandle, &properties)); } return properties; }
JsValueRef Debugger::GetSource(JsValueRef callee, bool isConstructCall, JsValueRef * arguments, unsigned short argumentCount, void * callbackState) { int scriptId; JsValueRef source = JS_INVALID_REFERENCE; if (argumentCount > 1) { IfJsErrorFailLogAndRet(ChakraRTInterface::JsNumberToInt(arguments[1], &scriptId)); IfJsErrorFailLogAndRet(ChakraRTInterface::JsDiagGetSource(scriptId, &source)); } return source; }
JsValueRef Debugger::GetStackProperties(JsValueRef callee, bool isConstructCall, JsValueRef *arguments, unsigned short argumentCount, void *callbackState) { JsValueRef properties = JS_INVALID_REFERENCE; int stackFrameIndex; if (argumentCount > 1) { IfJsErrorFailLogAndRet(ChakraRTInterface::JsNumberToInt(arguments[1], &stackFrameIndex)); IfJsErrorFailLogAndRet(ChakraRTInterface::JsDiagGetStackProperties(stackFrameIndex, &properties)); } return properties; }
JsValueRef Debugger::RemoveBreakpoint(JsValueRef callee, bool isConstructCall, JsValueRef *arguments, unsigned short argumentCount, void *callbackState) { int bpId; if (argumentCount > 1) { JsValueRef numberValue; IfJsErrorFailLogAndRet(ChakraRTInterface::JsConvertValueToNumber(arguments[1], &numberValue)); IfJsErrorFailLogAndRet(ChakraRTInterface::JsNumberToInt(numberValue, &bpId)); IfJsErrorFailLogAndRet(ChakraRTInterface::JsDiagRemoveBreakpoint(bpId)); } return JS_INVALID_REFERENCE; }
JsValueRef Debugger::SetBreakOnException(JsValueRef callee, bool isConstructCall, JsValueRef *arguments, unsigned short argumentCount, void *callbackState) { int exceptionAttributes; if (argumentCount > 1) { JsValueRef breakOnException; IfJsErrorFailLogAndRet(ChakraRTInterface::JsConvertValueToNumber(arguments[1], &breakOnException)); IfJsErrorFailLogAndRet(ChakraRTInterface::JsNumberToInt(breakOnException, &exceptionAttributes)); IfJsErrorFailLogAndRet(ChakraRTInterface::JsDiagSetBreakOnException(Debugger::GetRuntime(), (JsDiagBreakOnExceptionAttributes)exceptionAttributes)); } return JS_INVALID_REFERENCE; }
JsValueRef Debugger::Evaluate(JsValueRef callee, bool isConstructCall, JsValueRef *arguments, unsigned short argumentCount, void *callbackState) { int stackFrameIndex; JsValueRef result = JS_INVALID_REFERENCE; if (argumentCount > 2) { IfJsErrorFailLogAndRet(ChakraRTInterface::JsNumberToInt(arguments[1], &stackFrameIndex)); AutoString argstr(arguments[2]); IfJsErrorFailLogAndRet(argstr.GetError()); ChakraRTInterface::JsDiagEvaluateUtf8(argstr.GetString(), stackFrameIndex, &result); } return result; }
JsValueRef Debugger::SetBreakpoint(JsValueRef callee, bool isConstructCall, JsValueRef * arguments, unsigned short argumentCount, void * callbackState) { int scriptId; int line; int column; JsValueRef bpObject = JS_INVALID_REFERENCE; if (argumentCount > 3) { IfJsErrorFailLogAndRet(ChakraRTInterface::JsNumberToInt(arguments[1], &scriptId)); IfJsErrorFailLogAndRet(ChakraRTInterface::JsNumberToInt(arguments[2], &line)); IfJsErrorFailLogAndRet(ChakraRTInterface::JsNumberToInt(arguments[3], &column)); IfJsErrorFailLogAndRet(ChakraRTInterface::JsDiagSetBreakpoint(scriptId, line, column, &bpObject)); } return bpObject; }
JsValueRef WScriptJsrt::RequestAsyncBreakCallback(JsValueRef callee, bool isConstructCall, JsValueRef * arguments, unsigned short argumentCount, void * callbackState) { if (Debugger::debugger != nullptr && !Debugger::debugger->IsDetached()) { IfJsErrorFailLogAndRet(ChakraRTInterface::JsDiagRequestAsyncBreak(Debugger::GetRuntime())); } else { Helpers::LogError(_u("RequestAsyncBreak can only be called when debugger is attached")); } return JS_INVALID_REFERENCE; }
JsValueRef WScriptJsrt::DumpFunctionPositionCallback(JsValueRef callee, bool isConstructCall, JsValueRef * arguments, unsigned short argumentCount, void * callbackState) { JsValueRef functionPosition = JS_INVALID_REFERENCE; if (argumentCount > 1) { if (ChakraRTInterface::JsDiagGetFunctionPosition(arguments[1], &functionPosition) != JsNoError) { // If we can't get the functionPosition pass undefined IfJsErrorFailLogAndRet(ChakraRTInterface::JsGetUndefinedValue(&functionPosition)); } if (Debugger::debugger != nullptr) { Debugger::debugger->DumpFunctionPosition(functionPosition); } } return JS_INVALID_REFERENCE; }
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::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::GetScripts(JsValueRef callee, bool isConstructCall, JsValueRef *arguments, unsigned short argumentCount, void *callbackState) { JsValueRef sourcesList = JS_INVALID_REFERENCE; IfJsErrorFailLogAndRet(ChakraRTInterface::JsDiagGetScripts(&sourcesList)); return sourcesList; }