Search in sources :

Example 1 with DebugProcessImpl

use of com.intellij.debugger.engine.DebugProcessImpl 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 DebugProcessImpl

use of com.intellij.debugger.engine.DebugProcessImpl in project smali by JesusFreke.

the class LazyValue method virtualMachine.

@Override
public VirtualMachine virtualMachine() {
    if (evaluationContext != null) {
        return ((VirtualMachineProxyImpl) evaluationContext.getDebugProcess().getVirtualMachineProxy()).getVirtualMachine();
    } else {
        final DebuggerContextImpl debuggerContext = DebuggerManagerEx.getInstanceEx(project).getContext();
        final DebugProcessImpl process = debuggerContext.getDebugProcess();
        if (process != null) {
            return process.getVirtualMachineProxy().getVirtualMachine();
        }
    }
    return null;
}
Also used : VirtualMachineProxyImpl(com.intellij.debugger.jdi.VirtualMachineProxyImpl) DebugProcessImpl(com.intellij.debugger.engine.DebugProcessImpl) DebuggerContextImpl(com.intellij.debugger.impl.DebuggerContextImpl)

Example 3 with DebugProcessImpl

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

the class MethodBreakpoint method createRequestForPreparedClassEmulated.

static void createRequestForPreparedClassEmulated(@NotNull MethodBreakpointBase breakpoint, @NotNull DebugProcessImpl debugProcess, @NotNull ReferenceType classType, boolean base) {
    if (!base && !shouldCreateRequest(breakpoint, breakpoint.getXBreakpoint(), debugProcess, true)) {
        return;
    }
    try {
        Method lambdaMethod = MethodBytecodeUtil.getLambdaMethod(classType, debugProcess.getVirtualMachineProxy());
        StreamEx<Method> methods = lambdaMethod != null ? StreamEx.of(lambdaMethod) : breakpoint.matchingMethods(StreamEx.of(classType.methods()).filter(m -> base || !m.isAbstract()), debugProcess);
        boolean found = false;
        for (Method method : methods) {
            found = true;
            if (base && method.isNative()) {
                breakpoint.disableEmulation();
                return;
            }
            Method target = MethodBytecodeUtil.getBridgeTargetMethod(method, debugProcess.getVirtualMachineProxy());
            if (target != null && !DebuggerUtilsEx.allLineLocations(target).isEmpty()) {
                method = target;
            }
            List<Location> allLineLocations = DebuggerUtilsEx.allLineLocations(method);
            if (!allLineLocations.isEmpty()) {
                if (breakpoint.isWatchEntry()) {
                    createLocationBreakpointRequest(breakpoint, ContainerUtil.getFirstItem(allLineLocations), debugProcess);
                }
                if (breakpoint.isWatchExit()) {
                    MethodBytecodeUtil.visit(method, new MethodVisitor(Opcodes.API_VERSION) {

                        int myLastLine = 0;

                        @Override
                        public void visitLineNumber(int line, Label start) {
                            myLastLine = line;
                        }

                        @Override
                        public void visitInsn(int opcode) {
                            switch(opcode) {
                                case Opcodes.RETURN:
                                case Opcodes.IRETURN:
                                case Opcodes.FRETURN:
                                case Opcodes.ARETURN:
                                case Opcodes.LRETURN:
                                case Opcodes.DRETURN:
                                    //case Opcodes.ATHROW:
                                    allLineLocations.stream().filter(l -> l.lineNumber() == myLastLine).findFirst().ifPresent(location -> createLocationBreakpointRequest(breakpoint, location, debugProcess));
                            }
                        }
                    }, true);
                }
            }
        }
        if (base && found) {
            // desired class found - now also track all new classes
            createRequestForSubClasses(breakpoint, debugProcess, classType);
        }
    } catch (Exception e) {
        LOG.debug(e);
    }
}
Also used : com.intellij.openapi.util(com.intellij.openapi.util) MethodEntryEvent(com.sun.jdi.event.MethodEntryEvent) JVMNameUtil(com.intellij.debugger.engine.JVMNameUtil) AllIcons(com.intellij.icons.AllIcons) Document(com.intellij.openapi.editor.Document) Opcodes(org.jetbrains.org.objectweb.asm.Opcodes) DebuggerUtilsEx(com.intellij.debugger.impl.DebuggerUtilsEx) EventRequest(com.sun.jdi.request.EventRequest) EvaluationContextImpl(com.intellij.debugger.engine.evaluation.EvaluationContextImpl) StringBuilderSpinAllocator(com.intellij.util.StringBuilderSpinAllocator) ProgressWindowWithNotification(com.intellij.openapi.progress.util.ProgressWindowWithNotification) Logger(com.intellij.openapi.diagnostic.Logger) MultiMap(com.intellij.util.containers.MultiMap) MethodEntryRequest(com.sun.jdi.request.MethodEntryRequest) DebuggerManagerThreadImpl(com.intellij.debugger.engine.DebuggerManagerThreadImpl) EvaluateException(com.intellij.debugger.engine.evaluation.EvaluateException) ProgressManager(com.intellij.openapi.progress.ProgressManager) IndexNotReadyException(com.intellij.openapi.project.IndexNotReadyException) MethodExitRequest(com.sun.jdi.request.MethodExitRequest) DebugProcessImpl(com.intellij.debugger.engine.DebugProcessImpl) PositionUtil(com.intellij.debugger.impl.PositionUtil) MethodExitEvent(com.sun.jdi.event.MethodExitEvent) XBreakpoint(com.intellij.xdebugger.breakpoints.XBreakpoint) Nullable(org.jetbrains.annotations.Nullable) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) List(java.util.List) Stream(java.util.stream.Stream) StreamEx(one.util.streamex.StreamEx) ApplicationManager(com.intellij.openapi.application.ApplicationManager) Requestor(com.intellij.debugger.requests.Requestor) com.intellij.psi(com.intellij.psi) NotNull(org.jetbrains.annotations.NotNull) SourcePosition(com.intellij.debugger.SourcePosition) LocatableEvent(com.sun.jdi.event.LocatableEvent) Label(org.jetbrains.org.objectweb.asm.Label) NonNls(org.jetbrains.annotations.NonNls) MethodBytecodeUtil(com.intellij.debugger.jdi.MethodBytecodeUtil) ContainerUtil(com.intellij.util.containers.ContainerUtil) AtomicReference(java.util.concurrent.atomic.AtomicReference) RequestManagerImpl(com.intellij.debugger.engine.requests.RequestManagerImpl) Project(com.intellij.openapi.project.Project) DebuggerBundle(com.intellij.debugger.DebuggerBundle) JavaMethodBreakpointProperties(org.jetbrains.java.debugger.breakpoints.properties.JavaMethodBreakpointProperties) MethodVisitor(org.jetbrains.org.objectweb.asm.MethodVisitor) JVMName(com.intellij.debugger.engine.JVMName) Consumer(java.util.function.Consumer) ClassPrepareRequest(com.sun.jdi.request.ClassPrepareRequest) DebuggerManagerEx(com.intellij.debugger.DebuggerManagerEx) com.sun.jdi(com.sun.jdi) Element(org.jdom.Element) javax.swing(javax.swing) Label(org.jetbrains.org.objectweb.asm.Label) XBreakpoint(com.intellij.xdebugger.breakpoints.XBreakpoint) EvaluateException(com.intellij.debugger.engine.evaluation.EvaluateException) IndexNotReadyException(com.intellij.openapi.project.IndexNotReadyException) MethodVisitor(org.jetbrains.org.objectweb.asm.MethodVisitor)

Example 4 with DebugProcessImpl

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

the class StackCapturingLineBreakpoint method processLocatableEvent.

@Override
public boolean processLocatableEvent(SuspendContextCommandImpl action, LocatableEvent event) throws EventProcessingException {
    SuspendContextImpl suspendContext = action.getSuspendContext();
    if (suspendContext != null) {
        ThreadReferenceProxyImpl thread = suspendContext.getThread();
        if (thread != null) {
            DebugProcessImpl process = suspendContext.getDebugProcess();
            try {
                StackFrameProxyImpl frameProxy = ContainerUtil.getFirstItem(thread.forceFrames());
                if (frameProxy != null) {
                    Map<Object, List<StackFrameItem>> stacks = process.getUserData(CAPTURED_STACKS);
                    if (stacks == null) {
                        stacks = new CapturedStacksMap();
                        process.putUserData(CAPTURED_STACKS, Collections.synchronizedMap(stacks));
                    }
                    Value key = myCaptureEvaluator.evaluate(new EvaluationContextImpl(suspendContext, frameProxy));
                    if (key instanceof ObjectReference) {
                        List<StackFrameItem> frames = StackFrameItem.createFrames(suspendContext, true);
                        if (frames.size() > MAX_STACK_LENGTH) {
                            frames = frames.subList(0, MAX_STACK_LENGTH);
                        }
                        stacks.put(getKey((ObjectReference) key), frames);
                    }
                }
            } catch (EvaluateException e) {
                LOG.debug(e);
                process.printToConsole(DebuggerBundle.message("error.unable.to.evaluate.capture.expression", e.getMessage()) + "\n");
            }
        }
    }
    return false;
}
Also used : StackFrameProxyImpl(com.intellij.debugger.jdi.StackFrameProxyImpl) ThreadReferenceProxyImpl(com.intellij.debugger.jdi.ThreadReferenceProxyImpl) DebugProcessImpl(com.intellij.debugger.engine.DebugProcessImpl) SuspendContextImpl(com.intellij.debugger.engine.SuspendContextImpl) List(java.util.List) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) StackFrameItem(com.intellij.debugger.memory.utils.StackFrameItem)

Example 5 with DebugProcessImpl

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

the class StackCapturingLineBreakpoint method getRelatedStack.

@Nullable
public static List<StackFrameItem> getRelatedStack(@NotNull StackFrameProxyImpl frame, @NotNull SuspendContextImpl suspendContext) {
    DebugProcessImpl debugProcess = suspendContext.getDebugProcess();
    Map<Object, List<StackFrameItem>> capturedStacks = debugProcess.getUserData(CAPTURED_STACKS);
    if (ContainerUtil.isEmpty(capturedStacks)) {
        return null;
    }
    List<StackCapturingLineBreakpoint> captureBreakpoints = debugProcess.getUserData(CAPTURE_BREAKPOINTS);
    if (ContainerUtil.isEmpty(captureBreakpoints)) {
        return null;
    }
    try {
        Location location = frame.location();
        String className = location.declaringType().name();
        String methodName = location.method().name();
        for (StackCapturingLineBreakpoint b : captureBreakpoints) {
            String insertClassName = b.myCapturePoint.myInsertClassName;
            if ((StringUtil.isEmpty(insertClassName) || StringUtil.equals(insertClassName, className)) && StringUtil.equals(b.myCapturePoint.myInsertMethodName, methodName)) {
                try {
                    Value key = b.myInsertEvaluator.evaluate(new EvaluationContextImpl(suspendContext, frame));
                    if (key instanceof ObjectReference) {
                        return capturedStacks.get(getKey((ObjectReference) key));
                    }
                } catch (EvaluateException e) {
                    LOG.debug(e);
                    debugProcess.printToConsole(DebuggerBundle.message("error.unable.to.evaluate.insert.expression", e.getMessage()) + "\n");
                }
            }
        }
    } catch (EvaluateException e) {
        LOG.debug(e);
    }
    return null;
}
Also used : DebugProcessImpl(com.intellij.debugger.engine.DebugProcessImpl) List(java.util.List) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

DebugProcessImpl (com.intellij.debugger.engine.DebugProcessImpl)56 DebuggerContextImpl (com.intellij.debugger.impl.DebuggerContextImpl)20 EvaluateException (com.intellij.debugger.engine.evaluation.EvaluateException)15 Project (com.intellij.openapi.project.Project)15 Nullable (org.jetbrains.annotations.Nullable)12 DebuggerCommandImpl (com.intellij.debugger.engine.events.DebuggerCommandImpl)9 DebuggerTreeNodeImpl (com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl)9 DebuggerContextCommandImpl (com.intellij.debugger.engine.events.DebuggerContextCommandImpl)7 List (java.util.List)7 SourcePosition (com.intellij.debugger.SourcePosition)5 JavaValue (com.intellij.debugger.engine.JavaValue)5 DebuggerSession (com.intellij.debugger.impl.DebuggerSession)5 StackFrameProxyImpl (com.intellij.debugger.jdi.StackFrameProxyImpl)5 ThreadReferenceProxyImpl (com.intellij.debugger.jdi.ThreadReferenceProxyImpl)5 VirtualMachineProxyImpl (com.intellij.debugger.jdi.VirtualMachineProxyImpl)5 XDebugSession (com.intellij.xdebugger.XDebugSession)5 NotNull (org.jetbrains.annotations.NotNull)5 NodeDescriptorImpl (com.intellij.debugger.ui.impl.watch.NodeDescriptorImpl)4 ThreadDescriptorImpl (com.intellij.debugger.ui.impl.watch.ThreadDescriptorImpl)4 ArrayList (java.util.ArrayList)4