Search in sources :

Example 56 with EvaluateException

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

the class ClassLoadingUtils method getClassLoader.

public static ClassLoaderReference getClassLoader(EvaluationContext context, DebugProcess process) throws EvaluateException {
    try {
        // TODO [egor]: cache?
        ClassType loaderClass = (ClassType) process.findClass(context, "java.net.URLClassLoader", context.getClassLoader());
        Method ctorMethod = loaderClass.concreteMethodByName(JVMNameUtil.CONSTRUCTOR_NAME, "([Ljava/net/URL;Ljava/lang/ClassLoader;)V");
        ClassLoaderReference reference = (ClassLoaderReference) process.newInstance(context, loaderClass, ctorMethod, Arrays.asList(createURLArray(context), context.getClassLoader()));
        DebuggerUtilsEx.keep(reference, context);
        return reference;
    } catch (Exception e) {
        throw new EvaluateException("Error creating evaluation class loader: " + e, e);
    }
}
Also used : EvaluateException(com.intellij.debugger.engine.evaluation.EvaluateException) EvaluateException(com.intellij.debugger.engine.evaluation.EvaluateException) IOException(java.io.IOException)

Example 57 with EvaluateException

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

the class LocalVariableEvaluator method evaluate.

@Override
public Object evaluate(EvaluationContextImpl context) throws EvaluateException {
    StackFrameProxyImpl frameProxy = context.getFrameProxy();
    if (frameProxy == null) {
        throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.no.stackframe"));
    }
    try {
        ThreadReferenceProxyImpl threadProxy = null;
        int lastFrameIndex = -1;
        PsiVariable variable = null;
        DebugProcessImpl process = context.getDebugProcess();
        boolean topFrame = true;
        while (true) {
            try {
                LocalVariableProxyImpl local = frameProxy.visibleVariableByName(myLocalVariableName);
                if (local != null) {
                    if (topFrame || variable.equals(resolveVariable(frameProxy, myLocalVariableName, context.getProject(), process))) {
                        myEvaluatedVariable = local;
                        myContext = context;
                        return frameProxy.getValue(local);
                    }
                }
            } catch (EvaluateException e) {
                if (!(e.getCause() instanceof AbsentInformationException)) {
                    throw e;
                }
                // try to look in slots
                try {
                    Map<DecompiledLocalVariable, Value> vars = LocalVariablesUtil.fetchValues(frameProxy, process, true);
                    for (Map.Entry<DecompiledLocalVariable, Value> entry : vars.entrySet()) {
                        DecompiledLocalVariable var = entry.getKey();
                        if (var.getMatchedNames().contains(myLocalVariableName) || var.getDefaultName().equals(myLocalVariableName)) {
                            myEvaluatedDecompiledVariable = var;
                            myContext = context;
                            return entry.getValue();
                        }
                    }
                } catch (Exception e1) {
                    LOG.info(e1);
                }
            }
            if (myCanScanFrames) {
                if (topFrame) {
                    variable = resolveVariable(frameProxy, myLocalVariableName, context.getProject(), process);
                    if (variable == null)
                        break;
                }
                if (threadProxy == null) /* initialize it lazily */
                {
                    threadProxy = frameProxy.threadProxy();
                    lastFrameIndex = threadProxy.frameCount() - 1;
                }
                int currentFrameIndex = frameProxy.getFrameIndex();
                if (currentFrameIndex < lastFrameIndex) {
                    frameProxy = threadProxy.frame(currentFrameIndex + 1);
                    if (frameProxy != null) {
                        topFrame = false;
                        continue;
                    }
                }
            }
            break;
        }
        throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.local.variable.missing", myLocalVariableName));
    } catch (EvaluateException e) {
        myEvaluatedVariable = null;
        myContext = null;
        throw e;
    }
}
Also used : PsiVariable(com.intellij.psi.PsiVariable) EvaluateException(com.intellij.debugger.engine.evaluation.EvaluateException) EvaluateException(com.intellij.debugger.engine.evaluation.EvaluateException) DebugProcessImpl(com.intellij.debugger.engine.DebugProcessImpl) Map(java.util.Map)

Example 58 with EvaluateException

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

the class ArgumentValueDescriptorImpl method getModifier.

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

        @Override
        protected void setValueImpl(@NotNull String expression, @NotNull XModificationCallback callback) {
            final DecompiledLocalVariable local = ArgumentValueDescriptorImpl.this.getVariable();
            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 {
                        LocalVariablesUtil.setValue(debuggerContext.getFrameProxy().getStackFrame(), local.getSlot(), newValue);
                        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 : DecompiledLocalVariable(com.intellij.debugger.jdi.DecompiledLocalVariable) 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 59 with EvaluateException

use of com.intellij.debugger.engine.evaluation.EvaluateException 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)

Example 60 with EvaluateException

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

the class DescriptorTestCase method localVar.

protected LocalVariableDescriptorImpl localVar(DebuggerTree frameTree, EvaluationContextImpl evaluationContext, String name) {
    try {
        StackFrameProxy frameProxy = evaluationContext.getFrameProxy();
        assert frameProxy != null;
        LocalVariableDescriptorImpl local = frameTree.getNodeFactory().getLocalVariableDescriptor(null, frameProxy.visibleVariableByName(name));
        local.setContext(evaluationContext);
        return local;
    } catch (EvaluateException e) {
        error(e);
        return null;
    }
}
Also used : EvaluateException(com.intellij.debugger.engine.evaluation.EvaluateException) LocalVariableDescriptorImpl(com.intellij.debugger.ui.impl.watch.LocalVariableDescriptorImpl) StackFrameProxy(com.intellij.debugger.engine.jdi.StackFrameProxy)

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