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);
}
}
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;
}
}
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());
}
});
}
}
};
}
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);
}
}
});
}
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;
}
}
Aggregations