Search in sources :

Example 1 with VMDisconnectEvent

use of com.sun.jdi.event.VMDisconnectEvent in project ceylon by eclipse.

the class TracerImpl method start.

public void start() throws Exception {
    VirtualMachineManager vmm = com.sun.jdi.Bootstrap.virtualMachineManager();
    LaunchingConnector conn = vmm.defaultConnector();
    Map<String, Argument> defaultArguments = conn.defaultArguments();
    defaultArguments.get("main").setValue(mainClass);
    defaultArguments.get("options").setValue("-cp " + classPath);
    System.out.println(defaultArguments);
    vm = conn.launch(defaultArguments);
    err = vm.process().getErrorStream();
    out = vm.process().getInputStream();
    eq = vm.eventQueue();
    rm = vm.eventRequestManager();
    outer: while (true) {
        echo(err, System.err);
        echo(out, System.out);
        events = eq.remove();
        for (Event event : events) {
            if (event instanceof VMStartEvent) {
                System.out.println(event);
                break outer;
            } else if (event instanceof VMDisconnectEvent || event instanceof VMDeathEvent) {
                System.out.println(event);
                vm = null;
                rm = null;
                eq = null;
                break outer;
            }
        }
        events.resume();
    }
    echo(err, System.err);
    echo(out, System.out);
}
Also used : VMDisconnectEvent(com.sun.jdi.event.VMDisconnectEvent) Argument(com.sun.jdi.connect.Connector.Argument) VMDeathEvent(com.sun.jdi.event.VMDeathEvent) LaunchingConnector(com.sun.jdi.connect.LaunchingConnector) VMStartEvent(com.sun.jdi.event.VMStartEvent) MethodEntryEvent(com.sun.jdi.event.MethodEntryEvent) Event(com.sun.jdi.event.Event) VMDisconnectEvent(com.sun.jdi.event.VMDisconnectEvent) VMDeathEvent(com.sun.jdi.event.VMDeathEvent) StepEvent(com.sun.jdi.event.StepEvent) VMStartEvent(com.sun.jdi.event.VMStartEvent) MethodExitEvent(com.sun.jdi.event.MethodExitEvent) VirtualMachineManager(com.sun.jdi.VirtualMachineManager)

Example 2 with VMDisconnectEvent

use of com.sun.jdi.event.VMDisconnectEvent 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 3 with VMDisconnectEvent

use of com.sun.jdi.event.VMDisconnectEvent in project warn-report by saaavsaaa.

the class debugger method execute.

private static void execute(Event event) throws Exception {
    if (event instanceof VMStartEvent) {
        System.out.println("VM started");
        eventSet.resume();
    } else if (event instanceof BreakpointEvent) {
        System.out.println("Reach Method printHello of test.Test");
        eventSet.resume();
    } else if (event instanceof MethodEntryEvent) {
        MethodEntryEvent mee = (MethodEntryEvent) event;
        Method method = mee.method();
        System.out.println(method.name() + " was Entered!");
        eventSet.resume();
    } else if (event instanceof VMDisconnectEvent) {
        vmExit = true;
    } else {
        eventSet.resume();
    }
}
Also used : BreakpointEvent(com.sun.jdi.event.BreakpointEvent) VMDisconnectEvent(com.sun.jdi.event.VMDisconnectEvent) VMStartEvent(com.sun.jdi.event.VMStartEvent) Method(com.sun.jdi.Method) MethodEntryEvent(com.sun.jdi.event.MethodEntryEvent)

Example 4 with VMDisconnectEvent

use of com.sun.jdi.event.VMDisconnectEvent 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)

Example 5 with VMDisconnectEvent

use of com.sun.jdi.event.VMDisconnectEvent in project ceylon-compiler by ceylon.

the class TracerImpl method start.

public void start() throws Exception {
    VirtualMachineManager vmm = com.sun.jdi.Bootstrap.virtualMachineManager();
    LaunchingConnector conn = vmm.defaultConnector();
    Map<String, Argument> defaultArguments = conn.defaultArguments();
    defaultArguments.get("main").setValue(mainClass);
    defaultArguments.get("options").setValue("-cp " + classPath);
    System.out.println(defaultArguments);
    vm = conn.launch(defaultArguments);
    err = vm.process().getErrorStream();
    out = vm.process().getInputStream();
    eq = vm.eventQueue();
    rm = vm.eventRequestManager();
    outer: while (true) {
        echo(err, System.err);
        echo(out, System.out);
        events = eq.remove();
        for (Event event : events) {
            if (event instanceof VMStartEvent) {
                System.out.println(event);
                break outer;
            } else if (event instanceof VMDisconnectEvent || event instanceof VMDeathEvent) {
                System.out.println(event);
                vm = null;
                rm = null;
                eq = null;
                break outer;
            }
        }
        events.resume();
    }
    echo(err, System.err);
    echo(out, System.out);
}
Also used : VMDisconnectEvent(com.sun.jdi.event.VMDisconnectEvent) Argument(com.sun.jdi.connect.Connector.Argument) VMDeathEvent(com.sun.jdi.event.VMDeathEvent) LaunchingConnector(com.sun.jdi.connect.LaunchingConnector) VMStartEvent(com.sun.jdi.event.VMStartEvent) MethodEntryEvent(com.sun.jdi.event.MethodEntryEvent) Event(com.sun.jdi.event.Event) VMDisconnectEvent(com.sun.jdi.event.VMDisconnectEvent) VMDeathEvent(com.sun.jdi.event.VMDeathEvent) StepEvent(com.sun.jdi.event.StepEvent) VMStartEvent(com.sun.jdi.event.VMStartEvent) MethodExitEvent(com.sun.jdi.event.MethodExitEvent) VirtualMachineManager(com.sun.jdi.VirtualMachineManager)

Aggregations

VMDisconnectEvent (com.sun.jdi.event.VMDisconnectEvent)5 Event (com.sun.jdi.event.Event)4 VMDeathEvent (com.sun.jdi.event.VMDeathEvent)4 MethodEntryEvent (com.sun.jdi.event.MethodEntryEvent)3 VMStartEvent (com.sun.jdi.event.VMStartEvent)3 VirtualMachineManager (com.sun.jdi.VirtualMachineManager)2 Argument (com.sun.jdi.connect.Connector.Argument)2 LaunchingConnector (com.sun.jdi.connect.LaunchingConnector)2 BreakpointEvent (com.sun.jdi.event.BreakpointEvent)2 EventQueue (com.sun.jdi.event.EventQueue)2 EventSet (com.sun.jdi.event.EventSet)2 MethodExitEvent (com.sun.jdi.event.MethodExitEvent)2 StepEvent (com.sun.jdi.event.StepEvent)2 Method (com.sun.jdi.Method)1 ThreadReference (com.sun.jdi.ThreadReference)1 VirtualMachine (com.sun.jdi.VirtualMachine)1 ClassPrepareEvent (com.sun.jdi.event.ClassPrepareEvent)1 ExceptionEvent (com.sun.jdi.event.ExceptionEvent)1 ClassPrepareRequest (com.sun.jdi.request.ClassPrepareRequest)1