Search in sources :

Example 1 with VMDisconnectedException

use of com.sun.jdi.VMDisconnectedException in project intellij-community by JetBrains.

the class RequestHint method getNextStepDepth.

public int getNextStepDepth(final SuspendContextImpl context) {
    try {
        final StackFrameProxyImpl frameProxy = context.getFrameProxy();
        // smart step feature stop check
        if (myMethodFilter != null && frameProxy != null && !(myMethodFilter instanceof BreakpointStepMethodFilter) && myMethodFilter.locationMatches(context.getDebugProcess(), frameProxy.location()) && !isTheSameFrame(context)) {
            myTargetMethodMatched = true;
            return myMethodFilter.onReached(context, this);
        }
        if ((myDepth == StepRequest.STEP_OVER || myDepth == StepRequest.STEP_INTO) && myPosition != null) {
            SourcePosition locationPosition = ContextUtil.getSourcePosition(context);
            if (locationPosition != null) {
                Integer resultDepth = ApplicationManager.getApplication().runReadAction(new Computable<Integer>() {

                    public Integer compute() {
                        if (myPosition.getFile().equals(locationPosition.getFile()) && isTheSameFrame(context) && !mySteppedOut) {
                            return isOnTheSameLine(locationPosition) ? myDepth : STOP;
                        }
                        return null;
                    }
                });
                if (resultDepth != null) {
                    return resultDepth.intValue();
                }
            }
        }
        // Now check filters
        final DebuggerSettings settings = DebuggerSettings.getInstance();
        if ((myMethodFilter != null || (settings.SKIP_SYNTHETIC_METHODS && !myIgnoreFilters)) && frameProxy != null) {
            final Location location = frameProxy.location();
            if (location != null) {
                if (DebuggerUtils.isSynthetic(location.method())) {
                    return myDepth;
                }
            }
        }
        if (!myIgnoreFilters) {
            if (settings.SKIP_GETTERS) {
                boolean isGetter = ApplicationManager.getApplication().runReadAction(new Computable<Boolean>() {

                    public Boolean compute() {
                        PsiElement contextElement = ContextUtil.getContextElement(context);
                        return contextElement != null && DebuggerUtils.isInsideSimpleGetter(contextElement);
                    }
                }).booleanValue();
                if (isGetter) {
                    return StepRequest.STEP_OUT;
                }
            }
            if (frameProxy != null) {
                if (settings.SKIP_CONSTRUCTORS) {
                    final Location location = frameProxy.location();
                    if (location != null) {
                        final Method method = location.method();
                        if (method != null && method.isConstructor()) {
                            return StepRequest.STEP_OUT;
                        }
                    }
                }
                if (settings.SKIP_CLASSLOADERS) {
                    final Location location = frameProxy.location();
                    if (location != null && DebuggerUtilsEx.isAssignableFrom("java.lang.ClassLoader", location.declaringType())) {
                        return StepRequest.STEP_OUT;
                    }
                }
            }
            for (ExtraSteppingFilter filter : ExtraSteppingFilter.EP_NAME.getExtensions()) {
                try {
                    if (filter.isApplicable(context))
                        return filter.getStepRequestDepth(context);
                } catch (Exception | AssertionError e) {
                    LOG.error(e);
                }
            }
        }
        // smart step feature
        if (myMethodFilter != null && !mySteppedOut) {
            return StepRequest.STEP_OUT;
        }
    } catch (VMDisconnectedException ignored) {
    } catch (EvaluateException e) {
        LOG.error(e);
    }
    return STOP;
}
Also used : StackFrameProxyImpl(com.intellij.debugger.jdi.StackFrameProxyImpl) DebuggerSettings(com.intellij.debugger.settings.DebuggerSettings) Method(com.sun.jdi.Method) EvaluateException(com.intellij.debugger.engine.evaluation.EvaluateException) VMDisconnectedException(com.sun.jdi.VMDisconnectedException) VMDisconnectedException(com.sun.jdi.VMDisconnectedException) EvaluateException(com.intellij.debugger.engine.evaluation.EvaluateException) SourcePosition(com.intellij.debugger.SourcePosition) Computable(com.intellij.openapi.util.Computable) PsiElement(com.intellij.psi.PsiElement) Location(com.sun.jdi.Location)

Example 2 with VMDisconnectedException

use of com.sun.jdi.VMDisconnectedException in project intellij-community by JetBrains.

the class ConnectionServiceWrapper method createVirtualMachine.

public VirtualMachine createVirtualMachine() throws IOException {
    try {
        final VirtualMachineManager virtualMachineManager = Bootstrap.virtualMachineManager();
        //noinspection HardCodedStringLiteral
        final Method method = virtualMachineManager.getClass().getMethod("createVirtualMachine", new Class[] { myDelegateClass });
        return (VirtualMachine) method.invoke(virtualMachineManager, new Object[] { myConnection });
    } catch (NoSuchMethodException | IllegalAccessException e) {
        LOG.error(e);
    } catch (InvocationTargetException e) {
        final Throwable cause = e.getCause();
        if (cause instanceof IOException) {
            throw (IOException) cause;
        }
        if (cause instanceof VMDisconnectedException) {
            // ignore this one
            return null;
        }
        LOG.error(e);
    }
    return null;
}
Also used : VMDisconnectedException(com.sun.jdi.VMDisconnectedException) VirtualMachineManager(com.sun.jdi.VirtualMachineManager) Method(java.lang.reflect.Method) IOException(java.io.IOException) InvocationTargetException(java.lang.reflect.InvocationTargetException) VirtualMachine(com.sun.jdi.VirtualMachine)

Example 3 with VMDisconnectedException

use of com.sun.jdi.VMDisconnectedException in project intellij-community by JetBrains.

the class PopFrameAction method actionPerformed.

public void actionPerformed(@NotNull AnActionEvent e) {
    final Project project = e.getData(CommonDataKeys.PROJECT);
    final JavaStackFrame stackFrame = getStackFrame(e);
    if (stackFrame == null || stackFrame.getStackFrameProxy().isBottom()) {
        return;
    }
    try {
        final DebuggerContextImpl debuggerContext = DebuggerAction.getDebuggerContext(e.getDataContext());
        final DebugProcessImpl debugProcess = debuggerContext.getDebugProcess();
        if (debugProcess == null) {
            return;
        }
        debugProcess.getSession().setSteppingThrough(stackFrame.getStackFrameProxy().threadProxy());
        if (evaluateFinallyBlocks(project, UIUtil.removeMnemonic(ActionsBundle.actionText(DebuggerActions.POP_FRAME)), stackFrame, new XDebuggerEvaluator.XEvaluationCallback() {

            @Override
            public void evaluated(@NotNull XValue result) {
                popFrame(debugProcess, debuggerContext, stackFrame);
            }

            @Override
            public void errorOccurred(@NotNull final String errorMessage) {
                ApplicationManager.getApplication().invokeLater(() -> Messages.showMessageDialog(project, DebuggerBundle.message("error.executing.finally", errorMessage), UIUtil.removeMnemonic(ActionsBundle.actionText(DebuggerActions.POP_FRAME)), Messages.getErrorIcon()));
            }
        }))
            return;
        popFrame(debugProcess, debuggerContext, stackFrame);
    } catch (NativeMethodException e2) {
        Messages.showMessageDialog(project, DebuggerBundle.message("error.native.method.exception"), UIUtil.removeMnemonic(ActionsBundle.actionText(DebuggerActions.POP_FRAME)), Messages.getErrorIcon());
    } catch (InvalidStackFrameException | VMDisconnectedException ignored) {
    }
}
Also used : NativeMethodException(com.sun.jdi.NativeMethodException) XDebuggerEvaluator(com.intellij.xdebugger.evaluation.XDebuggerEvaluator) InvalidStackFrameException(com.sun.jdi.InvalidStackFrameException) XValue(com.intellij.xdebugger.frame.XValue) VMDisconnectedException(com.sun.jdi.VMDisconnectedException) Project(com.intellij.openapi.project.Project) DebugProcessImpl(com.intellij.debugger.engine.DebugProcessImpl) JavaStackFrame(com.intellij.debugger.engine.JavaStackFrame) DebuggerContextImpl(com.intellij.debugger.impl.DebuggerContextImpl)

Example 4 with VMDisconnectedException

use of com.sun.jdi.VMDisconnectedException in project intellij-community by JetBrains.

the class NodeDescriptorImpl method updateRepresentationNoNotify.

protected void updateRepresentationNoNotify(EvaluationContextImpl context, DescriptorLabelListener labelListener) {
    try {
        try {
            myEvaluateException = null;
            myLabel = calcRepresentation(context, labelListener);
        } catch (InconsistentDebugInfoException e) {
            throw new EvaluateException(DebuggerBundle.message("error.inconsistent.debug.info"));
        } catch (InvalidStackFrameException e) {
            throw new EvaluateException(DebuggerBundle.message("error.invalid.stackframe"));
        } catch (VMDisconnectedException e) {
            throw e;
        } catch (RuntimeException e) {
            if (e.getCause() instanceof InterruptedException) {
                throw e;
            }
            LOG.error(e);
            throw new EvaluateException("Internal error, see logs for more details");
        }
    } catch (EvaluateException e) {
        setFailed(e);
    }
}
Also used : VMDisconnectedException(com.sun.jdi.VMDisconnectedException) EvaluateException(com.intellij.debugger.engine.evaluation.EvaluateException) InconsistentDebugInfoException(com.sun.jdi.InconsistentDebugInfoException) InvalidStackFrameException(com.sun.jdi.InvalidStackFrameException)

Aggregations

VMDisconnectedException (com.sun.jdi.VMDisconnectedException)4 EvaluateException (com.intellij.debugger.engine.evaluation.EvaluateException)2 InvalidStackFrameException (com.sun.jdi.InvalidStackFrameException)2 SourcePosition (com.intellij.debugger.SourcePosition)1 DebugProcessImpl (com.intellij.debugger.engine.DebugProcessImpl)1 JavaStackFrame (com.intellij.debugger.engine.JavaStackFrame)1 DebuggerContextImpl (com.intellij.debugger.impl.DebuggerContextImpl)1 StackFrameProxyImpl (com.intellij.debugger.jdi.StackFrameProxyImpl)1 DebuggerSettings (com.intellij.debugger.settings.DebuggerSettings)1 Project (com.intellij.openapi.project.Project)1 Computable (com.intellij.openapi.util.Computable)1 PsiElement (com.intellij.psi.PsiElement)1 XDebuggerEvaluator (com.intellij.xdebugger.evaluation.XDebuggerEvaluator)1 XValue (com.intellij.xdebugger.frame.XValue)1 InconsistentDebugInfoException (com.sun.jdi.InconsistentDebugInfoException)1 Location (com.sun.jdi.Location)1 Method (com.sun.jdi.Method)1 NativeMethodException (com.sun.jdi.NativeMethodException)1 VirtualMachine (com.sun.jdi.VirtualMachine)1 VirtualMachineManager (com.sun.jdi.VirtualMachineManager)1