Search in sources :

Example 6 with ThreadReferenceProxyImpl

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

the class ForceEarlyReturnAction method actionPerformed.

public void actionPerformed(@NotNull AnActionEvent e) {
    final Project project = e.getProject();
    final JavaStackFrame stackFrame = PopFrameAction.getStackFrame(e);
    if (stackFrame == null || project == null) {
        return;
    }
    final DebuggerContextImpl debuggerContext = DebuggerAction.getDebuggerContext(e.getDataContext());
    final DebugProcessImpl debugProcess = debuggerContext.getDebugProcess();
    if (debugProcess == null) {
        return;
    }
    final StackFrameProxyImpl proxy = stackFrame.getStackFrameProxy();
    final ThreadReferenceProxyImpl thread = proxy.threadProxy();
    debugProcess.getManagerThread().schedule(new DebuggerContextCommandImpl(debuggerContext, thread) {

        @Override
        public void threadAction() {
            Method method;
            try {
                method = proxy.location().method();
            } catch (EvaluateException e) {
                showError(project, DebuggerBundle.message("error.early.return", e.getLocalizedMessage()));
                return;
            }
            if ("void".equals(method.returnTypeName())) {
                forceEarlyReturnWithFinally(thread.getVirtualMachine().mirrorOfVoid(), stackFrame, debugProcess, null);
            } else {
                ApplicationManager.getApplication().invokeLater(() -> new ReturnExpressionDialog(project, debugProcess.getXdebugProcess().getEditorsProvider(), debugProcess, stackFrame).show());
            }
        }
    });
}
Also used : Project(com.intellij.openapi.project.Project) StackFrameProxyImpl(com.intellij.debugger.jdi.StackFrameProxyImpl) EvaluateException(com.intellij.debugger.engine.evaluation.EvaluateException) DebugProcessImpl(com.intellij.debugger.engine.DebugProcessImpl) JavaStackFrame(com.intellij.debugger.engine.JavaStackFrame) DebuggerContextImpl(com.intellij.debugger.impl.DebuggerContextImpl) Method(com.sun.jdi.Method) ThreadReferenceProxyImpl(com.intellij.debugger.jdi.ThreadReferenceProxyImpl) DebuggerContextCommandImpl(com.intellij.debugger.engine.events.DebuggerContextCommandImpl)

Example 7 with ThreadReferenceProxyImpl

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

the class FreezeThreadAction method actionPerformed.

public void actionPerformed(final AnActionEvent e) {
    DebuggerTreeNodeImpl[] selectedNode = getSelectedNodes(e.getDataContext());
    if (selectedNode == null) {
        return;
    }
    final DebuggerContextImpl debuggerContext = getDebuggerContext(e.getDataContext());
    final DebugProcessImpl debugProcess = debuggerContext.getDebugProcess();
    for (final DebuggerTreeNodeImpl debuggerTreeNode : selectedNode) {
        ThreadDescriptorImpl threadDescriptor = ((ThreadDescriptorImpl) debuggerTreeNode.getDescriptor());
        final ThreadReferenceProxyImpl thread = threadDescriptor.getThreadReference();
        if (!threadDescriptor.isFrozen()) {
            debugProcess.getManagerThread().schedule(new DebuggerCommandImpl() {

                @Override
                protected void action() throws Exception {
                    debugProcess.createFreezeThreadCommand(thread).run();
                    debuggerTreeNode.calcValue();
                }
            });
        }
    }
}
Also used : DebuggerTreeNodeImpl(com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl) DebuggerCommandImpl(com.intellij.debugger.engine.events.DebuggerCommandImpl) DebugProcessImpl(com.intellij.debugger.engine.DebugProcessImpl) ThreadDescriptorImpl(com.intellij.debugger.ui.impl.watch.ThreadDescriptorImpl) DebuggerContextImpl(com.intellij.debugger.impl.DebuggerContextImpl) ThreadReferenceProxyImpl(com.intellij.debugger.jdi.ThreadReferenceProxyImpl)

Example 8 with ThreadReferenceProxyImpl

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

the class ThreadDescriptorImpl method setContext.

public void setContext(EvaluationContextImpl context) {
    final ThreadReferenceProxyImpl thread = getThreadReference();
    final SuspendManager suspendManager = context != null ? context.getDebugProcess().getSuspendManager() : null;
    final SuspendContextImpl suspendContext = context != null ? context.getSuspendContext() : null;
    try {
        myIsSuspended = suspendManager != null ? suspendManager.isSuspended(thread) : thread.isSuspended();
    } catch (ObjectCollectedException e) {
        myIsSuspended = false;
    }
    myIsExpandable = calcExpandable(myIsSuspended);
    mySuspendContext = suspendManager != null ? SuspendManagerUtil.findContextByThread(suspendManager, thread) : suspendContext;
    myIsAtBreakpoint = thread.isAtBreakpoint();
    myIsCurrent = suspendContext != null ? suspendContext.getThread() == thread : false;
    myIsFrozen = suspendManager != null ? suspendManager.isFrozen(thread) : myIsSuspended;
}
Also used : ObjectCollectedException(com.sun.jdi.ObjectCollectedException) SuspendContextImpl(com.intellij.debugger.engine.SuspendContextImpl) ThreadReferenceProxyImpl(com.intellij.debugger.jdi.ThreadReferenceProxyImpl) SuspendManager(com.intellij.debugger.engine.SuspendManager)

Example 9 with ThreadReferenceProxyImpl

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

the class ThreadGroupDescriptorImpl method setContext.

public void setContext(EvaluationContextImpl context) {
    ThreadReferenceProxyImpl threadProxy = context != null ? context.getSuspendContext().getThread() : null;
    myIsCurrent = threadProxy != null && isDescendantGroup(threadProxy.threadGroupProxy());
    myIsExpandable = calcExpandable();
}
Also used : ThreadReferenceProxyImpl(com.intellij.debugger.jdi.ThreadReferenceProxyImpl)

Example 10 with ThreadReferenceProxyImpl

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

the class InterruptThreadAction method actionPerformed.

public void actionPerformed(final AnActionEvent e) {
    final DebuggerTreeNodeImpl[] nodes = getSelectedNodes(e.getDataContext());
    if (nodes == null) {
        return;
    }
    //noinspection ConstantConditions
    final List<ThreadReferenceProxyImpl> threadsToInterrupt = new ArrayList<>();
    for (final DebuggerTreeNodeImpl debuggerTreeNode : nodes) {
        final NodeDescriptorImpl descriptor = debuggerTreeNode.getDescriptor();
        if (descriptor instanceof ThreadDescriptorImpl) {
            threadsToInterrupt.add(((ThreadDescriptorImpl) descriptor).getThreadReference());
        }
    }
    if (!threadsToInterrupt.isEmpty()) {
        final DebuggerContextImpl debuggerContext = getDebuggerContext(e.getDataContext());
        final DebugProcessImpl debugProcess = debuggerContext.getDebugProcess();
        if (debugProcess != null) {
            debugProcess.getManagerThread().schedule(new DebuggerCommandImpl() {

                protected void action() throws Exception {
                    boolean unsupported = false;
                    for (ThreadReferenceProxyImpl thread : threadsToInterrupt) {
                        try {
                            thread.getThreadReference().interrupt();
                        } catch (UnsupportedOperationException ignored) {
                            unsupported = true;
                        }
                    }
                    if (unsupported) {
                        final Project project = debugProcess.getProject();
                        XDebugSessionImpl.NOTIFICATION_GROUP.createNotification("Thread operation 'interrupt' is not supported by VM", MessageType.INFO).notify(project);
                    }
                }
            });
        }
    }
}
Also used : DebuggerTreeNodeImpl(com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl) ArrayList(java.util.ArrayList) ThreadDescriptorImpl(com.intellij.debugger.ui.impl.watch.ThreadDescriptorImpl) ThreadReferenceProxyImpl(com.intellij.debugger.jdi.ThreadReferenceProxyImpl) Project(com.intellij.openapi.project.Project) DebuggerCommandImpl(com.intellij.debugger.engine.events.DebuggerCommandImpl) DebugProcessImpl(com.intellij.debugger.engine.DebugProcessImpl) DebuggerContextImpl(com.intellij.debugger.impl.DebuggerContextImpl) NodeDescriptorImpl(com.intellij.debugger.ui.impl.watch.NodeDescriptorImpl)

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