Search in sources :

Example 1 with EvaluateException

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

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

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

the class DebuggerTreeCreatorImpl method createDescriptorByNode.

@Override
public void createDescriptorByNode(Object node, final ResultConsumer<Pair<NodeDescriptorImpl, String>> resultConsumer) {
    if (node instanceof DebuggerTreeNodeImpl) {
        final DebuggerTreeNodeImpl debuggerTreeNode = (DebuggerTreeNodeImpl) node;
        final DebuggerContextImpl context = DebuggerManagerEx.getInstanceEx(myProject).getContext();
        context.getDebugProcess().getManagerThread().schedule(new DebuggerContextCommandImpl(context) {

            @Override
            public void threadAction() {
                try {
                    final TextWithImports evaluationText = DebuggerTreeNodeExpression.createEvaluationText(debuggerTreeNode, context);
                    resultConsumer.onSuccess(Pair.create(debuggerTreeNode.getDescriptor(), evaluationText.getText()));
                } catch (EvaluateException e) {
                    resultConsumer.onFailure(e);
                }
            }
        });
    }
}
Also used : EvaluateException(com.intellij.debugger.engine.evaluation.EvaluateException) DebuggerTreeNodeImpl(com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl) TextWithImports(com.intellij.debugger.engine.evaluation.TextWithImports) DebuggerContextImpl(com.intellij.debugger.impl.DebuggerContextImpl) DebuggerContextCommandImpl(com.intellij.debugger.engine.events.DebuggerContextCommandImpl)

Example 4 with EvaluateException

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

the class JavaStackFrame method buildVariablesThreadAction.

// copied from DebuggerTree
private void buildVariablesThreadAction(DebuggerContextImpl debuggerContext, XValueChildrenList children, XCompositeNode node) {
    try {
        final EvaluationContextImpl evaluationContext = debuggerContext.createEvaluationContext();
        if (evaluationContext == null) {
            return;
        }
        if (!debuggerContext.isEvaluationPossible()) {
            node.setErrorMessage(MessageDescriptor.EVALUATION_NOT_POSSIBLE.getLabel());
        //myChildren.add(myNodeManager.createNode(MessageDescriptor.EVALUATION_NOT_POSSIBLE, evaluationContext));
        }
        final Location location = myDescriptor.getLocation();
        final ObjectReference thisObjectReference = myDescriptor.getThisObject();
        if (thisObjectReference != null) {
            ValueDescriptorImpl thisDescriptor = myNodeManager.getThisDescriptor(null, thisObjectReference);
            children.add(JavaValue.create(thisDescriptor, evaluationContext, myNodeManager));
        } else if (location != null) {
            StaticDescriptorImpl staticDecriptor = myNodeManager.getStaticDescriptor(myDescriptor, location.declaringType());
            if (staticDecriptor.isExpandable()) {
                children.addTopGroup(new JavaStaticGroup(staticDecriptor, evaluationContext, myNodeManager));
            }
        }
        DebugProcessImpl debugProcess = debuggerContext.getDebugProcess();
        if (debugProcess == null) {
            return;
        }
        // add last method return value if any
        final Pair<Method, Value> methodValuePair = debugProcess.getLastExecutedMethod();
        if (methodValuePair != null && myDescriptor.getUiIndex() == 0) {
            ValueDescriptorImpl returnValueDescriptor = myNodeManager.getMethodReturnValueDescriptor(myDescriptor, methodValuePair.getFirst(), methodValuePair.getSecond());
            children.add(JavaValue.create(returnValueDescriptor, evaluationContext, myNodeManager));
        }
        // add context exceptions
        Set<ObjectReference> exceptions = new HashSet<>();
        for (Pair<Breakpoint, Event> pair : DebuggerUtilsEx.getEventDescriptors(debuggerContext.getSuspendContext())) {
            Event debugEvent = pair.getSecond();
            if (debugEvent instanceof ExceptionEvent) {
                ObjectReference exception = ((ExceptionEvent) debugEvent).exception();
                if (exception != null) {
                    exceptions.add(exception);
                }
            }
        }
        exceptions.forEach(e -> children.add(JavaValue.create(myNodeManager.getThrownExceptionObjectDescriptor(myDescriptor, e), evaluationContext, myNodeManager)));
        try {
            buildVariables(debuggerContext, evaluationContext, debugProcess, children, thisObjectReference, location);
        //if (classRenderer.SORT_ASCENDING) {
        //  Collections.sort(myChildren, NodeManagerImpl.getNodeComparator());
        //}
        } catch (EvaluateException e) {
            node.setErrorMessage(e.getMessage());
        //myChildren.add(myNodeManager.createMessageNode(new MessageDescriptor(e.getMessage())));
        }
    } catch (InvalidStackFrameException e) {
        LOG.info(e);
    //myChildren.clear();
    //notifyCancelled();
    } catch (InternalException e) {
        if (e.errorCode() == 35) {
            node.setErrorMessage(DebuggerBundle.message("error.corrupt.debug.info", e.getMessage()));
        //myChildren.add(
        //  myNodeManager.createMessageNode(new MessageDescriptor(DebuggerBundle.message("error.corrupt.debug.info", e.getMessage()))));
        } else {
            throw e;
        }
    }
}
Also used : ExceptionEvent(com.sun.jdi.event.ExceptionEvent) Breakpoint(com.intellij.debugger.ui.breakpoints.Breakpoint) EvaluateException(com.intellij.debugger.engine.evaluation.EvaluateException) EvaluationContextImpl(com.intellij.debugger.engine.evaluation.EvaluationContextImpl) Event(com.sun.jdi.event.Event) ExceptionEvent(com.sun.jdi.event.ExceptionEvent)

Example 5 with EvaluateException

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

the class JavaValue method computePresentation.

@Override
public void computePresentation(@NotNull final XValueNode node, @NotNull XValuePlace place) {
    final SuspendContextImpl suspendContext = myEvaluationContext.getSuspendContext();
    myEvaluationContext.getManagerThread().schedule(new SuspendContextCommandImpl(suspendContext) {

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

        @Override
        protected void commandCancelled() {
            node.setPresentation(null, new XErrorValuePresentation(DebuggerBundle.message("error.context.has.changed")), false);
        }

        @Override
        public void contextAction() throws Exception {
            if (node.isObsolete()) {
                return;
            }
            if (!myContextSet) {
                myValueDescriptor.setContext(myEvaluationContext);
            }
            myValueDescriptor.updateRepresentation(myEvaluationContext, new DescriptorLabelListener() {

                @Override
                public void labelChanged() {
                    Icon nodeIcon = DebuggerTreeRenderer.getValueIcon(myValueDescriptor);
                    final String value = getValueString();
                    @SuppressWarnings("ThrowableResultOfMethodCallIgnored") EvaluateException exception = myValueDescriptor.getEvaluateException();
                    XValuePresentation presentation = new JavaValuePresentation(value, myValueDescriptor.getIdLabel(), exception != null ? exception.getMessage() : null, myValueDescriptor);
                    if (myValueDescriptor.getLastRenderer() instanceof FullValueEvaluatorProvider) {
                        XFullValueEvaluator evaluator = ((FullValueEvaluatorProvider) myValueDescriptor.getLastRenderer()).getFullValueEvaluator(myEvaluationContext, myValueDescriptor);
                        if (evaluator != null) {
                            node.setFullValueEvaluator(evaluator);
                        }
                    } else if (value.length() > XValueNode.MAX_VALUE_LENGTH) {
                        node.setFullValueEvaluator(new JavaFullValueEvaluator(myEvaluationContext) {

                            @Override
                            public void evaluate(@NotNull final XFullValueEvaluationCallback callback) {
                                final ValueDescriptorImpl fullValueDescriptor = myValueDescriptor.getFullValueDescriptor();
                                fullValueDescriptor.updateRepresentation(myEvaluationContext, new DescriptorLabelListener() {

                                    @Override
                                    public void labelChanged() {
                                        callback.evaluated(fullValueDescriptor.getValueText());
                                    }
                                });
                            }
                        });
                    }
                    node.setPresentation(nodeIcon, presentation, myValueDescriptor.isExpandable());
                }
            });
        }
    });
}
Also used : XValuePresentation(com.intellij.xdebugger.frame.presentation.XValuePresentation) SuspendContextCommandImpl(com.intellij.debugger.engine.events.SuspendContextCommandImpl) NotNull(org.jetbrains.annotations.NotNull) EvaluateException(com.intellij.debugger.engine.evaluation.EvaluateException) EvaluateException(com.intellij.debugger.engine.evaluation.EvaluateException) XErrorValuePresentation(com.intellij.xdebugger.frame.presentation.XErrorValuePresentation)

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