Search in sources :

Example 11 with StackFrameProxyImpl

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

the class EvaluationDescriptor method calcValue.

public final Value calcValue(EvaluationContextImpl evaluationContext) throws EvaluateException {
    try {
        PsiDocumentManager.getInstance(myProject).commitAndRunReadAction(() -> {
        });
        EvaluationContextImpl thisEvaluationContext = getEvaluationContext(evaluationContext);
        SourcePosition position = ContextUtil.getSourcePosition(evaluationContext);
        PsiElement psiContext = ContextUtil.getContextElement(evaluationContext, position);
        ExpressionEvaluator evaluator = ReadAction.compute(() -> {
            PsiCodeFragment code = getEvaluationCode(thisEvaluationContext);
            try {
                return DebuggerUtilsEx.findAppropriateCodeFragmentFactory(getEvaluationText(), psiContext).getEvaluatorBuilder().build(code, position);
            } catch (UnsupportedExpressionException ex) {
                ExpressionEvaluator eval = CompilingEvaluatorImpl.create(myProject, code.getContext(), element -> code);
                if (eval != null) {
                    return eval;
                }
                throw ex;
            }
        });
        if (!thisEvaluationContext.getDebugProcess().isAttached()) {
            throw EvaluateExceptionUtil.PROCESS_EXITED;
        }
        StackFrameProxyImpl frameProxy = thisEvaluationContext.getFrameProxy();
        if (frameProxy == null) {
            throw EvaluateExceptionUtil.NULL_STACK_FRAME;
        }
        Value value = evaluator.evaluate(thisEvaluationContext);
        DebuggerUtilsEx.keep(value, thisEvaluationContext);
        myModifier = evaluator.getModifier();
        setLvalue(myModifier != null);
        return value;
    } catch (final EvaluateException ex) {
        throw new EvaluateException(ex.getLocalizedMessage(), ex);
    } catch (ObjectCollectedException ex) {
        throw EvaluateExceptionUtil.OBJECT_WAS_COLLECTED;
    }
}
Also used : StackFrameContext(com.intellij.debugger.engine.StackFrameContext) Modifier(com.intellij.debugger.engine.evaluation.expression.Modifier) DebuggerContextImpl(com.intellij.debugger.impl.DebuggerContextImpl) ContextUtil(com.intellij.debugger.engine.ContextUtil) DebuggerUtilsEx(com.intellij.debugger.impl.DebuggerUtilsEx) EvaluationContextImpl(com.intellij.debugger.engine.evaluation.EvaluationContextImpl) ReadAction(com.intellij.openapi.application.ReadAction) ExpressionEvaluator(com.intellij.debugger.engine.evaluation.expression.ExpressionEvaluator) XValueModifier(com.intellij.xdebugger.frame.XValueModifier) TextWithImports(com.intellij.debugger.engine.evaluation.TextWithImports) Project(com.intellij.openapi.project.Project) DebuggerBundle(com.intellij.debugger.DebuggerBundle) StackFrameProxyImpl(com.intellij.debugger.jdi.StackFrameProxyImpl) EvaluateException(com.intellij.debugger.engine.evaluation.EvaluateException) UnsupportedExpressionException(com.intellij.debugger.engine.evaluation.expression.UnsupportedExpressionException) JavaValueModifier(com.intellij.debugger.engine.JavaValueModifier) EvaluateExceptionUtil(com.intellij.debugger.engine.evaluation.EvaluateExceptionUtil) JavaValue(com.intellij.debugger.engine.JavaValue) Nullable(org.jetbrains.annotations.Nullable) DebuggerContext(com.intellij.debugger.DebuggerContext) DebuggerManagerEx(com.intellij.debugger.DebuggerManagerEx) com.sun.jdi(com.sun.jdi) com.intellij.psi(com.intellij.psi) NotNull(org.jetbrains.annotations.NotNull) SourcePosition(com.intellij.debugger.SourcePosition) StackFrameProxyImpl(com.intellij.debugger.jdi.StackFrameProxyImpl) EvaluateException(com.intellij.debugger.engine.evaluation.EvaluateException) EvaluationContextImpl(com.intellij.debugger.engine.evaluation.EvaluationContextImpl) SourcePosition(com.intellij.debugger.SourcePosition) JavaValue(com.intellij.debugger.engine.JavaValue) UnsupportedExpressionException(com.intellij.debugger.engine.evaluation.expression.UnsupportedExpressionException) ExpressionEvaluator(com.intellij.debugger.engine.evaluation.expression.ExpressionEvaluator)

Example 12 with StackFrameProxyImpl

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

the class ThreadsPanel method selectFrame.

private void selectFrame(DebuggerTreeNodeImpl node) {
    StackFrameProxyImpl frame = ((StackFrameDescriptorImpl) node.getDescriptor()).getFrameProxy();
    DebuggerContextUtil.setStackFrame(getContextManager(), frame);
}
Also used : StackFrameProxyImpl(com.intellij.debugger.jdi.StackFrameProxyImpl) StackFrameDescriptorImpl(com.intellij.debugger.ui.impl.watch.StackFrameDescriptorImpl)

Example 13 with StackFrameProxyImpl

use of com.intellij.debugger.jdi.StackFrameProxyImpl in project kotlin by JetBrains.

the class DebuggerSteppingHelper method createStepOutCommand.

public static DebugProcessImpl.ResumeCommand createStepOutCommand(final SuspendContextImpl suspendContext, final boolean ignoreBreakpoints, final List<KtNamedFunction> inlineFunctions, final KtFunctionLiteral inlineArgument) {
    final DebugProcessImpl debugProcess = suspendContext.getDebugProcess();
    return debugProcess.new ResumeCommand(suspendContext) {

        @Override
        public void contextAction() {
            try {
                StackFrameProxyImpl frameProxy = suspendContext.getFrameProxy();
                if (frameProxy != null) {
                    Action action = KotlinSteppingCommandProviderKt.getStepOutAction(frameProxy.location(), suspendContext, inlineFunctions, inlineArgument);
                    createStepRequest(suspendContext, getContextThread(), debugProcess.getVirtualMachineProxy().eventRequestManager(), StepRequest.STEP_LINE, StepRequest.STEP_OUT);
                    action.apply(debugProcess, suspendContext, ignoreBreakpoints);
                    return;
                }
                debugProcess.createStepOverCommand(suspendContext, ignoreBreakpoints).contextAction();
            } catch (EvaluateException ignored) {
            }
        }
    };
}
Also used : StackFrameProxyImpl(com.intellij.debugger.jdi.StackFrameProxyImpl) EvaluateException(com.intellij.debugger.engine.evaluation.EvaluateException) DebugProcessImpl(com.intellij.debugger.engine.DebugProcessImpl)

Example 14 with StackFrameProxyImpl

use of com.intellij.debugger.jdi.StackFrameProxyImpl in project kotlin by JetBrains.

the class DebuggerSteppingHelper method getCurrentClassName.

// copied from DebugProcessImpl.getActiveFilters
@Nullable
private static String getCurrentClassName(ThreadReferenceProxyImpl thread) {
    try {
        if (thread != null && thread.frameCount() > 0) {
            StackFrameProxyImpl stackFrame = thread.frame(0);
            if (stackFrame != null) {
                Location location = stackFrame.location();
                ReferenceType referenceType = location == null ? null : location.declaringType();
                if (referenceType != null) {
                    return referenceType.name();
                }
            }
        }
    } catch (EvaluateException ignored) {
    }
    return null;
}
Also used : StackFrameProxyImpl(com.intellij.debugger.jdi.StackFrameProxyImpl) EvaluateException(com.intellij.debugger.engine.evaluation.EvaluateException) ReferenceType(com.sun.jdi.ReferenceType) Location(com.sun.jdi.Location) Nullable(org.jetbrains.annotations.Nullable)

Example 15 with StackFrameProxyImpl

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

the class SourceCodeChecker method checkSource.

public static void checkSource(DebuggerContextImpl debuggerContext) {
    if (!Registry.is("debugger.check.source")) {
        return;
    }
    SuspendContextImpl suspendContext = debuggerContext.getSuspendContext();
    if (suspendContext == null) {
        return;
    }
    suspendContext.getDebugProcess().getManagerThread().schedule(new SuspendContextCommandImpl(suspendContext) {

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

        @Override
        public void contextAction() throws Exception {
            try {
                StackFrameProxyImpl frameProxy = debuggerContext.getFrameProxy();
                if (frameProxy == null) {
                    return;
                }
                Location location = frameProxy.location();
                check(location, debuggerContext.getSourcePosition(), suspendContext.getDebugProcess().getProject());
            //checkAllClasses(debuggerContext);
            } catch (EvaluateException e) {
                LOG.info(e);
            }
        }
    });
}
Also used : StackFrameProxyImpl(com.intellij.debugger.jdi.StackFrameProxyImpl) EvaluateException(com.intellij.debugger.engine.evaluation.EvaluateException) SuspendContextCommandImpl(com.intellij.debugger.engine.events.SuspendContextCommandImpl) SuspendContextImpl(com.intellij.debugger.engine.SuspendContextImpl) EvaluateException(com.intellij.debugger.engine.evaluation.EvaluateException) NoDataException(com.intellij.debugger.NoDataException)

Aggregations

StackFrameProxyImpl (com.intellij.debugger.jdi.StackFrameProxyImpl)21 EvaluateException (com.intellij.debugger.engine.evaluation.EvaluateException)14 Nullable (org.jetbrains.annotations.Nullable)6 SourcePosition (com.intellij.debugger.SourcePosition)5 DebugProcessImpl (com.intellij.debugger.engine.DebugProcessImpl)5 SuspendContextImpl (com.intellij.debugger.engine.SuspendContextImpl)4 DebuggerContextImpl (com.intellij.debugger.impl.DebuggerContextImpl)4 Project (com.intellij.openapi.project.Project)4 EvaluationContextImpl (com.intellij.debugger.engine.evaluation.EvaluationContextImpl)3 ExpressionEvaluator (com.intellij.debugger.engine.evaluation.expression.ExpressionEvaluator)3 Location (com.sun.jdi.Location)3 ObjectReference (com.sun.jdi.ObjectReference)3 DebuggerContextCommandImpl (com.intellij.debugger.engine.events.DebuggerContextCommandImpl)2 DebuggerUtilsEx (com.intellij.debugger.impl.DebuggerUtilsEx)2 ThreadReferenceProxyImpl (com.intellij.debugger.jdi.ThreadReferenceProxyImpl)2 Computable (com.intellij.openapi.util.Computable)2 com.intellij.psi (com.intellij.psi)2 PsiElement (com.intellij.psi.PsiElement)2 ThreeState (com.intellij.util.ThreeState)2 Method (com.sun.jdi.Method)2