Search in sources :

Example 6 with ThreadReference

use of com.sun.jdi.ThreadReference in project intellij-community by JetBrains.

the class BreakpointManager method applyThreadFilter.

public void applyThreadFilter(@NotNull final DebugProcessImpl debugProcess, @Nullable ThreadReference newFilterThread) {
    final RequestManagerImpl requestManager = debugProcess.getRequestsManager();
    final ThreadReference oldFilterThread = requestManager.getFilterThread();
    if (Comparing.equal(newFilterThread, oldFilterThread)) {
        // the filter already added
        return;
    }
    requestManager.setFilterThread(newFilterThread);
    if (newFilterThread == null || oldFilterThread != null) {
        final List<Breakpoint> breakpoints = getBreakpoints();
        for (Breakpoint breakpoint : breakpoints) {
            if (LineBreakpoint.CATEGORY.equals(breakpoint.getCategory()) || MethodBreakpoint.CATEGORY.equals(breakpoint.getCategory())) {
                requestManager.deleteRequest(breakpoint);
                breakpoint.createRequest(debugProcess);
            }
        }
    } else {
        // important! need to add filter to _existing_ requests, otherwise Requestor->Request mapping will be lost
        // and debugger trees will not be restored to original state
        EventRequestManager eventRequestManager = requestManager.getVMRequestManager();
        if (eventRequestManager != null) {
            applyFilter(eventRequestManager.breakpointRequests(), request -> request.addThreadFilter(newFilterThread));
            applyFilter(eventRequestManager.methodEntryRequests(), request -> request.addThreadFilter(newFilterThread));
            applyFilter(eventRequestManager.methodExitRequests(), request -> request.addThreadFilter(newFilterThread));
        }
    }
}
Also used : ThreadReference(com.sun.jdi.ThreadReference) EventRequestManager(com.sun.jdi.request.EventRequestManager) RequestManagerImpl(com.intellij.debugger.engine.requests.RequestManagerImpl)

Example 7 with ThreadReference

use of com.sun.jdi.ThreadReference in project intellij-community by JetBrains.

the class ThreadGroupReferenceProxyImpl method threads.

public List<ThreadReferenceProxyImpl> threads() {
    List<ThreadReference> list = getThreadGroupReference().threads();
    List<ThreadReferenceProxyImpl> proxies = new ArrayList<>(list.size());
    for (ThreadReference threadReference : list) {
        proxies.add(getVirtualMachineProxy().getThreadReferenceProxy(threadReference));
    }
    return proxies;
}
Also used : ArrayList(java.util.ArrayList) ThreadReference(com.sun.jdi.ThreadReference)

Example 8 with ThreadReference

use of com.sun.jdi.ThreadReference 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 9 with ThreadReference

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

the class VMTargetRemoteTest method testDNU.

@Test
public void testDNU() throws Throwable {
    ObjectReference promise = remote.evaluateForked("3 fromage");
    ThreadReference thread = ((ThreadReference) remote.invokeMethod(promise, "thread"));
    remote.invokeMethod(thread, "start");
    ObjectReference state = (ObjectReference) remote.invokeMethod(thread, "getState");
    StringReference str = (StringReference) remote.invokeMethod(state, "toString");
    System.out.println(str.value());
    printStack(thread);
    //		assertFalse(thread.isSuspended());
    printThreadState();
    System.out.println("VMTargetStarter.sleep(1000)");
    VMTargetStarter.sleep(1000);
    printStack(thread);
    printThreadState();
    boolean isFinished = ((BooleanValue) remote.invokeMethod(promise, "isFinished")).booleanValue();
    assertFalse(isFinished);
    printThreadState();
    printStack(thread);
    assertTrue(thread.isAtBreakpoint());
}
Also used : ObjectReference(com.sun.jdi.ObjectReference) BooleanValue(com.sun.jdi.BooleanValue) ThreadReference(com.sun.jdi.ThreadReference) StringReference(com.sun.jdi.StringReference) Test(org.junit.Test)

Example 10 with ThreadReference

use of com.sun.jdi.ThreadReference in project intellij-community by JetBrains.

the class ThreadBlockedMonitor method onThreadBlocked.

private static void onThreadBlocked(@NotNull final ThreadReference blockedThread, @NotNull final ThreadReference blockingThread, final DebugProcessImpl process) {
    XDebugSessionImpl.NOTIFICATION_GROUP.createNotification(DebuggerBundle.message("status.thread.blocked.by", blockedThread.name(), blockingThread.name()), DebuggerBundle.message("status.thread.blocked.by.resume", blockingThread.name()), NotificationType.INFORMATION, (notification, event) -> {
        if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
            notification.expire();
            process.getManagerThread().schedule(new DebuggerCommandImpl() {

                @Override
                protected void action() throws Exception {
                    ThreadReferenceProxyImpl threadProxy = process.getVirtualMachineProxy().getThreadReferenceProxy(blockingThread);
                    SuspendContextImpl suspendingContext = SuspendManagerUtil.getSuspendingContext(process.getSuspendManager(), threadProxy);
                    process.getManagerThread().invoke(process.createResumeThreadCommand(suspendingContext, threadProxy));
                }
            });
        }
    }).notify(process.getProject());
}
Also used : ScheduledFuture(java.util.concurrent.ScheduledFuture) HyperlinkEvent(javax.swing.event.HyperlinkEvent) ThreadReferenceProxyImpl(com.intellij.debugger.jdi.ThreadReferenceProxyImpl) Collection(java.util.Collection) ThreadReference(com.sun.jdi.ThreadReference) XDebugSessionImpl(com.intellij.xdebugger.impl.XDebugSessionImpl) DebuggerCommandImpl(com.intellij.debugger.engine.events.DebuggerCommandImpl) Disposable(com.intellij.openapi.Disposable) NotificationType(com.intellij.notification.NotificationType) HashSet(java.util.HashSet) TimeUnit(java.util.concurrent.TimeUnit) IncompatibleThreadStateException(com.sun.jdi.IncompatibleThreadStateException) Nullable(org.jetbrains.annotations.Nullable) ThreadReferenceProxy(com.intellij.debugger.engine.jdi.ThreadReferenceProxy) Disposer(com.intellij.openapi.util.Disposer) VirtualMachineProxyImpl(com.intellij.debugger.jdi.VirtualMachineProxyImpl) Registry(com.intellij.openapi.util.registry.Registry) DebuggerBundle(com.intellij.debugger.DebuggerBundle) ObjectReference(com.sun.jdi.ObjectReference) Logger(com.intellij.openapi.diagnostic.Logger) NotNull(org.jetbrains.annotations.NotNull) JobScheduler(com.intellij.concurrency.JobScheduler) DebuggerCommandImpl(com.intellij.debugger.engine.events.DebuggerCommandImpl) ThreadReferenceProxyImpl(com.intellij.debugger.jdi.ThreadReferenceProxyImpl)

Aggregations

ThreadReference (com.sun.jdi.ThreadReference)13 ObjectReference (com.sun.jdi.ObjectReference)3 ThreadReferenceProxyImpl (com.intellij.debugger.jdi.ThreadReferenceProxyImpl)2 Breakpoint (com.intellij.debugger.ui.breakpoints.Breakpoint)2 StackCapturingLineBreakpoint (com.intellij.debugger.ui.breakpoints.StackCapturingLineBreakpoint)2 XBreakpoint (com.intellij.xdebugger.breakpoints.XBreakpoint)2 BooleanValue (com.sun.jdi.BooleanValue)2 StringReference (com.sun.jdi.StringReference)2 Value (com.sun.jdi.Value)2 VirtualMachine (com.sun.jdi.VirtualMachine)2 BreakpointEvent (com.sun.jdi.event.BreakpointEvent)2 JobScheduler (com.intellij.concurrency.JobScheduler)1 DebuggerBundle (com.intellij.debugger.DebuggerBundle)1 DebuggerCommandImpl (com.intellij.debugger.engine.events.DebuggerCommandImpl)1 SuspendContextCommandImpl (com.intellij.debugger.engine.events.SuspendContextCommandImpl)1 ThreadReferenceProxy (com.intellij.debugger.engine.jdi.ThreadReferenceProxy)1 LocatableEventRequestor (com.intellij.debugger.engine.requests.LocatableEventRequestor)1 RequestManagerImpl (com.intellij.debugger.engine.requests.RequestManagerImpl)1 VirtualMachineProxyImpl (com.intellij.debugger.jdi.VirtualMachineProxyImpl)1 NotificationType (com.intellij.notification.NotificationType)1