Search in sources :

Example 11 with ThreadReferenceProxyImpl

use of com.intellij.debugger.jdi.ThreadReferenceProxyImpl in project intellij-community by JetBrains.

the class SuspendManagerUtil method prepareForResume.

public static Object prepareForResume(SuspendContextImpl context) {
    SuspendManager suspendManager = context.getDebugProcess().getSuspendManager();
    ThreadReferenceProxyImpl thread = context.getThread();
    ResumeData resumeData = new ResumeData(suspendManager.isFrozen(thread), context.myResumedThreads);
    if (resumeData.myIsFrozen) {
        suspendManager.unfreezeThread(thread);
    }
    LOG.debug("Resuming SuspendContextImpl...");
    if (context.myResumedThreads != null) {
        context.myResumedThreads.forEach(ThreadReferenceProxyImpl::suspend);
        context.myResumedThreads = null;
    }
    return resumeData;
}
Also used : ThreadReferenceProxyImpl(com.intellij.debugger.jdi.ThreadReferenceProxyImpl)

Example 12 with ThreadReferenceProxyImpl

use of com.intellij.debugger.jdi.ThreadReferenceProxyImpl in project intellij-community by JetBrains.

the class SuspendManagerUtil method restoreAfterResume.

public static void restoreAfterResume(SuspendContextImpl context, Object resumeData) {
    SuspendManager suspendManager = context.getDebugProcess().getSuspendManager();
    ResumeData data = (ResumeData) resumeData;
    ThreadReferenceProxyImpl thread = context.getThread();
    if (data.myIsFrozen && !suspendManager.isFrozen(thread)) {
        suspendManager.freezeThread(thread);
    }
    LOG.debug("RestoreAfterResume SuspendContextImpl...");
    LOG.assertTrue(context.myResumedThreads == null);
    if (data.myResumedThreads != null) {
        data.myResumedThreads.forEach(ThreadReferenceProxyImpl::resume);
        context.myResumedThreads = data.myResumedThreads;
    }
}
Also used : ThreadReferenceProxyImpl(com.intellij.debugger.jdi.ThreadReferenceProxyImpl)

Example 13 with ThreadReferenceProxyImpl

use of com.intellij.debugger.jdi.ThreadReferenceProxyImpl 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)

Example 14 with ThreadReferenceProxyImpl

use of com.intellij.debugger.jdi.ThreadReferenceProxyImpl in project intellij-community by JetBrains.

the class DebugProcessEvents method processStepEvent.

private void processStepEvent(SuspendContextImpl suspendContext, StepEvent event) {
    final ThreadReference thread = event.thread();
    //LOG.assertTrue(thread.isSuspended());
    preprocessEvent(suspendContext, thread);
    //noinspection HardCodedStringLiteral
    RequestHint hint = (RequestHint) event.request().getProperty("hint");
    deleteStepRequests(event.thread());
    boolean shouldResume = false;
    final Project project = getProject();
    if (hint != null) {
        final int nextStepDepth = hint.getNextStepDepth(suspendContext);
        if (nextStepDepth == RequestHint.RESUME) {
            getSession().clearSteppingThrough();
            shouldResume = true;
        } else if (nextStepDepth != RequestHint.STOP) {
            final ThreadReferenceProxyImpl threadProxy = suspendContext.getThread();
            doStep(suspendContext, threadProxy, hint.getSize(), nextStepDepth, hint);
            shouldResume = true;
        }
        if (!shouldResume && hint.isRestoreBreakpoints()) {
            DebuggerManagerEx.getInstanceEx(project).getBreakpointManager().enableBreakpoints(this);
        }
    }
    if (shouldResume) {
        getSuspendManager().voteResume(suspendContext);
    } else {
        showStatusText("");
        if (myReturnValueWatcher != null) {
            myReturnValueWatcher.disable();
        }
        getSuspendManager().voteSuspend(suspendContext);
        if (hint != null) {
            final MethodFilter methodFilter = hint.getMethodFilter();
            if (methodFilter instanceof NamedMethodFilter && !hint.wasStepTargetMethodMatched()) {
                final String message = "Method <b>" + ((NamedMethodFilter) methodFilter).getMethodName() + "()</b> has not been called";
                XDebugSessionImpl.NOTIFICATION_GROUP.createNotification(message, MessageType.INFO).notify(project);
            }
            if (hint.wasStepTargetMethodMatched() && hint.isResetIgnoreFilters()) {
                checkPositionNotFiltered(suspendContext.getThread(), filters -> mySession.resetIgnoreStepFiltersFlag());
            }
        }
    }
}
Also used : Project(com.intellij.openapi.project.Project) ThreadReference(com.sun.jdi.ThreadReference) ThreadReferenceProxyImpl(com.intellij.debugger.jdi.ThreadReferenceProxyImpl) StackCapturingLineBreakpoint(com.intellij.debugger.ui.breakpoints.StackCapturingLineBreakpoint) XBreakpoint(com.intellij.xdebugger.breakpoints.XBreakpoint) Breakpoint(com.intellij.debugger.ui.breakpoints.Breakpoint)

Example 15 with ThreadReferenceProxyImpl

use of com.intellij.debugger.jdi.ThreadReferenceProxyImpl in project intellij-community by JetBrains.

the class DebuggerContextCommandImpl method getSuspendContext.

@Nullable
@Override
public SuspendContextImpl getSuspendContext() {
    if (myCustomSuspendContext == null) {
        myCustomSuspendContext = super.getSuspendContext();
        ThreadReferenceProxyImpl thread = getThread();
        if (myCustomThread != null && (myCustomSuspendContext == null || myCustomSuspendContext.isResumed() || !myCustomSuspendContext.suspends(thread))) {
            myCustomSuspendContext = SuspendManagerUtil.findContextByThread(myDebuggerContext.getDebugProcess().getSuspendManager(), thread);
        }
    }
    return myCustomSuspendContext;
}
Also used : ThreadReferenceProxyImpl(com.intellij.debugger.jdi.ThreadReferenceProxyImpl) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

ThreadReferenceProxyImpl (com.intellij.debugger.jdi.ThreadReferenceProxyImpl)17 DebuggerCommandImpl (com.intellij.debugger.engine.events.DebuggerCommandImpl)6 DebugProcessImpl (com.intellij.debugger.engine.DebugProcessImpl)5 DebuggerContextImpl (com.intellij.debugger.impl.DebuggerContextImpl)4 Project (com.intellij.openapi.project.Project)4 SuspendContextImpl (com.intellij.debugger.engine.SuspendContextImpl)3 StackFrameProxyImpl (com.intellij.debugger.jdi.StackFrameProxyImpl)3 DebuggerTreeNodeImpl (com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl)3 ThreadDescriptorImpl (com.intellij.debugger.ui.impl.watch.ThreadDescriptorImpl)3 ObjectCollectedException (com.sun.jdi.ObjectCollectedException)3 DebuggerContextCommandImpl (com.intellij.debugger.engine.events.DebuggerContextCommandImpl)2 ThreadReferenceProxy (com.intellij.debugger.engine.jdi.ThreadReferenceProxy)2 VirtualMachineProxyImpl (com.intellij.debugger.jdi.VirtualMachineProxyImpl)2 StackCapturingLineBreakpoint (com.intellij.debugger.ui.breakpoints.StackCapturingLineBreakpoint)2 ThreadReference (com.sun.jdi.ThreadReference)2 Nullable (org.jetbrains.annotations.Nullable)2 Patches (com.intellij.Patches)1 JobScheduler (com.intellij.concurrency.JobScheduler)1 com.intellij.debugger (com.intellij.debugger)1 DebuggerBundle (com.intellij.debugger.DebuggerBundle)1