Search in sources :

Example 1 with XSuspendContext

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

the class XFramesView method processSessionEvent.

@Override
public void processSessionEvent(@NotNull SessionEvent event, @NotNull XDebugSession session) {
    myRefresh = event == SessionEvent.SETTINGS_CHANGED;
    if (event == SessionEvent.BEFORE_RESUME) {
        return;
    }
    XStackFrame currentStackFrame = session.getCurrentStackFrame();
    XSuspendContext suspendContext = session.getSuspendContext();
    if (event == SessionEvent.FRAME_CHANGED) {
        ApplicationManager.getApplication().assertIsDispatchThread();
        if (currentStackFrame != null) {
            myFramesList.setSelectedValue(currentStackFrame, true);
            mySelectedFrameIndex = myFramesList.getSelectedIndex();
            myExecutionStacksWithSelection.put(mySelectedStack, mySelectedFrameIndex);
        }
        return;
    }
    myLaterInvocator.offer(() -> {
        if (event != SessionEvent.SETTINGS_CHANGED) {
            mySelectedFrameIndex = 0;
            mySelectedStack = null;
            myVisibleRect = null;
        } else {
            myVisibleRect = myFramesList.getVisibleRect();
        }
        myListenersEnabled = false;
        myBuilders.values().forEach(StackFramesListBuilder::dispose);
        myBuilders.clear();
        if (suspendContext == null) {
            requestClear();
            return;
        }
        if (event == SessionEvent.PAUSED) {
            // clear immediately
            cancelClear();
            clear();
        }
        XExecutionStack[] executionStacks = suspendContext.getExecutionStacks();
        addExecutionStacks(Arrays.asList(executionStacks));
        XExecutionStack activeExecutionStack = mySelectedStack != null ? mySelectedStack : suspendContext.getActiveExecutionStack();
        myThreadComboBox.setSelectedItem(activeExecutionStack);
        myThreadsPanel.removeAll();
        myThreadsPanel.add(myToolbar.getComponent(), BorderLayout.EAST);
        final boolean invisible = executionStacks.length == 1 && StringUtil.isEmpty(executionStacks[0].getDisplayName());
        if (!invisible) {
            myThreadsPanel.add(myThreadComboBox, BorderLayout.CENTER);
        }
        myToolbar.setAddSeparatorFirst(!invisible);
        updateFrames(activeExecutionStack, session);
    });
}
Also used : XSuspendContext(com.intellij.xdebugger.frame.XSuspendContext) XStackFrame(com.intellij.xdebugger.frame.XStackFrame) XExecutionStack(com.intellij.xdebugger.frame.XExecutionStack)

Example 2 with XSuspendContext

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

the class XDebugSessionImpl method smartStepInto.

@Override
public <V extends XSmartStepIntoVariant> void smartStepInto(XSmartStepIntoHandler<V> handler, V variant) {
    if (!myDebugProcess.checkCanPerformCommands())
        return;
    final XSuspendContext context = doResume();
    handler.startStepInto(variant, context);
}
Also used : XSuspendContext(com.intellij.xdebugger.frame.XSuspendContext)

Example 3 with XSuspendContext

use of com.intellij.xdebugger.frame.XSuspendContext in project intellij-plugins by JetBrains.

the class DartVmServiceListener method onIsolatePaused.

void onIsolatePaused(@NotNull final IsolateRef isolateRef, @Nullable final ElementList<Breakpoint> vmBreakpoints, @Nullable final InstanceRef exception, @Nullable final Frame vmTopFrame, boolean atAsyncSuspension) {
    if (vmTopFrame == null) {
        myDebugProcess.getSession().positionReached(new XSuspendContext() {
        });
        return;
    }
    final DartVmServiceSuspendContext suspendContext = new DartVmServiceSuspendContext(myDebugProcess, isolateRef, vmTopFrame, exception, atAsyncSuspension);
    final XStackFrame xTopFrame = suspendContext.getActiveExecutionStack().getTopFrame();
    final XSourcePosition sourcePosition = xTopFrame == null ? null : xTopFrame.getSourcePosition();
    if (vmBreakpoints == null || vmBreakpoints.isEmpty()) {
        final StepOption latestStep = myDebugProcess.getVmServiceWrapper().getLatestStep();
        if (latestStep == StepOption.Over && equalSourcePositions(myLatestSourcePosition, sourcePosition)) {
            // continue stepping to change current line
            myDebugProcess.getVmServiceWrapper().resumeIsolate(isolateRef.getId(), latestStep);
        } else {
            myLatestSourcePosition = sourcePosition;
            myDebugProcess.getSession().positionReached(suspendContext);
        }
    } else {
        if (vmBreakpoints.size() > 1) {
            // Shouldn't happen. IDE doesn't allow to set 2 breakpoints on one line.
            LOG.error(vmBreakpoints.size() + " breakpoints hit in one shot.");
        }
        // Remove any temporary (run to cursor) breakpoints.
        myBreakpointHandler.removeTemporaryBreakpoints(isolateRef.getId());
        final XLineBreakpoint<XBreakpointProperties> xBreakpoint = myBreakpointHandler.getXBreakpoint(vmBreakpoints.get(0));
        if (xBreakpoint == null) {
            // breakpoint could be set in the Observatory
            myLatestSourcePosition = sourcePosition;
            myDebugProcess.getSession().positionReached(suspendContext);
            return;
        }
        if ("false".equals(evaluateExpression(isolateRef.getId(), vmTopFrame, xBreakpoint.getConditionExpression()))) {
            myDebugProcess.getVmServiceWrapper().resumeIsolate(isolateRef.getId(), null);
            return;
        }
        myLatestSourcePosition = sourcePosition;
        final String logExpression = evaluateExpression(isolateRef.getId(), vmTopFrame, xBreakpoint.getLogExpressionObject());
        final boolean suspend = myDebugProcess.getSession().breakpointReached(xBreakpoint, logExpression, suspendContext);
        if (!suspend) {
            myDebugProcess.getVmServiceWrapper().resumeIsolate(isolateRef.getId(), null);
        }
    }
}
Also used : XBreakpointProperties(com.intellij.xdebugger.breakpoints.XBreakpointProperties) DartVmServiceSuspendContext(com.jetbrains.lang.dart.ide.runner.server.vmService.frame.DartVmServiceSuspendContext) XSuspendContext(com.intellij.xdebugger.frame.XSuspendContext) XSourcePosition(com.intellij.xdebugger.XSourcePosition) XStackFrame(com.intellij.xdebugger.frame.XStackFrame)

Example 4 with XSuspendContext

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

the class XDebugSessionImpl method doResume.

@Nullable
private XSuspendContext doResume() {
    if (!myPaused.getAndSet(false)) {
        return null;
    }
    myDispatcher.getMulticaster().beforeSessionResume();
    XSuspendContext context = mySuspendContext;
    mySuspendContext = null;
    myCurrentExecutionStack = null;
    myCurrentStackFrame = null;
    myTopFramePosition = null;
    myActiveNonLineBreakpoint = null;
    updateExecutionPosition();
    UIUtil.invokeLaterIfNeeded(() -> {
        if (mySessionTab != null) {
            mySessionTab.getUi().clearAttractionBy(XDebuggerUIConstants.LAYOUT_VIEW_BREAKPOINT_CONDITION);
        }
    });
    myDispatcher.getMulticaster().sessionResumed();
    return context;
}
Also used : XSuspendContext(com.intellij.xdebugger.frame.XSuspendContext) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

XSuspendContext (com.intellij.xdebugger.frame.XSuspendContext)4 XStackFrame (com.intellij.xdebugger.frame.XStackFrame)2 XSourcePosition (com.intellij.xdebugger.XSourcePosition)1 XBreakpointProperties (com.intellij.xdebugger.breakpoints.XBreakpointProperties)1 XExecutionStack (com.intellij.xdebugger.frame.XExecutionStack)1 DartVmServiceSuspendContext (com.jetbrains.lang.dart.ide.runner.server.vmService.frame.DartVmServiceSuspendContext)1 Nullable (org.jetbrains.annotations.Nullable)1