• Home
  • Raw
  • Download

Lines Matching refs:cx

102     JSValue msg = JS_ParseJSON(debuggerInfo->cx, message, strlen(message), "<debugger>");  in DBG_ReadMsg()
113 JSContext *cx = debuggerInfo->cx; in DBG_SendMsg() local
114 if (cx == NULL) { in DBG_SendMsg()
118 JSValue jsValMsg = JS_JsonStringify(cx, JS_UNDEFINED, 1, args); in DBG_SendMsg()
120 const char *jsonStrMsg = JS_ToCStringLen(cx, &len, jsValMsg); in DBG_SendMsg()
127 JS_FreeValue(cx, jsValMsg); in DBG_SendMsg()
134 JS_FreeCString(cx, jsonStrMsg); in DBG_SendMsg()
135 JS_FreeValue(cx, jsValMsg); in DBG_SendMsg()
140 JS_FreeCString(cx, jsonStrMsg); in DBG_SendMsg()
141 JS_FreeValue(cx, jsValMsg); in DBG_SendMsg()
146 JS_FreeCString(cx, jsonStrMsg); in DBG_SendMsg()
147 JS_FreeValue(cx, jsValMsg); in DBG_SendMsg()
153 JS_FreeCString(cx, jsonStrMsg); in DBG_SendMsg()
154 JS_FreeValue(cx, jsValMsg); in DBG_SendMsg()
157 JS_FreeCString(cx, jsonStrMsg); in DBG_SendMsg()
158 JS_FreeValue(cx, jsValMsg); in DBG_SendMsg()
166 JSContext *cx = debuggerInfo->cx; in DBG_SendStopMsg() local
167 if (cx == NULL) { in DBG_SendStopMsg()
171 JSValue stopEvent = JS_NewObject(cx); in DBG_SendStopMsg()
172 JS_SetPropertyStr(cx, stopEvent, "reason", JS_NewString(cx, stopReason)); in DBG_SendStopMsg()
173 JS_SetPropertyStr(cx, stopEvent, "type", JS_NewString(cx, "StoppedEvent")); in DBG_SendStopMsg()
174 JS_SetPropertyStr(cx, stopEvent, "thread", JS_NewInt64(cx, (int64_t)debuggerInfo->client)); in DBG_SendStopMsg()
175 JSValue msgBody = JS_NewObject(cx); in DBG_SendStopMsg()
176 JS_SetPropertyStr(cx, msgBody, "type", JS_NewString(cx, "event")); in DBG_SendStopMsg()
177 JS_SetPropertyStr(cx, msgBody, "event", stopEvent); in DBG_SendStopMsg()
179 JS_FreeValue(cx, msgBody); in DBG_SendStopMsg()
190 JSContext *cx = debuggerInfo->cx; in DBG_SendResponseMsg() local
191 if (cx == NULL) { in DBG_SendResponseMsg()
195 JSValue msgBody = JS_NewObject(cx); in DBG_SendResponseMsg()
196 JS_SetPropertyStr(cx, msgBody, "type", JS_NewString(cx, "response")); in DBG_SendResponseMsg()
197 JS_SetPropertyStr(cx, msgBody, "request_seq", JS_GetPropertyStr(cx, request, "request_seq")); in DBG_SendResponseMsg()
198 JS_SetPropertyStr(cx, msgBody, "body", body); in DBG_SendResponseMsg()
200 JS_FreeValue(cx, msgBody); in DBG_SendResponseMsg()
212 JSValue filename = JS_GetPropertyStr(debuggerInfo->cx, breakpoints, "path"); in DBG_SetBreakpoints()
213 const char *path = JS_ToCString(debuggerInfo->cx, filename); in DBG_SetBreakpoints()
216 JS_FreeValue(debuggerInfo->cx, filename); in DBG_SetBreakpoints()
219 JSValue pathData = JS_GetPropertyStr(debuggerInfo->cx, debuggerInfo->breakpoints, path); in DBG_SetBreakpoints()
222 JS_FreeValue(debuggerInfo->cx, pathData); in DBG_SetBreakpoints()
225 pathData = JS_NewObject(debuggerInfo->cx); in DBG_SetBreakpoints()
226 JS_SetPropertyStr(debuggerInfo->cx, debuggerInfo->breakpoints, path, pathData); in DBG_SetBreakpoints()
227 JS_FreeCString(debuggerInfo->cx, path); in DBG_SetBreakpoints()
228 JS_FreeValue(debuggerInfo->cx, filename); in DBG_SetBreakpoints()
230 JSValue jsBreakpoints = JS_GetPropertyStr(debuggerInfo->cx, breakpoints, "breakpoints"); in DBG_SetBreakpoints()
231 JS_SetPropertyStr(debuggerInfo->cx, pathData, "breakpoints", jsBreakpoints); in DBG_SetBreakpoints()
232 JS_FreeValue(debuggerInfo->cx, jsBreakpoints); in DBG_SetBreakpoints()
243 JSContext *cx = debuggerInfo->cx; in DBG_CotinueProcess() local
244 if (cx == NULL) { in DBG_CotinueProcess()
247 debuggerInfo->depth = JS_GetStackDepth(cx); in DBG_CotinueProcess()
248 LocInfo loc = JS_GetCurrentLocation(cx, pc); in DBG_CotinueProcess()
262 JSValue stackTrace = JS_BuildStackTrace(debuggerInfo->cx, curPc); in DBG_StackTraceProcess()
269 static void DBG_SetScopes(JSContext *cx, JSValue scopes, int scopeCount, int scopeType, int frameId) in DBG_SetScopes() argument
271 if (cx == NULL) { in DBG_SetScopes()
275 JSValue scopeObj = JS_NewObject(cx); in DBG_SetScopes()
280 JS_SetPropertyStr(cx, scopeObj, "name", JS_NewString(cx, "Global")); in DBG_SetScopes()
283 JS_SetPropertyStr(cx, scopeObj, "name", JS_NewString(cx, "Locals")); in DBG_SetScopes()
286 JS_SetPropertyStr(cx, scopeObj, "name", JS_NewString(cx, "Closure")); in DBG_SetScopes()
291 JS_SetPropertyStr(cx, scopeObj, "reference", in DBG_SetScopes()
292 JS_NewInt32(cx, (frameId << FRAME_MOVE_TWO_STEP) + scopeType)); in DBG_SetScopes()
293 JS_SetPropertyStr(cx, scopeObj, "expensive", expensiveFlag); in DBG_SetScopes()
294 JS_SetPropertyUint32(cx, scopes, scopeCount, scopeObj); in DBG_SetScopes()
299 uint32_t DBG_GetValueAsUint32Type(JSContext *cx, JSValue obj, const char *property) in DBG_GetValueAsUint32Type() argument
301 if (cx == NULL) { in DBG_GetValueAsUint32Type()
305 JSValue prop = JS_GetPropertyStr(cx, obj, property); in DBG_GetValueAsUint32Type()
307 JS_ToUint32(cx, &ret, prop); in DBG_GetValueAsUint32Type()
308 JS_FreeValue(cx, prop); in DBG_GetValueAsUint32Type()
320 JSContext *cx = debuggerInfo->cx; in DBG_ScopesProcess() local
321 if (cx == NULL) { in DBG_ScopesProcess()
325 JSValue argsValue = JS_GetPropertyStr(cx, msg, "args"); in DBG_ScopesProcess()
326 int frameId = DBG_GetValueAsUint32Type(cx, argsValue, "frameId"); in DBG_ScopesProcess()
331 JS_FreeValue(cx, argsValue); in DBG_ScopesProcess()
332 JSValue scopes = JS_NewArray(cx); in DBG_ScopesProcess()
334 DBG_SetScopes(cx, scopes, scopeCount++, LOCAL, frameId); in DBG_ScopesProcess()
335 DBG_SetScopes(cx, scopes, scopeCount++, CLOSURE, frameId); in DBG_ScopesProcess()
336 DBG_SetScopes(cx, scopes, scopeCount++, GLOBAL, frameId); in DBG_ScopesProcess()
338 JS_FreeValue(cx, scopes); in DBG_ScopesProcess()
349 JSContext *cx = debuggerInfo->cx; in DBG_SetStepOverToDebugger() local
350 if (cx == NULL) { in DBG_SetStepOverToDebugger()
354 debuggerInfo->depth = JS_GetStackDepth(cx); in DBG_SetStepOverToDebugger()
355 LocInfo loc = JS_GetCurrentLocation(cx, pc); in DBG_SetStepOverToDebugger()
369 JSContext *cx = debuggerInfo->cx; in DBG_SetStepOutToDebugger() local
370 if (cx == NULL) { in DBG_SetStepOutToDebugger()
374 debuggerInfo->depth = JS_GetStackDepth(cx); in DBG_SetStepOutToDebugger()
375 LocInfo loc = JS_GetCurrentLocation(cx, pc); in DBG_SetStepOutToDebugger()
389 JSContext *cx = debuggerInfo->cx; in DBG_SetStepInToDebugger() local
390 if (cx == NULL) { in DBG_SetStepInToDebugger()
394 debuggerInfo->depth = JS_GetStackDepth(cx); in DBG_SetStepInToDebugger()
395 LocInfo loc = JS_GetCurrentLocation(cx, pc); in DBG_SetStepInToDebugger()
403 static void DBG_FreePropEnum(JSContext *cx, JSPropertyEnum *tab, uint32_t len) in DBG_FreePropEnum() argument
405 if (cx == NULL || tab == NULL) { in DBG_FreePropEnum()
410 JS_FreeAtom(cx, tab[i].atom); in DBG_FreePropEnum()
412 js_free(cx, tab); in DBG_FreePropEnum()
417 static uint32_t DBG_GetObjectVariableReference(JSContext *cx, in DBG_GetObjectVariableReference() argument
422 if (cx == NULL || state == NULL) { in DBG_GetObjectVariableReference()
432 JSValue found = JS_GetPropertyUint32(cx, state->variablePointers, pVal); in DBG_GetObjectVariableReference()
435 JS_SetPropertyUint32(cx, state->variableReferences, reference, JS_DupValue(cx, varVal)); in DBG_GetObjectVariableReference()
436 JS_SetPropertyUint32(cx, state->variablePointers, pVal, JS_NewInt32(cx, reference)); in DBG_GetObjectVariableReference()
438 JS_ToUint32(cx, &reference, found); in DBG_GetObjectVariableReference()
440 JS_FreeValue(cx, found); in DBG_GetObjectVariableReference()
445 static void DBG_SetVariableType(JSContext *cx, in DBG_SetVariableType() argument
450 if (cx == NULL || state == NULL) { in DBG_SetVariableType()
459 JS_SetPropertyStr(cx, var, "type", JS_NewString(cx, "integer")); in DBG_SetVariableType()
463 JS_SetPropertyStr(cx, var, "type", JS_NewString(cx, "float")); in DBG_SetVariableType()
466 JS_SetPropertyStr(cx, var, "type", JS_NewString(cx, "bool")); in DBG_SetVariableType()
469 JS_SetPropertyStr(cx, var, "type", JS_NewString(cx, "string")); in DBG_SetVariableType()
472 JS_SetPropertyStr(cx, var, "type", JS_NewString(cx, "null")); in DBG_SetVariableType()
475 JS_SetPropertyStr(cx, var, "type", JS_NewString(cx, "exception")); in DBG_SetVariableType()
478 JS_SetPropertyStr(cx, var, "type", JS_NewString(cx, "undefined")); in DBG_SetVariableType()
481 JS_SetPropertyStr(cx, var, "type", JS_NewString(cx, "object")); in DBG_SetVariableType()
482 reference = DBG_GetObjectVariableReference(cx, state, var, varVal); in DBG_SetVariableType()
487 JS_SetPropertyStr(cx, var, "variablesReference", JS_NewInt32(cx, reference)); in DBG_SetVariableType()
492 static void DBG_SetVariableProperty(JSContext *cx, in DBG_SetVariableProperty() argument
497 if (cx == NULL || valueProperty == NULL) { in DBG_SetVariableProperty()
501 if (JS_IsArray(cx, varVal)) { in DBG_SetVariableProperty()
502 uint32_t len = DBG_GetValueAsUint32Type(cx, varVal, "length"); in DBG_SetVariableProperty()
507 JS_SetPropertyStr(cx, var, valueProperty, JS_NewString(cx, lenBuf)); in DBG_SetVariableProperty()
508 JS_SetPropertyStr(cx, var, "indexedVariables", JS_NewInt32(cx, len)); in DBG_SetVariableProperty()
510 JS_SetPropertyStr(cx, var, valueProperty, JS_ToString(cx, varVal)); in DBG_SetVariableProperty()
516 static JSValue DBG_GetVariableObj(JSContext *cx, in DBG_GetVariableObj() argument
521 if (cx == NULL || state == NULL) { in DBG_GetVariableObj()
525 JSValue var = JS_NewObject(cx); in DBG_GetVariableObj()
526 JS_SetPropertyStr(cx, var, "name", varName); in DBG_GetVariableObj()
527 DBG_SetVariableProperty(cx, varVal, var, "value"); in DBG_GetVariableObj()
528 DBG_SetVariableType(cx, state, var, varVal); in DBG_GetVariableObj()
533 static JSValue DBG_ProcessUndefinedVariable(JSContext *cx, struct DebuggerVariableState *state, in DBG_ProcessUndefinedVariable() argument
536 if (cx == NULL || state == NULL) { in DBG_ProcessUndefinedVariable()
542 if (frame >= JS_GetStackDepth(cx)) { in DBG_ProcessUndefinedVariable()
547 variable = JS_GetGlobalObject(cx); in DBG_ProcessUndefinedVariable()
550 variable = JS_GetLocalVariables(cx, frame); in DBG_ProcessUndefinedVariable()
553 variable = JS_GetClosureVariables(cx, frame); in DBG_ProcessUndefinedVariable()
558 JS_SetPropertyUint32(cx, state->variableReferences, reference, JS_DupValue(cx, variable)); in DBG_ProcessUndefinedVariable()
562 static JSValue DBG_VariablesUnFilteredProcess(JSContext *cx, in DBG_VariablesUnFilteredProcess() argument
567 if (cx == NULL || state == NULL) { in DBG_VariablesUnFilteredProcess()
573 if (JS_GetOwnPropertyNames(cx, &tabAtom, &tabAtomCount, variable, in DBG_VariablesUnFilteredProcess()
579 JSValue value = JS_GetProperty(cx, variable, tabAtom[idx].atom); in DBG_VariablesUnFilteredProcess()
580 JSValue variableJson = DBG_GetVariableObj(cx, state, in DBG_VariablesUnFilteredProcess()
581 JS_AtomToString(cx, tabAtom[idx].atom), value); in DBG_VariablesUnFilteredProcess()
582 JS_FreeValue(cx, value); in DBG_VariablesUnFilteredProcess()
583 JS_SetPropertyUint32(cx, properties, idx, variableJson); in DBG_VariablesUnFilteredProcess()
585 DBG_FreePropEnum(cx, tabAtom, tabAtomCount); in DBG_VariablesUnFilteredProcess()
590 static JSValue DBG_VariablesFilteredProcess(JSContext *cx, in DBG_VariablesFilteredProcess() argument
596 if (cx == NULL || state == NULL) { in DBG_VariablesFilteredProcess()
600 const char *filterStr = JS_ToCString(cx, JS_GetPropertyStr(cx, args, "filter")); in DBG_VariablesFilteredProcess()
606 JS_FreeCString(cx, filterStr); in DBG_VariablesFilteredProcess()
609 return DBG_VariablesUnFilteredProcess(cx, variable, properties, state); in DBG_VariablesFilteredProcess()
612 uint32_t start = DBG_GetValueAsUint32Type(cx, args, "start"); in DBG_VariablesFilteredProcess()
616 uint32_t count = DBG_GetValueAsUint32Type(cx, args, "count"); in DBG_VariablesFilteredProcess()
622 JSValue value = JS_GetPropertyUint32(cx, variable, start + i); in DBG_VariablesFilteredProcess()
626 JSValue variableJson = DBG_GetVariableObj(cx, state, JS_NewString(cx, nameBuf), value); in DBG_VariablesFilteredProcess()
627 JS_FreeValue(cx, value); in DBG_VariablesFilteredProcess()
628 JS_SetPropertyUint32(cx, properties, i, variableJson); in DBG_VariablesFilteredProcess()
642 JSContext *cx = debuggerInfo->cx; in DBG_VariablesProcess() local
643 if (cx == NULL) { in DBG_VariablesProcess()
647 JSValue args = JS_GetPropertyStr(cx, request, "args"); in DBG_VariablesProcess()
648 uint32_t reference = DBG_GetValueAsUint32Type(cx, args, "variablesReference"); in DBG_VariablesProcess()
649 JSValue properties = JS_NewArray(cx); in DBG_VariablesProcess()
650 JSValue variable = JS_GetPropertyUint32(cx, state->variableReferences, reference); in DBG_VariablesProcess()
652 variable = DBG_ProcessUndefinedVariable(cx, state, reference, variable); in DBG_VariablesProcess()
654 JSValue filter = JS_GetPropertyStr(cx, args, "filter"); in DBG_VariablesProcess()
656 properties = DBG_VariablesFilteredProcess(cx, args, variable, properties, state); in DBG_VariablesProcess()
658 properties = DBG_VariablesUnFilteredProcess(cx, variable, properties, state); in DBG_VariablesProcess()
660 JS_FreeValue(cx, variable); in DBG_VariablesProcess()
661 JS_FreeValue(cx, args); in DBG_VariablesProcess()
663 JS_FreeValue(cx, properties); in DBG_VariablesProcess()
676 JSContext *cx = debuggerInfo->cx; in DBG_EvaluateProcess() local
677 if (cx == NULL) { in DBG_EvaluateProcess()
681 JSValue argsJsVal = JS_GetPropertyStr(cx, msg, "args"); in DBG_EvaluateProcess()
682 JSValue expressionJsVal = JS_GetPropertyStr(cx, argsJsVal, "expression"); in DBG_EvaluateProcess()
683 JS_FreeValue(cx, argsJsVal); in DBG_EvaluateProcess()
685 JSValue frameJsVal = JS_GetPropertyStr(cx, argsJsVal, "frameId"); in DBG_EvaluateProcess()
686 JS_ToInt32(cx, &frameId, frameJsVal); in DBG_EvaluateProcess()
687 JS_FreeValue(cx, frameJsVal); in DBG_EvaluateProcess()
688 JSValue ret = JS_DebuggerEvaluate(cx, frameId, expressionJsVal); in DBG_EvaluateProcess()
691 JS_FreeValue(cx, ret); in DBG_EvaluateProcess()
692 ret = JS_GetException(cx); in DBG_EvaluateProcess()
694 JS_FreeValue(cx, expressionJsVal); in DBG_EvaluateProcess()
696 JSValue body = JS_NewObject(cx); in DBG_EvaluateProcess()
697 DBG_SetVariableProperty(cx, ret, body, "result"); in DBG_EvaluateProcess()
698 DBG_SetVariableType(cx, state, body, ret); in DBG_EvaluateProcess()
700 JS_FreeValue(cx, body); in DBG_EvaluateProcess()
724 JSContext *cx = debuggerInfo->cx; in DBG_RequestProcess() local
725 if (cx == NULL) { in DBG_RequestProcess()
730 JSValue jsRequestMsg = JS_GetPropertyStr(cx, msg, "request"); in DBG_RequestProcess()
731 JSValue jsCommand = JS_GetPropertyStr(cx, jsRequestMsg, "command"); in DBG_RequestProcess()
732 const char *command = JS_ToCString(cx, jsCommand); in DBG_RequestProcess()
761 JS_FreeCString(cx, command); in DBG_RequestProcess()
762 JS_FreeValue(cx, jsRequestMsg); in DBG_RequestProcess()
778 JSValue jsBreakpointsVal = JS_GetPropertyStr(debuggerInfo->cx, msg, "breakpoints"); in DBG_ProcessMsgByType()
780 JS_FreeValue(debuggerInfo->cx, jsBreakpointsVal); in DBG_ProcessMsgByType()
792 state.variableReferenceCount = JS_GetStackDepth(debuggerInfo->cx) << STACK_DEPTH_MOVE_TWO_STEP; in DBG_GetVariableState()
793 state.variablePointers = JS_NewObject(debuggerInfo->cx); in DBG_GetVariableState()
794 state.variableReferences = JS_NewObject(debuggerInfo->cx); in DBG_GetVariableState()
816 JSValue jsType = JS_GetPropertyStr(debuggerInfo->cx, msg, "type"); in DBG_ProcessMsg()
817 const char *type = JS_ToCString(debuggerInfo->cx, jsType); in DBG_ProcessMsg()
818 JS_FreeValue(debuggerInfo->cx, jsType); in DBG_ProcessMsg()
828 JS_FreeCString(debuggerInfo->cx, type); in DBG_ProcessMsg()
832 static void DBG_Entry(JSContext *cx, int client) in DBG_Entry() argument
834 if (cx == NULL) { in DBG_Entry()
838 struct DebuggerInfo *debuggerInfo = JS_GetDebuggerInfo(cx); in DBG_Entry()
843 debuggerInfo->cx = cx; in DBG_Entry()
845 debuggerInfo->breakpoints = JS_NewObject(cx); in DBG_Entry()
869 static int DBG_ProcessStepOperation(JSContext *cx, DebuggerInfo *debuggerInfo, const uint8_t *pc) in DBG_ProcessStepOperation() argument
871 if (cx == NULL || debuggerInfo == NULL) { in DBG_ProcessStepOperation()
876 uint32_t depth = JS_GetStackDepth(cx); in DBG_ProcessStepOperation()
877 LocInfo loc = JS_GetCurrentLocation(cx, pc); in DBG_ProcessStepOperation()
924 void DBG_FreeSources(JSContext *cx, DebuggerInfo *debuggerInfo) in DBG_FreeSources() argument
926 if (cx == NULL) { in DBG_FreeSources()
934 JS_FreeValue(cx, debuggerInfo->breakpoints); in DBG_FreeSources()
937 void DBG_CallDebugger(JSContext *cx, const uint8_t *pc) in DBG_CallDebugger() argument
939 if (cx == NULL) { in DBG_CallDebugger()
943 struct DebuggerInfo *debuggerInfo = JS_GetDebuggerInfo(cx); in DBG_CallDebugger()
960 DBG_Entry(cx, debuggerInfo->client); in DBG_CallDebugger()
969 DBG_Entry(cx, debuggerInfo->client); in DBG_CallDebugger()
981 uint32_t depth = JS_GetStackDepth(cx); in DBG_CallDebugger()
982 LocInfo loc = JS_GetCurrentLocation(cx, pc); in DBG_CallDebugger()
988 if (g_isBreakPointSet && JS_HitBreakpoint(cx, pc) && JS_JudgeConditionBreakPoint(cx, pc)) { in DBG_CallDebugger()
989 LocInfo loc = JS_GetCurrentLocation(cx, pc); in DBG_CallDebugger()
993 debuggerInfo->depth = JS_GetStackDepth(cx); in DBG_CallDebugger()
1001 int isNeedReadMsg = DBG_ProcessStepOperation(cx, debuggerInfo, pc); in DBG_CallDebugger()