Search in sources :

Example 21 with DebuggerSession

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

the class ValueHint method evaluateAndShowHint.

@Override
protected void evaluateAndShowHint() {
    final DebuggerContextImpl debuggerContext = DebuggerManagerEx.getInstanceEx(getProject()).getContext();
    final DebuggerSession debuggerSession = debuggerContext.getDebuggerSession();
    if (debuggerSession == null || !debuggerSession.isPaused())
        return;
    try {
        final ExpressionEvaluator evaluator = getExpressionEvaluator(debuggerContext);
        if (evaluator == null)
            return;
        debuggerContext.getDebugProcess().getManagerThread().schedule(new DebuggerContextCommandImpl(debuggerContext) {

            @Override
            public Priority getPriority() {
                return Priority.HIGH;
            }

            @Override
            public void threadAction() {
                try {
                    final EvaluationContextImpl evaluationContext = debuggerContext.createEvaluationContext();
                    final String expressionText = ApplicationManager.getApplication().runReadAction(new Computable<String>() {

                        @Override
                        public String compute() {
                            return myCurrentExpression.getText();
                        }
                    });
                    final TextWithImports text = new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, expressionText);
                    final Value value = myValueToShow != null ? myValueToShow : evaluator.evaluate(evaluationContext);
                    final WatchItemDescriptor descriptor = new WatchItemDescriptor(getProject(), text, value);
                    if (!isActiveTooltipApplicable(value) || getType() == ValueHintType.MOUSE_OVER_HINT) {
                        if (getType() == ValueHintType.MOUSE_OVER_HINT) {
                            // force using default renderer for mouse over hint in order to not to call accidentally methods while rendering
                            // otherwise, if the hint is invoked explicitly, show it with the right "auto" renderer
                            descriptor.setRenderer(DebugProcessImpl.getDefaultRenderer(value));
                        }
                        descriptor.updateRepresentation(evaluationContext, new DescriptorLabelListener() {

                            @Override
                            public void labelChanged() {
                                if (getCurrentRange() != null) {
                                    if (getType() != ValueHintType.MOUSE_OVER_HINT || descriptor.isValueValid()) {
                                        final SimpleColoredText simpleColoredText = DebuggerTreeRenderer.getDescriptorText(debuggerContext, descriptor, true);
                                        if (isActiveTooltipApplicable(value)) {
                                            simpleColoredText.append(" (" + DebuggerBundle.message("active.tooltip.suggestion") + ")", SimpleTextAttributes.GRAYED_ATTRIBUTES);
                                        }
                                        showHint(simpleColoredText, descriptor);
                                    }
                                }
                            }
                        });
                    } else {
                        createAndShowTree(expressionText, descriptor);
                    }
                } catch (EvaluateException e) {
                    LOG.debug(e);
                }
            }
        });
    } catch (EvaluateException e) {
        LOG.debug(e);
    }
}
Also used : SimpleColoredText(com.intellij.ui.SimpleColoredText) DescriptorLabelListener(com.intellij.debugger.ui.tree.render.DescriptorLabelListener) ExpressionEvaluator(com.intellij.debugger.engine.evaluation.expression.ExpressionEvaluator) WatchItemDescriptor(com.intellij.debugger.ui.impl.watch.WatchItemDescriptor) DebuggerSession(com.intellij.debugger.impl.DebuggerSession) PrimitiveValue(com.sun.jdi.PrimitiveValue) Value(com.sun.jdi.Value) DebuggerContextImpl(com.intellij.debugger.impl.DebuggerContextImpl) DebuggerContextCommandImpl(com.intellij.debugger.engine.events.DebuggerContextCommandImpl)

Example 22 with DebuggerSession

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

the class ThreadsDebuggerTree method build.

protected void build(DebuggerContextImpl context) {
    DebuggerSession session = context.getDebuggerSession();
    final RefreshThreadsTreeCommand command = new RefreshThreadsTreeCommand(session);
    final DebuggerSession.State state = session != null ? session.getState() : DebuggerSession.State.DISPOSED;
    if (ApplicationManager.getApplication().isUnitTestMode() || state == DebuggerSession.State.PAUSED || state == DebuggerSession.State.RUNNING) {
        showMessage(MessageDescriptor.EVALUATING);
        context.getDebugProcess().getManagerThread().schedule(command);
    } else {
        showMessage(session != null ? session.getStateDescription() : DebuggerBundle.message("status.debug.stopped"));
    }
}
Also used : DebuggerSession(com.intellij.debugger.impl.DebuggerSession)

Example 23 with DebuggerSession

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

the class JavaStackFrame method customizePresentation.

@Override
public void customizePresentation(@NotNull ColoredTextContainer component) {
    StackFrameDescriptorImpl selectedDescriptor = null;
    DebuggerSession session = myDebugProcess.getSession();
    if (session != null) {
        XDebugSession xSession = session.getXDebugSession();
        if (xSession != null) {
            XStackFrame frame = xSession.getCurrentStackFrame();
            if (frame instanceof JavaStackFrame) {
                selectedDescriptor = ((JavaStackFrame) frame).getDescriptor();
            }
        }
    }
    FRAME_RENDERER.customizePresentation(myDescriptor, component, selectedDescriptor);
    if (myInsertCapturePoint != null) {
        component.setIcon(XDebuggerUIConstants.INFORMATION_MESSAGE_ICON);
    }
}
Also used : XDebugSession(com.intellij.xdebugger.XDebugSession) DebuggerSession(com.intellij.debugger.impl.DebuggerSession)

Example 24 with DebuggerSession

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

the class DebuggerTree method buildWhenPaused.

protected final void buildWhenPaused(DebuggerContextImpl context, RefreshDebuggerTreeCommand command) {
    DebuggerSession session = context.getDebuggerSession();
    if (ApplicationManager.getApplication().isUnitTestMode() || (session != null && session.getState() == DebuggerSession.State.PAUSED)) {
        showMessage(MessageDescriptor.EVALUATING);
        context.getDebugProcess().getManagerThread().schedule(command);
    } else {
        showMessage(session != null ? session.getStateDescription() : DebuggerBundle.message("status.debug.stopped"));
        if (session == null || session.isStopped()) {
            // save memory by clearing references on JDI objects
            getNodeFactory().clearHistory();
        }
    }
}
Also used : DebuggerSession(com.intellij.debugger.impl.DebuggerSession)

Example 25 with DebuggerSession

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

DebuggerSession (com.intellij.debugger.impl.DebuggerSession)25 DebuggerContextImpl (com.intellij.debugger.impl.DebuggerContextImpl)11 Project (com.intellij.openapi.project.Project)9 XDebugSession (com.intellij.xdebugger.XDebugSession)6 DebuggerManagerEx (com.intellij.debugger.DebuggerManagerEx)4 DebugProcessImpl (com.intellij.debugger.engine.DebugProcessImpl)4 Nullable (org.jetbrains.annotations.Nullable)4 SourcePosition (com.intellij.debugger.SourcePosition)3 DebuggerCommandImpl (com.intellij.debugger.engine.events.DebuggerCommandImpl)3 DebuggerContextCommandImpl (com.intellij.debugger.engine.events.DebuggerContextCommandImpl)3 DebugEnvironment (com.intellij.debugger.DebugEnvironment)2 SuspendContextImpl (com.intellij.debugger.engine.SuspendContextImpl)2 DebuggerTree (com.intellij.debugger.ui.impl.watch.DebuggerTree)2 DebuggerTreeNodeImpl (com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl)2 NodeDescriptorImpl (com.intellij.debugger.ui.impl.watch.NodeDescriptorImpl)2 WatchItemDescriptor (com.intellij.debugger.ui.impl.watch.WatchItemDescriptor)2 Presentation (com.intellij.openapi.actionSystem.Presentation)2 Ref (com.intellij.openapi.util.Ref)2 XDebugProcess (com.intellij.xdebugger.XDebugProcess)2 XDebugProcessStarter (com.intellij.xdebugger.XDebugProcessStarter)2