Search in sources :

Example 6 with DebuggerCommandImpl

use of com.intellij.debugger.engine.events.DebuggerCommandImpl 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 7 with DebuggerCommandImpl

use of com.intellij.debugger.engine.events.DebuggerCommandImpl in project intellij-community by JetBrains.

the class DebuggerTree method rebuild.

public void rebuild(final DebuggerContextImpl context) {
    ApplicationManager.getApplication().assertIsDispatchThread();
    final DebugProcessImpl process = context.getDebugProcess();
    if (process == null) {
        // empty context, no process available yet
        return;
    }
    myDebuggerContext = context;
    saveState();
    process.getManagerThread().schedule(new DebuggerCommandImpl() {

        @Override
        protected void action() throws Exception {
            getNodeFactory().setHistoryByContext(context);
        }

        @Override
        public Priority getPriority() {
            return Priority.NORMAL;
        }
    });
    build(context);
}
Also used : DebuggerCommandImpl(com.intellij.debugger.engine.events.DebuggerCommandImpl) DebugProcessImpl(com.intellij.debugger.engine.DebugProcessImpl) EvaluateException(com.intellij.debugger.engine.evaluation.EvaluateException)

Example 8 with DebuggerCommandImpl

use of com.intellij.debugger.engine.events.DebuggerCommandImpl in project smali by JesusFreke.

the class SmaliSteppingCommandProvider method getStepOverCommand.

@Override
public ResumeCommand getStepOverCommand(@NotNull final SuspendContextImpl suspendContext, boolean ignoreBreakpoints, int stepSize) {
    final SourcePosition[] location = new SourcePosition[1];
    suspendContext.getDebugProcess().getManagerThread().invokeAndWait(new DebuggerCommandImpl() {

        @Override
        protected void action() throws Exception {
            location[0] = ContextUtil.getSourcePosition(suspendContext);
        }
    });
    if (location[0] != null && location[0].getFile().getLanguage() == SmaliLanguage.INSTANCE) {
        return suspendContext.getDebugProcess().createStepOverCommand(suspendContext, ignoreBreakpoints, StepRequest.STEP_MIN);
    }
    return null;
}
Also used : DebuggerCommandImpl(com.intellij.debugger.engine.events.DebuggerCommandImpl) SourcePosition(com.intellij.debugger.SourcePosition)

Example 9 with DebuggerCommandImpl

use of com.intellij.debugger.engine.events.DebuggerCommandImpl in project android by JetBrains.

the class InstantRunManager method refreshDebugger.

private void refreshDebugger(@NotNull String packageName) {
    // First we reapply the breakpoints on the new code, otherwise the breakpoints
    // remain set on the old classes and will never be hit again.
    ApplicationManager.getApplication().runReadAction(new Runnable() {

        @Override
        public void run() {
            DebuggerManagerEx debugger = DebuggerManagerEx.getInstanceEx(myProject);
            if (!debugger.getSessions().isEmpty()) {
                List<Breakpoint> breakpoints = debugger.getBreakpointManager().getBreakpoints();
                for (Breakpoint breakpoint : breakpoints) {
                    if (breakpoint.isEnabled()) {
                        breakpoint.setEnabled(false);
                        breakpoint.setEnabled(true);
                    }
                }
            }
        }
    });
    // Now we refresh the call-stacks and the variable panes.
    DebuggerManagerEx debugger = DebuggerManagerEx.getInstanceEx(myProject);
    for (final DebuggerSession session : debugger.getSessions()) {
        Client client = session.getProcess().getProcessHandler().getUserData(AndroidSessionInfo.ANDROID_DEBUG_CLIENT);
        if (client != null && client.isValid() && StringUtil.equals(packageName, client.getClientData().getClientDescription())) {
            session.getProcess().getManagerThread().invoke(new DebuggerCommandImpl() {

                @Override
                protected void action() throws Exception {
                    DebuggerContextImpl context = session.getContextManager().getContext();
                    SuspendContextImpl suspendContext = context.getSuspendContext();
                    if (suspendContext != null) {
                        XExecutionStack stack = suspendContext.getActiveExecutionStack();
                        if (stack != null) {
                            ((JavaExecutionStack) stack).initTopFrame();
                        }
                    }
                    ApplicationManager.getApplication().invokeLater(new Runnable() {

                        @Override
                        public void run() {
                            session.refresh(false);
                            XDebugSession xSession = session.getXDebugSession();
                            if (xSession != null) {
                                xSession.resume();
                            }
                        }
                    });
                }
            });
        }
    }
}
Also used : Breakpoint(com.intellij.debugger.ui.breakpoints.Breakpoint) XDebugSession(com.intellij.xdebugger.XDebugSession) DebuggerManagerEx(com.intellij.debugger.DebuggerManagerEx) XExecutionStack(com.intellij.xdebugger.frame.XExecutionStack) InstantRunPushFailedException(com.android.tools.fd.client.InstantRunPushFailedException) IOException(java.io.IOException) DebuggerSession(com.intellij.debugger.impl.DebuggerSession) DebuggerCommandImpl(com.intellij.debugger.engine.events.DebuggerCommandImpl) List(java.util.List) SuspendContextImpl(com.intellij.debugger.engine.SuspendContextImpl) DebuggerContextImpl(com.intellij.debugger.impl.DebuggerContextImpl) InstantRunClient(com.android.tools.fd.client.InstantRunClient) Client(com.android.ddmlib.Client)

Example 10 with DebuggerCommandImpl

use of com.intellij.debugger.engine.events.DebuggerCommandImpl 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

DebuggerCommandImpl (com.intellij.debugger.engine.events.DebuggerCommandImpl)24 DebugProcessImpl (com.intellij.debugger.engine.DebugProcessImpl)9 DebuggerContextImpl (com.intellij.debugger.impl.DebuggerContextImpl)8 ThreadReferenceProxyImpl (com.intellij.debugger.jdi.ThreadReferenceProxyImpl)5 EvaluateException (com.intellij.debugger.engine.evaluation.EvaluateException)4 Project (com.intellij.openapi.project.Project)4 SuspendContextImpl (com.intellij.debugger.engine.SuspendContextImpl)3 DebuggerSession (com.intellij.debugger.impl.DebuggerSession)3 DebuggerTreeNodeImpl (com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl)3 ThreadDescriptorImpl (com.intellij.debugger.ui.impl.watch.ThreadDescriptorImpl)3 ExecutionException (com.intellij.execution.ExecutionException)3 VMDisconnectedException (com.sun.jdi.VMDisconnectedException)3 List (java.util.List)3 SuspendContextCommandImpl (com.intellij.debugger.engine.events.SuspendContextCommandImpl)2 VirtualMachineProxyImpl (com.intellij.debugger.jdi.VirtualMachineProxyImpl)2 InvalidDataException (com.intellij.openapi.util.InvalidDataException)2 XDebugSession (com.intellij.xdebugger.XDebugSession)2 ArrayList (java.util.ArrayList)2 Client (com.android.ddmlib.Client)1 InstantRunClient (com.android.tools.fd.client.InstantRunClient)1