Search in sources :

Example 41 with DebuggerContextImpl

use of com.intellij.debugger.impl.DebuggerContextImpl in project intellij-community by JetBrains.

the class LocalVariableDescriptorImpl method getModifier.

@Override
public XValueModifier getModifier(JavaValue value) {
    return new JavaValueModifier(value) {

        @Override
        protected void setValueImpl(@NotNull String expression, @NotNull XModificationCallback callback) {
            final LocalVariableProxyImpl local = LocalVariableDescriptorImpl.this.getLocalVariable();
            if (local != null) {
                final DebuggerContextImpl debuggerContext = DebuggerManagerEx.getInstanceEx(getProject()).getContext();
                set(expression, callback, debuggerContext, new SetValueRunnable() {

                    public void setValue(EvaluationContextImpl evaluationContext, Value newValue) throws ClassNotLoadedException, InvalidTypeException, EvaluateException {
                        debuggerContext.getFrameProxy().setValue(local, preprocessValue(evaluationContext, newValue, local.getType()));
                        update(debuggerContext);
                    }

                    public ReferenceType loadClass(EvaluationContextImpl evaluationContext, String className) throws InvocationException, ClassNotLoadedException, IncompatibleThreadStateException, InvalidTypeException, EvaluateException {
                        return evaluationContext.getDebugProcess().loadClass(evaluationContext, className, evaluationContext.getClassLoader());
                    }
                });
            }
        }
    };
}
Also used : LocalVariableProxyImpl(com.intellij.debugger.jdi.LocalVariableProxyImpl) NotNull(org.jetbrains.annotations.NotNull) EvaluateException(com.intellij.debugger.engine.evaluation.EvaluateException) JavaValueModifier(com.intellij.debugger.engine.JavaValueModifier) EvaluationContextImpl(com.intellij.debugger.engine.evaluation.EvaluationContextImpl) JavaValue(com.intellij.debugger.engine.JavaValue) DebuggerContextImpl(com.intellij.debugger.impl.DebuggerContextImpl)

Example 42 with DebuggerContextImpl

use of com.intellij.debugger.impl.DebuggerContextImpl 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)

Aggregations

DebuggerContextImpl (com.intellij.debugger.impl.DebuggerContextImpl)42 DebugProcessImpl (com.intellij.debugger.engine.DebugProcessImpl)20 DebuggerSession (com.intellij.debugger.impl.DebuggerSession)12 Project (com.intellij.openapi.project.Project)12 DebuggerContextCommandImpl (com.intellij.debugger.engine.events.DebuggerContextCommandImpl)11 DebuggerTreeNodeImpl (com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl)11 EvaluateException (com.intellij.debugger.engine.evaluation.EvaluateException)10 JavaValue (com.intellij.debugger.engine.JavaValue)9 DebuggerCommandImpl (com.intellij.debugger.engine.events.DebuggerCommandImpl)8 NotNull (org.jetbrains.annotations.NotNull)7 EvaluationContextImpl (com.intellij.debugger.engine.evaluation.EvaluationContextImpl)6 SourcePosition (com.intellij.debugger.SourcePosition)5 JavaValueModifier (com.intellij.debugger.engine.JavaValueModifier)5 SuspendContextImpl (com.intellij.debugger.engine.SuspendContextImpl)5 NodeDescriptorImpl (com.intellij.debugger.ui.impl.watch.NodeDescriptorImpl)5 ThreadReferenceProxyImpl (com.intellij.debugger.jdi.ThreadReferenceProxyImpl)4 ValueDescriptor (com.intellij.debugger.ui.tree.ValueDescriptor)4 List (java.util.List)4 StackFrameProxyImpl (com.intellij.debugger.jdi.StackFrameProxyImpl)3 ThreadDescriptorImpl (com.intellij.debugger.ui.impl.watch.ThreadDescriptorImpl)3