Search in sources :

Example 36 with EvaluateException

use of com.intellij.debugger.engine.evaluation.EvaluateException in project intellij-community by JetBrains.

the class RuntimeTypeEvaluator method evaluate.

@Nullable
protected PsiType evaluate(final EvaluationContextImpl evaluationContext) throws EvaluateException {
    Project project = evaluationContext.getProject();
    SourcePosition position = ContextUtil.getSourcePosition(evaluationContext);
    ExpressionEvaluator evaluator = DebuggerInvocationUtil.commitAndRunReadAction(project, new EvaluatingComputable<ExpressionEvaluator>() {

        public ExpressionEvaluator compute() throws EvaluateException {
            return EvaluatorBuilderImpl.getInstance().build(myElement, position);
        }
    });
    final Value value = evaluator.evaluate(evaluationContext);
    if (value != null) {
        return getCastableRuntimeType(project, value);
    }
    throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.surrounded.expression.null"));
}
Also used : Project(com.intellij.openapi.project.Project) EvaluateException(com.intellij.debugger.engine.evaluation.EvaluateException) SourcePosition(com.intellij.debugger.SourcePosition) Value(com.sun.jdi.Value) ExpressionEvaluator(com.intellij.debugger.engine.evaluation.expression.ExpressionEvaluator) Nullable(org.jetbrains.annotations.Nullable)

Example 37 with EvaluateException

use of com.intellij.debugger.engine.evaluation.EvaluateException in project intellij-community by JetBrains.

the class BasicStepMethodFilter method locationMatches.

public boolean locationMatches(final DebugProcessImpl process, final Location location) throws EvaluateException {
    Method method = location.method();
    String name = method.name();
    if (!myTargetMethodName.equals(name)) {
        if (DebuggerUtilsEx.isLambdaName(name)) {
            SourcePosition position = process.getPositionManager().getSourcePosition(location);
            return ReadAction.compute(() -> {
                PsiElement psiMethod = DebuggerUtilsEx.getContainingMethod(position);
                if (psiMethod instanceof PsiLambdaExpression) {
                    PsiType type = ((PsiLambdaExpression) psiMethod).getFunctionalInterfaceType();
                    PsiMethod interfaceMethod = LambdaUtil.getFunctionalInterfaceMethod(type);
                    if (type != null && interfaceMethod != null && myTargetMethodName.equals(interfaceMethod.getName())) {
                        try {
                            return InheritanceUtil.isInheritor(type, myDeclaringClassName.getName(process).replace('$', '.'));
                        } catch (EvaluateException e) {
                            LOG.info(e);
                        }
                    }
                }
                return false;
            });
        }
        return false;
    }
    if (myTargetMethodSignature != null && !signatureMatches(method, myTargetMethodSignature.getName(process))) {
        return false;
    }
    if (method.isBridge()) {
        // skip bridge methods
        return false;
    }
    return DebuggerUtilsEx.isAssignableFrom(myDeclaringClassName.getName(process), location.declaringType());
}
Also used : EvaluateException(com.intellij.debugger.engine.evaluation.EvaluateException) SourcePosition(com.intellij.debugger.SourcePosition) Method(com.sun.jdi.Method)

Example 38 with EvaluateException

use of com.intellij.debugger.engine.evaluation.EvaluateException in project intellij-community by JetBrains.

the class ClassInstanceMethodFilter method onReached.

@Override
public int onReached(SuspendContextImpl context, RequestHint hint) {
    StackFrameProxyImpl proxy = context.getFrameProxy();
    if (proxy != null) {
        try {
            ObjectReference reference = proxy.thisObject();
            if (reference != null) {
                StepIntoBreakpoint breakpoint = DebuggerManagerEx.getInstanceEx(context.getDebugProcess().getProject()).getBreakpointManager().addStepIntoBreakpoint(myMethodFilter);
                if (breakpoint != null) {
                    breakpoint.addInstanceFilter(reference.uniqueID());
                    breakpoint.setInstanceFiltersEnabled(true);
                    setUpStepIntoBreakpoint(context, breakpoint, hint);
                    return RequestHint.RESUME;
                }
            }
        } catch (EvaluateException ignored) {
        }
    }
    return RequestHint.STOP;
}
Also used : StackFrameProxyImpl(com.intellij.debugger.jdi.StackFrameProxyImpl) EvaluateException(com.intellij.debugger.engine.evaluation.EvaluateException) ObjectReference(com.sun.jdi.ObjectReference) StepIntoBreakpoint(com.intellij.debugger.ui.breakpoints.StepIntoBreakpoint)

Example 39 with EvaluateException

use of com.intellij.debugger.engine.evaluation.EvaluateException in project intellij-community by JetBrains.

the class LocalVariablesUtil method setValue.

public static void setValue(StackFrame frame, int slot, Value value) throws EvaluateException {
    try {
        final Long frameId = ReflectionUtil.getField(frame.getClass(), frame, long.class, "id");
        final VirtualMachine vm = frame.virtualMachine();
        final Method stateMethod = vm.getClass().getDeclaredMethod("state");
        stateMethod.setAccessible(true);
        Object slotInfoArray = createSlotInfoArraySet(slot, value);
        Object ps;
        final Object vmState = stateMethod.invoke(vm);
        synchronized (vmState) {
            ps = ourEnqueueMethodSet.invoke(null, vm, frame.thread(), frameId, slotInfoArray);
        }
        ourWaitForReplyMethodSet.invoke(null, vm, ps);
    } catch (Exception e) {
        throw new EvaluateException("Unable to set value", e);
    }
}
Also used : EvaluateException(com.intellij.debugger.engine.evaluation.EvaluateException) Method(java.lang.reflect.Method) EvaluateException(com.intellij.debugger.engine.evaluation.EvaluateException) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 40 with EvaluateException

use of com.intellij.debugger.engine.evaluation.EvaluateException in project intellij-community by JetBrains.

the class StackFrameProxyImpl method getValue.

public Value getValue(LocalVariableProxyImpl localVariable) throws EvaluateException {
    DebuggerManagerThreadImpl.assertIsManagerThread();
    InvalidStackFrameException error = null;
    for (int attempt = 0; attempt < 2; attempt++) {
        try {
            Map<LocalVariable, Value> values = getAllValues();
            LocalVariable variable = localVariable.getVariable();
            if (values.containsKey(variable)) {
                return values.get(variable);
            } else {
                // try direct get
                return getStackFrame().getValue(variable);
            }
        } catch (InvalidStackFrameException e) {
            error = e;
            clearCaches();
        } catch (InternalException e) {
            if (e.errorCode() == 35 || e.errorCode() == 101) {
                throw new EvaluateException(DebuggerBundle.message("error.corrupt.debug.info", e.getMessage()), e);
            } else
                throw e;
        }
    }
    throw new EvaluateException(error.getMessage(), error);
}
Also used : EvaluateException(com.intellij.debugger.engine.evaluation.EvaluateException)

Aggregations

EvaluateException (com.intellij.debugger.engine.evaluation.EvaluateException)62 StackFrameProxyImpl (com.intellij.debugger.jdi.StackFrameProxyImpl)13 NotNull (org.jetbrains.annotations.NotNull)12 Nullable (org.jetbrains.annotations.Nullable)12 EvaluationContextImpl (com.intellij.debugger.engine.evaluation.EvaluationContextImpl)11 DebugProcessImpl (com.intellij.debugger.engine.DebugProcessImpl)10 DebuggerContextImpl (com.intellij.debugger.impl.DebuggerContextImpl)10 SourcePosition (com.intellij.debugger.SourcePosition)8 JavaValue (com.intellij.debugger.engine.JavaValue)8 JavaValueModifier (com.intellij.debugger.engine.JavaValueModifier)6 Value (com.sun.jdi.Value)6 Project (com.intellij.openapi.project.Project)5 IncorrectOperationException (com.intellij.util.IncorrectOperationException)5 Method (com.sun.jdi.Method)5 ObjectReference (com.sun.jdi.ObjectReference)5 TextWithImports (com.intellij.debugger.engine.evaluation.TextWithImports)4 ExpressionEvaluator (com.intellij.debugger.engine.evaluation.expression.ExpressionEvaluator)4 SuspendContextCommandImpl (com.intellij.debugger.engine.events.SuspendContextCommandImpl)4 SuspendContextImpl (com.intellij.debugger.engine.SuspendContextImpl)3 DebuggerContextCommandImpl (com.intellij.debugger.engine.events.DebuggerContextCommandImpl)3