Search in sources :

Example 1 with EventQueue

use of com.sun.jdi.event.EventQueue in project gravel by gravel-st.

the class VMRemoteTarget method eventLoop.

private void eventLoop() throws InterruptedException {
    System.out.println("eventLoop started");
    EventQueue eventQueue = vm.eventQueue();
    boolean isRunning = true;
    while (isRunning) {
        EventSet eventSet = eventQueue.remove();
        boolean mayResume = true;
        for (Event event : eventSet) {
            System.out.println(event);
            if (event instanceof VMDeathEvent || event instanceof VMDisconnectEvent) {
                isRunning = false;
            } else if (event instanceof ExceptionEvent) {
                mayResume = false;
            }
        }
        if (mayResume)
            eventSet.resume();
    }
}
Also used : ExceptionEvent(com.sun.jdi.event.ExceptionEvent) VMDisconnectEvent(com.sun.jdi.event.VMDisconnectEvent) VMDeathEvent(com.sun.jdi.event.VMDeathEvent) EventSet(com.sun.jdi.event.EventSet) Event(com.sun.jdi.event.Event) VMDisconnectEvent(com.sun.jdi.event.VMDisconnectEvent) VMDeathEvent(com.sun.jdi.event.VMDeathEvent) ExceptionEvent(com.sun.jdi.event.ExceptionEvent) EventQueue(com.sun.jdi.event.EventQueue)

Example 2 with EventQueue

use of com.sun.jdi.event.EventQueue in project gravel by gravel-st.

the class VMTargetStarter method createJVM.

public VMRemoteTarget createJVM() throws IOException, InterruptedException, IncompatibleThreadStateException {
    Process process = startSecondJVM(VMLocalTarget.class);
    sleep(90);
    // connect
    VirtualMachine vm = new VMAcquirer().connect(debugPort);
    ClassPrepareRequest createClassPrepareRequest = vm.eventRequestManager().createClassPrepareRequest();
    createClassPrepareRequest.addClassFilter(VMLocalTarget.class.getName());
    createClassPrepareRequest.enable();
    vm.resume();
    List<ThreadReference> allThreads = vm.allThreads();
    for (ThreadReference threadReference : allThreads) {
        System.out.println(threadReference + " isSuspended: " + threadReference.isSuspended() + " suspendCount: " + threadReference.suspendCount());
    }
    // process events
    EventQueue eventQueue = vm.eventQueue();
    while (true) {
        EventSet eventSet = eventQueue.remove();
        for (Event event : eventSet) {
            if (event instanceof ClassPrepareEvent) {
                event.request().disable();
                installHaltPoint(vm);
            }
            if (event instanceof VMDeathEvent || event instanceof VMDisconnectEvent) {
                return null;
            }
            if (event instanceof BreakpointEvent) {
                event.request().disable();
                ThreadReference thread = ((BreakpointEvent) event).thread();
                return new VMRemoteTarget(process, vm, thread, debugPort);
            }
        }
        eventSet.resume();
    }
}
Also used : VMDeathEvent(com.sun.jdi.event.VMDeathEvent) EventSet(com.sun.jdi.event.EventSet) ThreadReference(com.sun.jdi.ThreadReference) EventQueue(com.sun.jdi.event.EventQueue) ClassPrepareRequest(com.sun.jdi.request.ClassPrepareRequest) BreakpointEvent(com.sun.jdi.event.BreakpointEvent) ClassPrepareEvent(com.sun.jdi.event.ClassPrepareEvent) VMDisconnectEvent(com.sun.jdi.event.VMDisconnectEvent) BreakpointEvent(com.sun.jdi.event.BreakpointEvent) ClassPrepareEvent(com.sun.jdi.event.ClassPrepareEvent) Event(com.sun.jdi.event.Event) VMDisconnectEvent(com.sun.jdi.event.VMDisconnectEvent) VMDeathEvent(com.sun.jdi.event.VMDeathEvent) VirtualMachine(com.sun.jdi.VirtualMachine)

Aggregations

Event (com.sun.jdi.event.Event)2 EventQueue (com.sun.jdi.event.EventQueue)2 EventSet (com.sun.jdi.event.EventSet)2 VMDeathEvent (com.sun.jdi.event.VMDeathEvent)2 VMDisconnectEvent (com.sun.jdi.event.VMDisconnectEvent)2 ThreadReference (com.sun.jdi.ThreadReference)1 VirtualMachine (com.sun.jdi.VirtualMachine)1 BreakpointEvent (com.sun.jdi.event.BreakpointEvent)1 ClassPrepareEvent (com.sun.jdi.event.ClassPrepareEvent)1 ExceptionEvent (com.sun.jdi.event.ExceptionEvent)1 ClassPrepareRequest (com.sun.jdi.request.ClassPrepareRequest)1