static void enqueueCommand(HelperCommand *command, jboolean wait, jboolean reportingVMDeath) { static jboolean vmDeathReported = JNI_FALSE; CommandQueue *queue = &commandQueue; jint size = commandSize(command); command->done = JNI_FALSE; command->waiting = wait; command->next = NULL; debugMonitorEnter(commandQueueLock); while (size + currentQueueSize > maxQueueSize) { debugMonitorWait(commandQueueLock); } log_debugee_location("enqueueCommand(): HelperCommand being processed", NULL, NULL, 0); if (vmDeathReported) { /* send no more events after VMDeath and don't wait */ wait = JNI_FALSE; } else { currentQueueSize += size; if (queue->head == NULL) { queue->head = command; } else { queue->tail->next = command; } queue->tail = command; if (reportingVMDeath) { vmDeathReported = JNI_TRUE; } } debugMonitorNotifyAll(commandQueueLock); debugMonitorExit(commandQueueLock); if (wait) { debugMonitorEnter(commandCompleteLock); while (!command->done) { log_debugee_location("enqueueCommand(): HelperCommand wait", NULL, NULL, 0); debugMonitorWait(commandCompleteLock); } freeCommand(command); debugMonitorExit(commandCompleteLock); } }
/* * We wait for either ThreadReferenceImpl.c: resume() or * VirtualMachineImpl.c: resume() to be called. */ static void doBlockCommandLoop(void) { debugMonitorEnter(blockCommandLoopLock); while (blockCommandLoop == JNI_TRUE) { debugMonitorWait(blockCommandLoopLock); } debugMonitorExit(blockCommandLoopLock); }
/* * Wait for all initialization to complete. */ void debugInit_waitInitComplete(void) { debugMonitorEnter(initMonitor); while (!initComplete) { debugMonitorWait(initMonitor); } debugMonitorExit(initMonitor); }
static HelperCommand * dequeueCommand(void) { HelperCommand *command = NULL; CommandQueue *queue = &commandQueue; jint size; debugMonitorEnter(commandQueueLock); while (command == NULL) { while (holdEvents || (queue->head == NULL)) { debugMonitorWait(commandQueueLock); } JDI_ASSERT(queue->head); command = queue->head; queue->head = command->next; if (queue->tail == command) { queue->tail = NULL; } log_debugee_location("dequeueCommand(): command being dequeued", NULL, NULL, 0); size = commandSize(command); /* * Immediately close out any commands enqueued from a * previously attached debugger. */ if (command->sessionID != currentSessionID) { log_debugee_location("dequeueCommand(): command session removal", NULL, NULL, 0); completeCommand(command); command = NULL; } /* * There's room in the queue for more. */ currentQueueSize -= size; debugMonitorNotifyAll(commandQueueLock); } debugMonitorExit(commandQueueLock); return command; }
void transport_waitForConnection(void) { /* * If the VM is suspended on debugger initialization, we wait * for a connection before continuing. This ensures that all * events are delivered to the debugger. (We might as well do this * this since the VM won't continue until a remote debugger attaches * and resumes it.) If not suspending on initialization, we must * just drop any packets (i.e. events) so that the VM can continue * to run. The debugger may not attach until much later. */ if (debugInit_suspendOnInit()) { debugMonitorEnter(listenerLock); while (transport == NULL) { debugMonitorWait(listenerLock); } debugMonitorExit(listenerLock); } }
static jboolean dequeue(jdwpPacket *packet) { struct PacketList *node = NULL; debugMonitorEnter(cmdQueueLock); while (!transportError && (cmdQueue == NULL)) { debugMonitorWait(cmdQueueLock); } if (cmdQueue != NULL) { node = (struct PacketList *)cmdQueue; cmdQueue = node->next; } debugMonitorExit(cmdQueueLock); if (node != NULL) { *packet = node->packet; jvmtiDeallocate(node); } return (node != NULL); }