• Home
  • Raw
  • Download

Lines Matching refs:debuggerInfo

90 static JSValue DBG_ReadMsg(DebuggerInfo *debuggerInfo)  in DBG_ReadMsg()  argument
92 if (debuggerInfo == NULL) { in DBG_ReadMsg()
96 while (QueueIsEmpty(debuggerInfo->client)) { in DBG_ReadMsg()
100 const char *message = QueueFront(debuggerInfo->client); in DBG_ReadMsg()
102 JSValue msg = JS_ParseJSON(debuggerInfo->cx, message, strlen(message), "<debugger>"); in DBG_ReadMsg()
103 QueuePop(debuggerInfo->client); in DBG_ReadMsg()
108 static void DBG_SendMsg(DebuggerInfo *debuggerInfo, JSValue msgBody) in DBG_SendMsg() argument
110 if (debuggerInfo == NULL) { in DBG_SendMsg()
113 JSContext *cx = debuggerInfo->cx; in DBG_SendMsg()
138 int writeMsgLenRet = DBG_SocketWrite(debuggerInfo->client, msglen, WRITE_MSG_LEN - 1); in DBG_SendMsg()
144 int writeMsgRet = DBG_SocketWrite(debuggerInfo->client, jsonStrMsg, len); in DBG_SendMsg()
151 int writeNewLineRet = DBG_SocketWrite(debuggerInfo->client, addLine, 1); in DBG_SendMsg()
160 static void DBG_SendStopMsg(DebuggerInfo *debuggerInfo, const char *stopReason) in DBG_SendStopMsg() argument
162 if (debuggerInfo == NULL) { in DBG_SendStopMsg()
166 JSContext *cx = debuggerInfo->cx; in DBG_SendStopMsg()
174 JS_SetPropertyStr(cx, stopEvent, "thread", JS_NewInt64(cx, (int64_t)debuggerInfo->client)); in DBG_SendStopMsg()
178 DBG_SendMsg(debuggerInfo, msgBody); in DBG_SendStopMsg()
184 static void DBG_SendResponseMsg(DebuggerInfo *debuggerInfo, JSValue request, JSValue body) in DBG_SendResponseMsg() argument
186 if (debuggerInfo == NULL) { in DBG_SendResponseMsg()
190 JSContext *cx = debuggerInfo->cx; in DBG_SendResponseMsg()
199 DBG_SendMsg(debuggerInfo, msgBody); in DBG_SendResponseMsg()
206 static void DBG_SetBreakpoints(DebuggerInfo *debuggerInfo, JSValue breakpoints) in DBG_SetBreakpoints() argument
208 if (debuggerInfo == NULL) { in DBG_SetBreakpoints()
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()
237 static void DBG_CotinueProcess(DebuggerInfo *debuggerInfo, JSValue msg, const uint8_t *pc) in DBG_CotinueProcess() argument
239 if (debuggerInfo == NULL) { in DBG_CotinueProcess()
243 JSContext *cx = debuggerInfo->cx; in DBG_CotinueProcess()
247 debuggerInfo->depth = JS_GetStackDepth(cx); in DBG_CotinueProcess()
249 debuggerInfo->stepOperation = STEP_CONTINUE; in DBG_CotinueProcess()
250 debuggerInfo->loc = loc; in DBG_CotinueProcess()
251 DBG_SendResponseMsg(debuggerInfo, msg, JS_UNDEFINED); in DBG_CotinueProcess()
256 static void DBG_StackTraceProcess(DebuggerInfo *debuggerInfo, JSValue msg, const uint8_t *curPc) in DBG_StackTraceProcess() argument
258 if (debuggerInfo == NULL) { in DBG_StackTraceProcess()
262 JSValue stackTrace = JS_BuildStackTrace(debuggerInfo->cx, curPc); in DBG_StackTraceProcess()
263 DBG_SendResponseMsg(debuggerInfo, msg, stackTrace); in DBG_StackTraceProcess()
314 static void DBG_ScopesProcess(DebuggerInfo *debuggerInfo, JSValue msg) in DBG_ScopesProcess() argument
316 if (debuggerInfo == NULL) { in DBG_ScopesProcess()
320 JSContext *cx = debuggerInfo->cx; in DBG_ScopesProcess()
337 DBG_SendResponseMsg(debuggerInfo, msg, scopes); in DBG_ScopesProcess()
343 static void DBG_SetStepOverToDebugger(DebuggerInfo *debuggerInfo, JSValue msg, const uint8_t *pc) in DBG_SetStepOverToDebugger() argument
345 if (debuggerInfo == NULL) { in DBG_SetStepOverToDebugger()
349 JSContext *cx = debuggerInfo->cx; in DBG_SetStepOverToDebugger()
354 debuggerInfo->depth = JS_GetStackDepth(cx); in DBG_SetStepOverToDebugger()
356 debuggerInfo->stepOperation = STEP_NEXT; in DBG_SetStepOverToDebugger()
357 debuggerInfo->loc = loc; in DBG_SetStepOverToDebugger()
358 DBG_SendResponseMsg(debuggerInfo, msg, JS_UNDEFINED); in DBG_SetStepOverToDebugger()
363 static void DBG_SetStepOutToDebugger(DebuggerInfo *debuggerInfo, JSValue msg, const uint8_t *pc) in DBG_SetStepOutToDebugger() argument
365 if (debuggerInfo == NULL) { in DBG_SetStepOutToDebugger()
369 JSContext *cx = debuggerInfo->cx; in DBG_SetStepOutToDebugger()
374 debuggerInfo->depth = JS_GetStackDepth(cx); in DBG_SetStepOutToDebugger()
376 debuggerInfo->stepOperation = STEP_OUT; in DBG_SetStepOutToDebugger()
377 debuggerInfo->loc = loc; in DBG_SetStepOutToDebugger()
378 DBG_SendResponseMsg(debuggerInfo, msg, JS_UNDEFINED); in DBG_SetStepOutToDebugger()
383 static void DBG_SetStepInToDebugger(DebuggerInfo *debuggerInfo, JSValue msg, const uint8_t *pc) in DBG_SetStepInToDebugger() argument
385 if (debuggerInfo == NULL) { in DBG_SetStepInToDebugger()
389 JSContext *cx = debuggerInfo->cx; in DBG_SetStepInToDebugger()
394 debuggerInfo->depth = JS_GetStackDepth(cx); in DBG_SetStepInToDebugger()
396 debuggerInfo->stepOperation = STEP_IN; in DBG_SetStepInToDebugger()
397 debuggerInfo->loc = loc; in DBG_SetStepInToDebugger()
398 DBG_SendResponseMsg(debuggerInfo, msg, JS_UNDEFINED); in DBG_SetStepInToDebugger()
634 static void DBG_VariablesProcess(DebuggerInfo *debuggerInfo, in DBG_VariablesProcess() argument
638 if (debuggerInfo == NULL || state == NULL) { in DBG_VariablesProcess()
642 JSContext *cx = debuggerInfo->cx; in DBG_VariablesProcess()
662 DBG_SendResponseMsg(debuggerInfo, request, properties); in DBG_VariablesProcess()
668 static void DBG_EvaluateProcess(DebuggerInfo *debuggerInfo, in DBG_EvaluateProcess() argument
672 if (debuggerInfo == NULL || state == NULL) { in DBG_EvaluateProcess()
676 JSContext *cx = debuggerInfo->cx; in DBG_EvaluateProcess()
699 DBG_SendResponseMsg(debuggerInfo, msg, body); in DBG_EvaluateProcess()
705 static void DBG_PauseProcess(DebuggerInfo *debuggerInfo, JSValue msg) in DBG_PauseProcess() argument
707 if (debuggerInfo == NULL) { in DBG_PauseProcess()
711 DBG_SendResponseMsg(debuggerInfo, msg, JS_UNDEFINED); in DBG_PauseProcess()
712 DBG_SendStopMsg(debuggerInfo, "pause"); in DBG_PauseProcess()
717 static int DBG_RequestProcess(DebuggerInfo *debuggerInfo, in DBG_RequestProcess() argument
721 if (debuggerInfo == NULL || state == NULL) { in DBG_RequestProcess()
724 JSContext *cx = debuggerInfo->cx; in DBG_RequestProcess()
738 DBG_CotinueProcess(debuggerInfo, jsRequestMsg, pc); in DBG_RequestProcess()
740 DBG_StackTraceProcess(debuggerInfo, jsRequestMsg, pc); in DBG_RequestProcess()
743 DBG_ScopesProcess(debuggerInfo, jsRequestMsg); in DBG_RequestProcess()
746 DBG_SetStepInToDebugger(debuggerInfo, jsRequestMsg, pc); in DBG_RequestProcess()
748 DBG_SetStepOutToDebugger(debuggerInfo, jsRequestMsg, pc); in DBG_RequestProcess()
750 DBG_SetStepOverToDebugger(debuggerInfo, jsRequestMsg, pc); in DBG_RequestProcess()
752 DBG_VariablesProcess(debuggerInfo, jsRequestMsg, state); in DBG_RequestProcess()
755 DBG_EvaluateProcess(debuggerInfo, jsRequestMsg, state); in DBG_RequestProcess()
758 DBG_PauseProcess(debuggerInfo, jsRequestMsg); in DBG_RequestProcess()
767 static int DBG_ProcessMsgByType(DebuggerInfo *debuggerInfo, const char *type, in DBG_ProcessMsgByType() argument
770 if (debuggerInfo == NULL || type == NULL) { in DBG_ProcessMsgByType()
775 return DBG_RequestProcess(debuggerInfo, msg, state); in DBG_ProcessMsgByType()
778 JSValue jsBreakpointsVal = JS_GetPropertyStr(debuggerInfo->cx, msg, "breakpoints"); in DBG_ProcessMsgByType()
779 DBG_SetBreakpoints(debuggerInfo, jsBreakpointsVal); in DBG_ProcessMsgByType()
780 JS_FreeValue(debuggerInfo->cx, jsBreakpointsVal); in DBG_ProcessMsgByType()
789 static DebuggerVariableState DBG_GetVariableState(DebuggerInfo *debuggerInfo, const uint8_t *pc) in DBG_GetVariableState() argument
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()
800 static void DBG_ProcessMsg(DebuggerInfo *debuggerInfo, const uint8_t *pc, int runningBreakpoint) in DBG_ProcessMsg() argument
802 if (debuggerInfo == NULL) { in DBG_ProcessMsg()
807 struct DebuggerVariableState state = DBG_GetVariableState(debuggerInfo, pc); in DBG_ProcessMsg()
811 JSValue msg = DBG_ReadMsg(debuggerInfo); in DBG_ProcessMsg()
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()
824 isNeedReadMsg = DBG_ProcessMsgByType(debuggerInfo, type, msg, &state); in DBG_ProcessMsg()
828 JS_FreeCString(debuggerInfo->cx, type); in DBG_ProcessMsg()
838 struct DebuggerInfo *debuggerInfo = JS_GetDebuggerInfo(cx); in DBG_Entry() local
839 if (debuggerInfo == NULL) { in DBG_Entry()
843 debuggerInfo->cx = cx; in DBG_Entry()
845 debuggerInfo->breakpoints = JS_NewObject(cx); in DBG_Entry()
847 DBG_SendStopMsg(debuggerInfo, "entry"); in DBG_Entry()
850 static int DBG_IsLocEqual(DebuggerInfo *debuggerInfo, uint32_t depth, LocInfo loc) in DBG_IsLocEqual() argument
852 if (debuggerInfo == NULL) { in DBG_IsLocEqual()
859 …OGI("DBG_IsLocEqual last depth %d, this depth %d, last line %d, this line %d", debuggerInfo->depth, in DBG_IsLocEqual()
860 depth, debuggerInfo->loc.line, loc.line); in DBG_IsLocEqual()
861 if ((debuggerInfo->depth == depth) && (debuggerInfo->loc.line == loc.line) && in DBG_IsLocEqual()
862 (debuggerInfo->loc.filename == loc.filename)) { in DBG_IsLocEqual()
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()
878 if (debuggerInfo->stepOperation == STEP_CONTINUE) { in DBG_ProcessStepOperation()
879 if (depth == debuggerInfo->depth) { in DBG_ProcessStepOperation()
882 debuggerInfo->stepOperation = NO_STEP_OPERATION; in DBG_ProcessStepOperation()
887 if (debuggerInfo->stepOperation == STEP_NEXT) { in DBG_ProcessStepOperation()
888 if (depth > debuggerInfo->depth || (loc.line == debuggerInfo->loc.line && in DBG_ProcessStepOperation()
889 loc.filename == debuggerInfo->loc.filename)) { in DBG_ProcessStepOperation()
893 DBG_SendStopMsg(debuggerInfo, "step"); in DBG_ProcessStepOperation()
894 debuggerInfo->stepOperation = NO_STEP_OPERATION; in DBG_ProcessStepOperation()
898 if (debuggerInfo->stepOperation == STEP_IN) { in DBG_ProcessStepOperation()
899 if ((loc.line == 0) || (loc.line == debuggerInfo->loc.line && in DBG_ProcessStepOperation()
900 loc.filename == debuggerInfo->loc.filename)) { in DBG_ProcessStepOperation()
904 DBG_SendStopMsg(debuggerInfo, "stepIn"); in DBG_ProcessStepOperation()
905 debuggerInfo->stepOperation = NO_STEP_OPERATION; in DBG_ProcessStepOperation()
909 if (debuggerInfo->stepOperation == STEP_OUT) { in DBG_ProcessStepOperation()
910 if (depth >= debuggerInfo->depth) { in DBG_ProcessStepOperation()
914 DBG_SendStopMsg(debuggerInfo, "stepOut"); in DBG_ProcessStepOperation()
915 debuggerInfo->stepOperation = NO_STEP_OPERATION; in DBG_ProcessStepOperation()
919 debuggerInfo->stepOperation = NO_STEP_OPERATION; in DBG_ProcessStepOperation()
924 void DBG_FreeSources(JSContext *cx, DebuggerInfo *debuggerInfo) in DBG_FreeSources() argument
930 if (debuggerInfo->client <= 0) { in DBG_FreeSources()
933 close(debuggerInfo->client); in DBG_FreeSources()
934 JS_FreeValue(cx, debuggerInfo->breakpoints); in DBG_FreeSources()
943 struct DebuggerInfo *debuggerInfo = JS_GetDebuggerInfo(cx); in DBG_CallDebugger() local
944 if (debuggerInfo == NULL) { in DBG_CallDebugger()
951 if (pthread_create(&tid, NULL, &DBG_StartAgent, (void*)debuggerInfo) != 0) { in DBG_CallDebugger()
957 while (debuggerInfo->isConnected != 1) { in DBG_CallDebugger()
960 DBG_Entry(cx, debuggerInfo->client); in DBG_CallDebugger()
962 DBG_ProcessMsg(debuggerInfo, pc, 0); in DBG_CallDebugger()
967 if (g_isAttachMode && (debuggerInfo->isConnected == 1 && !g_isBreakPointSet)) { in DBG_CallDebugger()
969 DBG_Entry(cx, debuggerInfo->client); in DBG_CallDebugger()
970 DBG_ProcessMsg(debuggerInfo, pc, 0); in DBG_CallDebugger()
974 if (QueueIsEmpty(debuggerInfo->client) == 0) { in DBG_CallDebugger()
975 DBG_ProcessMsg(debuggerInfo, pc, 1); in DBG_CallDebugger()
979 if (debuggerInfo->stepOperation != NO_STEP_OPERATION) { in DBG_CallDebugger()
983 if (DBG_IsLocEqual(debuggerInfo, depth, loc) == DBG_LOC_ISEQUAL) { in DBG_CallDebugger()
992 debuggerInfo->stepOperation = NO_STEP_OPERATION; in DBG_CallDebugger()
993 debuggerInfo->depth = JS_GetStackDepth(cx); in DBG_CallDebugger()
994 DBG_SendStopMsg(debuggerInfo, "breakpoint"); in DBG_CallDebugger()
995 DBG_ProcessMsg(debuggerInfo, pc, 0); in DBG_CallDebugger()
999 if (debuggerInfo->stepOperation != NO_STEP_OPERATION) { in DBG_CallDebugger()
1001 int isNeedReadMsg = DBG_ProcessStepOperation(cx, debuggerInfo, pc); in DBG_CallDebugger()
1006 DBG_ProcessMsg(debuggerInfo, pc, 0); in DBG_CallDebugger()