Lines Matching defs:state

82 before sleeping, the switch back to RUNNING state when we get the token
88 We need to change to VMWAIT state at the *start* of posting an event,
119 u4 dvmJdwpNextRequestSerial(JdwpState* state)
121 dvmDbgLockMutex(&state->serialLock);
122 u4 result = state->requestSerial++;
123 dvmDbgUnlockMutex(&state->serialLock);
132 u4 dvmJdwpNextEventSerial(JdwpState* state)
134 dvmDbgLockMutex(&state->serialLock);
135 u4 result = state->eventSerial++;
136 dvmDbgUnlockMutex(&state->serialLock);
144 static void lockEventMutex(JdwpState* state)
147 dvmDbgLockMutex(&state->eventLock);
154 static void unlockEventMutex(JdwpState* state)
156 dvmDbgUnlockMutex(&state->eventLock);
186 JdwpError dvmJdwpRegisterEvent(JdwpState* state, JdwpEvent* pEvent)
188 lockEventMutex(state);
190 assert(state != NULL);
218 if (state->eventList != NULL) {
219 pEvent->next = state->eventList;
220 state->eventList->prev = pEvent;
222 state->eventList = pEvent;
223 state->numEvents++;
225 unlockEventMutex(state);
238 static void unregisterEvent(JdwpState* state, JdwpEvent* pEvent)
242 assert(state->eventList == pEvent);
244 state->eventList = pEvent->next;
270 state->numEvents--;
271 assert(state->numEvents != 0 || state->eventList == NULL);
281 void dvmJdwpUnregisterEventById(JdwpState* state, u4 requestId)
283 lockEventMutex(state);
285 JdwpEvent* pEvent = state->eventList;
288 unregisterEvent(state, pEvent);
299 unlockEventMutex(state);
305 void dvmJdwpUnregisterAll(JdwpState* state)
307 lockEventMutex(state);
309 JdwpEvent* pEvent = state->eventList;
313 unregisterEvent(state, pEvent);
318 state->eventList = NULL;
320 unlockEventMutex(state);
352 /* want to assert state->eventList != pEvent */
375 * The state->eventLock should be held before calling.
377 static JdwpEvent** allocMatchList(JdwpState* state)
379 return (JdwpEvent**) malloc(sizeof(JdwpEvent*) * state->numEvents);
386 static void cleanupMatchList(JdwpState* state, JdwpEvent** matchList,
399 unregisterEvent(state, pEvent);
461 static bool modsMatch(JdwpState* state, JdwpEvent* pEvent, ModBasket* basket)
538 static void findMatchingEvents(JdwpState* state, JdwpEventKind eventKind,
544 JdwpEvent* pEvent = state->eventList;
546 if (pEvent->eventKind == eventKind && modsMatch(state, pEvent, basket))
580 static void suspendByPolicy(JdwpState* state, JdwpSuspendPolicy suspendPolicy)
592 if (dvmDbgGetThreadSelfId() == state->debugThreadId) {
613 dvmJdwpSetWaitForEventThread(state, dvmDbgGetThreadSelfId());
636 * state. If set, we're in the process of invoking a method.
638 static bool invokeInProgress(JdwpState* state)
654 void dvmJdwpSetWaitForEventThread(JdwpState* state, ObjectId threadId)
659 dvmDbgLockMutex(&state->eventThreadLock);
665 while (state->eventThreadId != 0) {
667 state->eventThreadId, threadId);
669 dvmDbgCondWait(&state->eventThreadCond, &state->eventThreadLock);
675 state->eventThreadId = threadId;
677 dvmDbgUnlockMutex(&state->eventThreadLock);
683 void dvmJdwpClearWaitForEventThread(JdwpState* state)
690 dvmDbgLockMutex(&state->eventThreadLock);
692 assert(state->eventThreadId != 0);
693 ALOGV("cleared event token (0x%llx)", state->eventThreadId);
695 state->eventThreadId = 0;
697 dvmDbgCondSignal(&state->eventThreadCond);
699 dvmDbgUnlockMutex(&state->eventThreadLock);
720 static void eventFinish(JdwpState* state, ExpandBuf* pReq)
725 set4BE(buf+4, dvmJdwpNextRequestSerial(state));
730 dvmJdwpSendRequest(state, pReq);
744 bool dvmJdwpPostVMStart(JdwpState* state, bool suspend)
755 lockEventMutex(state);
771 unlockEventMutex(state);
777 dvmJdwpSetWaitForEventThread(state, threadId);
779 eventFinish(state, pReq);
781 suspendByPolicy(state, suspendPolicy);
809 bool dvmJdwpPostLocationEvent(JdwpState* state, const JdwpLocation* pLoc,
830 if (basket.threadId == state->debugThreadId) {
845 if (invokeInProgress(state)) {
852 lockEventMutex(state);
854 JdwpEvent** matchList = allocMatchList(state);
858 findMatchingEvents(state, EK_BREAKPOINT, &basket, matchList,
861 findMatchingEvents(state, EK_SINGLE_STEP, &basket, matchList,
864 findMatchingEvents(state, EK_METHOD_ENTRY, &basket, matchList,
867 findMatchingEvents(state, EK_METHOD_EXIT, &basket, matchList,
894 cleanupMatchList(state, matchList, matchCount);
895 unlockEventMutex(state);
901 dvmJdwpSetWaitForEventThread(state, basket.threadId);
903 eventFinish(state, pReq);
905 suspendByPolicy(state, suspendPolicy);
919 bool dvmJdwpPostThreadChange(JdwpState* state, ObjectId threadId, bool start)
928 if (invokeInProgress(state)) {
938 lockEventMutex(state);
940 JdwpEvent** matchList = allocMatchList(state);
944 findMatchingEvents(state, EK_THREAD_START, &basket, matchList,
947 findMatchingEvents(state, EK_THREAD_DEATH, &basket, matchList,
972 cleanupMatchList(state, matchList, matchCount);
973 unlockEventMutex(state);
979 dvmJdwpSetWaitForEventThread(state, basket.threadId);
981 eventFinish(state, pReq);
983 suspendByPolicy(state, suspendPolicy);
995 bool dvmJdwpPostVMDeath(JdwpState* state)
1005 eventFinish(state, pReq);
1021 bool dvmJdwpPostException(JdwpState* state, const JdwpLocation* pThrowLoc,
1040 if (invokeInProgress(state)) {
1047 lockEventMutex(state);
1049 JdwpEvent** matchList = allocMatchList(state);
1052 findMatchingEvents(state, EK_EXCEPTION, &basket, matchList, &matchCount);
1095 cleanupMatchList(state, matchList, matchCount);
1096 unlockEventMutex(state);
1102 dvmJdwpSetWaitForEventThread(state, basket.threadId);
1104 eventFinish(state, pReq);
1106 suspendByPolicy(state, suspendPolicy);
1120 bool dvmJdwpPostClassPrepare(JdwpState* state, int tag, RefTypeId refTypeId,
1134 if (invokeInProgress(state)) {
1141 lockEventMutex(state);
1143 JdwpEvent** matchList = allocMatchList(state);
1146 findMatchingEvents(state, EK_CLASS_PREPARE, &basket, matchList,
1159 if (basket.threadId == state->debugThreadId) {
1187 cleanupMatchList(state, matchList, matchCount);
1189 unlockEventMutex(state);
1195 dvmJdwpSetWaitForEventThread(state, basket.threadId);
1197 eventFinish(state, pReq);
1199 suspendByPolicy(state, suspendPolicy);
1213 bool dvmJdwpPostClassUnload(JdwpState* state, RefTypeId refTypeId)
1226 bool dvmJdwpPostFieldAccess(JdwpState* state, int STUFF, ObjectId thisPtr,
1240 void dvmJdwpDdmSendChunkV(JdwpState* state, int type, const struct iovec* iov,
1262 set4BE(header+4, dvmJdwpNextRequestSerial(state));
1276 dvmJdwpSendBufferedRequest(state, wrapiov, iovcnt+1);