Search in sources :

Example 1 with DartVmServiceSuspendContext

use of io.flutter.vmService.frame.DartVmServiceSuspendContext in project flutter-intellij by flutter.

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)) {
            final StepOption nextStep = atAsyncSuspension ? StepOption.OverAsyncSuspension : latestStep;
            // continue stepping to change current line
            myDebugProcess.getVmServiceWrapper().resumeIsolate(isolateRef.getId(), nextStep);
        } else if (exception != null) {
            final XBreakpoint<DartExceptionBreakpointProperties> breakpoint = DartExceptionBreakpointHandler.getDefaultExceptionBreakpoint(myDebugProcess.getSession().getProject());
            final boolean suspend = myDebugProcess.getSession().breakpointReached(breakpoint, null, suspendContext);
            if (!suspend) {
                myDebugProcess.getVmServiceWrapper().resumeIsolate(isolateRef.getId(), null);
            }
        } 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.warn(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(io.flutter.vmService.frame.DartVmServiceSuspendContext) XSuspendContext(com.intellij.xdebugger.frame.XSuspendContext) XBreakpoint(com.intellij.xdebugger.breakpoints.XBreakpoint) XSourcePosition(com.intellij.xdebugger.XSourcePosition) XStackFrame(com.intellij.xdebugger.frame.XStackFrame)

Example 2 with DartVmServiceSuspendContext

use of io.flutter.vmService.frame.DartVmServiceSuspendContext in project flutter-intellij by flutter.

the class DartVmServiceDebugProcess method startStepOver.

@Override
public void startStepOver(@Nullable XSuspendContext context) {
    if (myLatestCurrentIsolateId != null && mySuspendedIsolateIds.containsKey(myLatestCurrentIsolateId)) {
        final DartVmServiceSuspendContext suspendContext = (DartVmServiceSuspendContext) context;
        final StepOption stepOption = suspendContext != null && suspendContext.getAtAsyncSuspension() ? StepOption.OverAsyncSuspension : StepOption.Over;
        myVmServiceWrapper.resumeIsolate(myLatestCurrentIsolateId, stepOption);
    }
}
Also used : DartVmServiceSuspendContext(io.flutter.vmService.frame.DartVmServiceSuspendContext)

Aggregations

DartVmServiceSuspendContext (io.flutter.vmService.frame.DartVmServiceSuspendContext)2 XSourcePosition (com.intellij.xdebugger.XSourcePosition)1 XBreakpoint (com.intellij.xdebugger.breakpoints.XBreakpoint)1 XBreakpointProperties (com.intellij.xdebugger.breakpoints.XBreakpointProperties)1 XStackFrame (com.intellij.xdebugger.frame.XStackFrame)1 XSuspendContext (com.intellij.xdebugger.frame.XSuspendContext)1