Search in sources :

Example 36 with XDebugSession

use of com.intellij.xdebugger.XDebugSession in project intellij-community by JetBrains.

the class DebugProcessEvents method vmAttached.

private void vmAttached() {
    DebuggerManagerThreadImpl.assertIsManagerThread();
    LOG.assertTrue(!isAttached());
    if (myState.compareAndSet(State.INITIAL, State.ATTACHED)) {
        final VirtualMachineProxyImpl machineProxy = getVirtualMachineProxy();
        final EventRequestManager requestManager = machineProxy.eventRequestManager();
        if (machineProxy.canGetMethodReturnValues()) {
            myReturnValueWatcher = new MethodReturnValueWatcher(requestManager);
        }
        final ThreadStartRequest threadStartRequest = requestManager.createThreadStartRequest();
        threadStartRequest.setSuspendPolicy(EventRequest.SUSPEND_NONE);
        threadStartRequest.enable();
        final ThreadDeathRequest threadDeathRequest = requestManager.createThreadDeathRequest();
        threadDeathRequest.setSuspendPolicy(EventRequest.SUSPEND_NONE);
        threadDeathRequest.enable();
        // fill position managers
        ((DebuggerManagerImpl) DebuggerManager.getInstance(getProject())).getCustomPositionManagerFactories().map(factory -> factory.fun(this)).filter(Objects::nonNull).forEach(this::appendPositionManager);
        Stream.of(Extensions.getExtensions(PositionManagerFactory.EP_NAME, getProject())).map(factory -> factory.createPositionManager(this)).filter(Objects::nonNull).forEach(this::appendPositionManager);
        myDebugProcessDispatcher.getMulticaster().processAttached(this);
        createStackCapturingBreakpoints();
        // breakpoints should be initialized after all processAttached listeners work
        ApplicationManager.getApplication().runReadAction(() -> {
            XDebugSession session = getSession().getXDebugSession();
            if (session != null) {
                session.initBreakpoints();
            }
        });
        final String addressDisplayName = DebuggerBundle.getAddressDisplayName(getConnection());
        final String transportName = DebuggerBundle.getTransportName(getConnection());
        showStatusText(DebuggerBundle.message("status.connected", addressDisplayName, transportName));
        LOG.debug("leave: processVMStartEvent()");
    }
}
Also used : XDebugSession(com.intellij.xdebugger.XDebugSession) VirtualMachineProxyImpl(com.intellij.debugger.jdi.VirtualMachineProxyImpl) ThreadStartRequest(com.sun.jdi.request.ThreadStartRequest) ThreadDeathRequest(com.sun.jdi.request.ThreadDeathRequest) EventRequestManager(com.sun.jdi.request.EventRequestManager) MethodReturnValueWatcher(com.intellij.debugger.engine.requests.MethodReturnValueWatcher)

Example 37 with XDebugSession

use of com.intellij.xdebugger.XDebugSession in project intellij-community by JetBrains.

the class DebugProcessEvents method processLocatableEvent.

private void processLocatableEvent(final SuspendContextImpl suspendContext, final LocatableEvent event) {
    ThreadReference thread = event.thread();
    //LOG.assertTrue(thread.isSuspended());
    preprocessEvent(suspendContext, thread);
    //we use schedule to allow processing other events during processing this one
    //this is especially necessary if a method is breakpoint condition
    getManagerThread().schedule(new SuspendContextCommandImpl(suspendContext) {

        @Override
        public void contextAction() throws Exception {
            final SuspendManager suspendManager = getSuspendManager();
            SuspendContextImpl evaluatingContext = SuspendManagerUtil.getEvaluatingContext(suspendManager, suspendContext.getThread());
            if (evaluatingContext != null && !DebuggerSession.enableBreakpointsDuringEvaluation()) {
                // is inside evaluation, so ignore any breakpoints
                suspendManager.voteResume(suspendContext);
                return;
            }
            final LocatableEventRequestor requestor = (LocatableEventRequestor) getRequestsManager().findRequestor(event.request());
            boolean resumePreferred = requestor != null && DebuggerSettings.SUSPEND_NONE.equals(requestor.getSuspendPolicy());
            boolean requestHit;
            try {
                requestHit = (requestor != null) && requestor.processLocatableEvent(this, event);
            } catch (final LocatableEventRequestor.EventProcessingException ex) {
                if (LOG.isDebugEnabled()) {
                    LOG.debug(ex.getMessage());
                }
                final boolean[] considerRequestHit = new boolean[] { true };
                DebuggerInvocationUtil.invokeAndWait(getProject(), () -> {
                    final String displayName = requestor instanceof Breakpoint ? ((Breakpoint) requestor).getDisplayName() : requestor.getClass().getSimpleName();
                    final String message = DebuggerBundle.message("error.evaluating.breakpoint.condition.or.action", displayName, ex.getMessage());
                    considerRequestHit[0] = Messages.showYesNoDialog(getProject(), message, ex.getTitle(), Messages.getQuestionIcon()) == Messages.YES;
                }, ModalityState.NON_MODAL);
                requestHit = considerRequestHit[0];
                resumePreferred = !requestHit;
            }
            if (requestHit && requestor instanceof Breakpoint) {
                // if requestor is a breakpoint and this breakpoint was hit, no matter its suspend policy
                ApplicationManager.getApplication().runReadAction(() -> {
                    XDebugSession session = getSession().getXDebugSession();
                    if (session != null) {
                        XBreakpoint breakpoint = ((Breakpoint) requestor).getXBreakpoint();
                        if (breakpoint != null) {
                            ((XDebugSessionImpl) session).processDependencies(breakpoint);
                        }
                    }
                });
            }
            if (!requestHit || resumePreferred) {
                suspendManager.voteResume(suspendContext);
            } else {
                if (myReturnValueWatcher != null) {
                    myReturnValueWatcher.disable();
                }
                //if (suspendContext.getSuspendPolicy() == EventRequest.SUSPEND_ALL) {
                //  // there could be explicit resume as a result of call to voteSuspend()
                //  // e.g. when breakpoint was considered invalid, in that case the filter will be applied _after_
                //  // resuming and all breakpoints in other threads will be ignored.
                //  // As resume() implicitly cleares the filter, the filter must be always applied _before_ any resume() action happens
                //  myBreakpointManager.applyThreadFilter(DebugProcessEvents.this, event.thread());
                //}
                suspendManager.voteSuspend(suspendContext);
                showStatusText(DebugProcessEvents.this, event);
            }
        }
    });
}
Also used : StackCapturingLineBreakpoint(com.intellij.debugger.ui.breakpoints.StackCapturingLineBreakpoint) XBreakpoint(com.intellij.xdebugger.breakpoints.XBreakpoint) Breakpoint(com.intellij.debugger.ui.breakpoints.Breakpoint) XDebugSession(com.intellij.xdebugger.XDebugSession) SuspendContextCommandImpl(com.intellij.debugger.engine.events.SuspendContextCommandImpl) XBreakpoint(com.intellij.xdebugger.breakpoints.XBreakpoint) ThreadReference(com.sun.jdi.ThreadReference) LocatableEventRequestor(com.intellij.debugger.engine.requests.LocatableEventRequestor) ProcessCanceledException(com.intellij.openapi.progress.ProcessCanceledException) VMDisconnectedException(com.sun.jdi.VMDisconnectedException) InternalException(com.sun.jdi.InternalException)

Example 38 with XDebugSession

use of com.intellij.xdebugger.XDebugSession in project intellij-community by JetBrains.

the class ConstructorInstancesTracker method obsolete.

public void obsolete() {
    if (myNewObjects != null) {
        myNewObjects.forEach(ObjectReference::enableCollection);
    }
    myNewObjects = null;
    if (!myIsBackgroundMode || myIsBackgroundTrackingEnabled) {
        myBreakpoint.enable();
    }
    final XDebugSession session = XDebuggerManager.getInstance(myProject).getCurrentSession();
    if (session != null) {
        final DebugProcess process = DebuggerManager.getInstance(myProject).getDebugProcess(session.getDebugProcess().getProcessHandler());
        final MemoryViewDebugProcessData data = process.getUserData(MemoryViewDebugProcessData.KEY);
        if (data != null) {
            data.getTrackedStacks().release();
        }
    }
}
Also used : MemoryViewDebugProcessData(com.intellij.debugger.memory.component.MemoryViewDebugProcessData) XDebugSession(com.intellij.xdebugger.XDebugSession) DebugProcess(com.intellij.debugger.engine.DebugProcess) ObjectReference(com.sun.jdi.ObjectReference)

Example 39 with XDebugSession

use of com.intellij.xdebugger.XDebugSession in project intellij-community by JetBrains.

the class ShowInstancesByClassAction method perform.

@Override
protected void perform(XValueNodeImpl node, @NotNull String nodeName, AnActionEvent e) {
    final Project project = e.getProject();
    if (project != null) {
        final XDebugSession debugSession = XDebuggerManager.getInstance(project).getCurrentSession();
        final ObjectReference ref = getObjectReference(node);
        if (debugSession != null && ref != null) {
            final ReferenceType referenceType = ref.referenceType();
            new InstancesWindow(debugSession, l -> {
                final List<ObjectReference> instances = referenceType.instances(l);
                return instances == null ? Collections.emptyList() : instances;
            }, referenceType.name()).show();
        }
    }
}
Also used : List(java.util.List) XValueNodeImpl(com.intellij.xdebugger.impl.ui.tree.nodes.XValueNodeImpl) StringUtil(com.intellij.openapi.util.text.StringUtil) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) ReferenceType(com.sun.jdi.ReferenceType) Project(com.intellij.openapi.project.Project) XDebuggerManager(com.intellij.xdebugger.XDebuggerManager) InstancesWindow(com.intellij.debugger.memory.ui.InstancesWindow) ObjectReference(com.sun.jdi.ObjectReference) NotNull(org.jetbrains.annotations.NotNull) XDebugSession(com.intellij.xdebugger.XDebugSession) Collections(java.util.Collections) Project(com.intellij.openapi.project.Project) XDebugSession(com.intellij.xdebugger.XDebugSession) InstancesWindow(com.intellij.debugger.memory.ui.InstancesWindow) ObjectReference(com.sun.jdi.ObjectReference) List(java.util.List) ReferenceType(com.sun.jdi.ReferenceType)

Example 40 with XDebugSession

use of com.intellij.xdebugger.XDebugSession in project intellij-community by JetBrains.

the class JavaStackFrame method customizePresentation.

@Override
public void customizePresentation(@NotNull ColoredTextContainer component) {
    StackFrameDescriptorImpl selectedDescriptor = null;
    DebuggerSession session = myDebugProcess.getSession();
    if (session != null) {
        XDebugSession xSession = session.getXDebugSession();
        if (xSession != null) {
            XStackFrame frame = xSession.getCurrentStackFrame();
            if (frame instanceof JavaStackFrame) {
                selectedDescriptor = ((JavaStackFrame) frame).getDescriptor();
            }
        }
    }
    FRAME_RENDERER.customizePresentation(myDescriptor, component, selectedDescriptor);
    if (myInsertCapturePoint != null) {
        component.setIcon(XDebuggerUIConstants.INFORMATION_MESSAGE_ICON);
    }
}
Also used : XDebugSession(com.intellij.xdebugger.XDebugSession) DebuggerSession(com.intellij.debugger.impl.DebuggerSession)

Aggregations

XDebugSession (com.intellij.xdebugger.XDebugSession)50 Project (com.intellij.openapi.project.Project)15 NotNull (org.jetbrains.annotations.NotNull)13 XDebugProcessStarter (com.intellij.xdebugger.XDebugProcessStarter)9 XDebugSessionImpl (com.intellij.xdebugger.impl.XDebugSessionImpl)9 XDebugProcess (com.intellij.xdebugger.XDebugProcess)8 Nullable (org.jetbrains.annotations.Nullable)7 DebuggerSession (com.intellij.debugger.impl.DebuggerSession)6 IOException (java.io.IOException)5 DebugProcessImpl (com.intellij.debugger.engine.DebugProcessImpl)4 ExecutionException (com.intellij.execution.ExecutionException)4 XValueNodeImpl (com.intellij.xdebugger.impl.ui.tree.nodes.XValueNodeImpl)4 DebugEnvironment (com.intellij.debugger.DebugEnvironment)3 VirtualMachineProxyImpl (com.intellij.debugger.jdi.VirtualMachineProxyImpl)3 ExecutionResult (com.intellij.execution.ExecutionResult)3 RunContentDescriptor (com.intellij.execution.ui.RunContentDescriptor)3 XSourcePosition (com.intellij.xdebugger.XSourcePosition)3 ServerSocket (java.net.ServerSocket)3 List (java.util.List)3 DefaultDebugEnvironment (com.intellij.debugger.DefaultDebugEnvironment)2