com.intellij.xdebugger.frame.XSuspendContext Java Examples

The following examples show how to use com.intellij.xdebugger.frame.XSuspendContext. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SkylarkDebugProcess.java    From intellij with Apache License 2.0 6 votes vote down vote up
/** Blocks waiting for a response from the debugger, so must be called on a worker thread. */
private void doStartStepping(@Nullable XSuspendContext context, Stepping stepping) {
  long threadId = getThreadId(context);
  if (threadId == 0 && stepping != Stepping.NONE) {
    // TODO(brendandouglas): cache suspended threads here, and apply stepping behavior to all?
    return;
  }
  transport.sendRequest(
      DebugRequest.newBuilder()
          .setContinueExecution(
              ContinueExecutionRequest.newBuilder()
                  .setThreadId(threadId)
                  .setStepping(stepping)
                  .build()));

  currentlySteppingThreadId = threadId;

  // this is necessary because we yet aren't reliably informed of thread death. If the thread
  // finishes without triggering the stepping condition, we need to remind the debugger that there
  // could still be suspended threads remaining.
  scheduleWakeupIfNecessary(2000);
}
 
Example #2
Source File: XDebugSessionImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@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;
}
 
Example #3
Source File: XDebuggerUtilImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nullable
public static XDebuggerEvaluator getEvaluator(final XSuspendContext suspendContext) {
  XExecutionStack executionStack = suspendContext.getActiveExecutionStack();
  if (executionStack != null) {
    XStackFrame stackFrame = executionStack.getTopFrame();
    if (stackFrame != null) {
      return stackFrame.getEvaluator();
    }
  }
  return null;
}
 
Example #4
Source File: SkylarkDebugProcess.java    From intellij with Apache License 2.0 5 votes vote down vote up
private void startStepping(@Nullable XSuspendContext context, Stepping stepping) {
  if (!isConnected()) {
    return;
  }
  ApplicationManager.getApplication()
      .executeOnPooledThread(() -> doStartStepping(context, stepping));
}
 
Example #5
Source File: DartVmServiceDebugProcess.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void runToPosition(@NotNull XSourcePosition position, @Nullable XSuspendContext context) {
  if (myLatestCurrentIsolateId != null && mySuspendedIsolateIds.containsKey(myLatestCurrentIsolateId)) {
    // Set a temporary breakpoint and resume.
    myVmServiceWrapper.addTemporaryBreakpoint(position, myLatestCurrentIsolateId);
    myVmServiceWrapper.resumeIsolate(myLatestCurrentIsolateId, null);
  }
}
 
Example #6
Source File: XQueryDebugProcess.java    From intellij-xquery with Apache License 2.0 5 votes vote down vote up
@Override
public void runToPosition(@NotNull XSourcePosition position, XSuspendContext context) {
    String fileURL = XQueryBreakpointHandler.getFileUrl(position);
    int lineNumber = XQueryBreakpointHandler.getActualLineNumber(position.getLine());
    dbgpIde.breakpointSet(aLineBreakpoint(fileURL, lineNumber).withTemporary(true).build());
    dbgpIde.run();
}
 
Example #7
Source File: DartVmServiceDebugProcess.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@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);
  }
}
 
Example #8
Source File: DartVmServiceDebugProcess.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void runToPosition(@NotNull XSourcePosition position, @Nullable XSuspendContext context) {
  if (myLatestCurrentIsolateId != null && mySuspendedIsolateIds.containsKey(myLatestCurrentIsolateId)) {
    // Set a temporary breakpoint and resume.
    myVmServiceWrapper.addTemporaryBreakpoint(position, myLatestCurrentIsolateId);
    myVmServiceWrapper.resumeIsolate(myLatestCurrentIsolateId, null);
  }
}
 
Example #9
Source File: DartVmServiceDebugProcess.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@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);
  }
}
 
Example #10
Source File: XDebugSessionImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public <V extends XSmartStepIntoVariant> void smartStepInto(XSmartStepIntoHandler<V> handler, V variant) {
  if (!myDebugProcess.checkCanPerformCommands()) return;

  final XSuspendContext context = doResume();
  handler.startStepInto(variant, context);
}
 
Example #11
Source File: XDebugSessionImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
private boolean breakpointReached(@Nonnull final XBreakpoint<?> breakpoint, @Nullable String evaluatedLogExpression,
                                  @Nonnull XSuspendContext suspendContext, boolean doProcessing) {
  if (doProcessing) {
    if (breakpoint.isLogMessage()) {
      XSourcePosition position = breakpoint.getSourcePosition();
      OpenFileHyperlinkInfo hyperlinkInfo =
              position != null ? new OpenFileHyperlinkInfo(myProject, position.getFile(), position.getLine()) : null;
      printMessage(XDebuggerBundle.message("xbreakpoint.reached.text") + " ", XBreakpointUtil.getShortText(breakpoint), hyperlinkInfo);
    }

    if (evaluatedLogExpression != null) {
      printMessage(evaluatedLogExpression, null, null);
    }

    processDependencies(breakpoint);

    if (breakpoint.getSuspendPolicy() == SuspendPolicy.NONE) {
      return false;
    }
  }

  myActiveNonLineBreakpoint =
          (!(breakpoint instanceof XLineBreakpoint) || ((XLineBreakpoint)breakpoint).getType().canBeHitInOtherPlaces()) ? breakpoint : null;

  // set this session active on breakpoint, update execution position will be called inside positionReached
  myDebuggerManager.setCurrentSession(this);

  positionReachedInternal(suspendContext, true);

  if (doProcessing && breakpoint instanceof XLineBreakpoint<?> && ((XLineBreakpoint)breakpoint).isTemporary()) {
    handleTemporaryBreakpointHit(breakpoint);
  }
  return true;
}
 
Example #12
Source File: XQueryDebugProcess.java    From intellij-xquery with Apache License 2.0 4 votes vote down vote up
private XSuspendContext prepareContext(DBGpIde dbgpIde) {
    return new XQuerySuspendContext(dbgpIde, session.getProject());
}
 
Example #13
Source File: XFramesView.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public void processSessionEvent(@Nonnull SessionEvent event, @Nonnull XDebugSession session) {
  myRefresh = event == SessionEvent.SETTINGS_CHANGED;

  if (event == SessionEvent.BEFORE_RESUME) {
    return;
  }

  XExecutionStack currentExecutionStack = ((XDebugSessionImpl)session).getCurrentExecutionStack();
  XStackFrame currentStackFrame = session.getCurrentStackFrame();
  XSuspendContext suspendContext = session.getSuspendContext();

  if (event == SessionEvent.FRAME_CHANGED && Objects.equals(mySelectedStack, currentExecutionStack)) {
    ApplicationManager.getApplication().assertIsDispatchThread();
    if (currentStackFrame != null) {
      myFramesList.setSelectedValue(currentStackFrame, true);
      mySelectedFrameIndex = myFramesList.getSelectedIndex();
      myExecutionStacksWithSelection.put(mySelectedStack, mySelectedFrameIndex);
    }
    return;
  }

  EdtExecutorService.getInstance().execute(() -> {
    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 activeExecutionStack = mySelectedStack != null ? mySelectedStack : currentExecutionStack;
    addExecutionStacks(Collections.singletonList(activeExecutionStack));

    XExecutionStack[] executionStacks = suspendContext.getExecutionStacks();
    addExecutionStacks(Arrays.asList(executionStacks));

    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);
    }
    updateFrames(activeExecutionStack, session, event == SessionEvent.FRAME_CHANGED ? currentStackFrame : null);
  });
}
 
Example #14
Source File: XDebugSessionImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
public void positionReached(@Nonnull XSuspendContext suspendContext, boolean attract) {
  myActiveNonLineBreakpoint = null;
  positionReachedInternal(suspendContext, attract);
}
 
Example #15
Source File: MuleDebugProcess.java    From mule-intellij-plugins with Apache License 2.0 4 votes vote down vote up
@Override
public void startStepOver(@Nullable XSuspendContext context) {
  muleDebuggerSession.nextStep();
}
 
Example #16
Source File: XQueryDebugProcess.java    From intellij-xquery with Apache License 2.0 4 votes vote down vote up
@Override
public void startStepInto(XSuspendContext context) {
    dbgpIde.stepInto();
}
 
Example #17
Source File: XQueryDebugProcess.java    From intellij-xquery with Apache License 2.0 4 votes vote down vote up
@Override
public void startStepOut(XSuspendContext context) {
    dbgpIde.stepOut();
}
 
Example #18
Source File: XQueryDebugProcess.java    From intellij-xquery with Apache License 2.0 4 votes vote down vote up
@Override
public void resume(XSuspendContext context) {
    dbgpIde.run();
}
 
Example #19
Source File: XDebugSessionImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public void positionReached(@Nonnull final XSuspendContext suspendContext) {
  positionReached(suspendContext, false);
}
 
Example #20
Source File: XDebugSessionImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
private void positionReachedInternal(@Nonnull final XSuspendContext suspendContext, boolean attract) {
  enableBreakpoints();
  mySuspendContext = suspendContext;
  myCurrentExecutionStack = suspendContext.getActiveExecutionStack();
  myCurrentStackFrame = myCurrentExecutionStack != null ? myCurrentExecutionStack.getTopFrame() : null;
  myIsTopFrame = true;
  myTopFramePosition = myCurrentStackFrame != null ? myCurrentStackFrame.getSourcePosition() : null;

  myPaused.set(true);

  updateExecutionPosition();

  final boolean showOnSuspend = myShowTabOnSuspend.compareAndSet(true, false);
  if (showOnSuspend || attract) {
    AppUIUtil.invokeLaterIfProjectAlive(myProject, () -> {
      if (showOnSuspend) {
        initSessionTab(null);
        showSessionTab();
      }

      // user attractions should only be made if event happens independently (e.g. program paused/suspended)
      // and should not be made when user steps in the code
      if (attract) {
        if (mySessionTab == null) {
          LOG.debug("Cannot request focus because Session Tab is not initialized yet");
          return;
        }

        if (XDebuggerSettingManagerImpl.getInstanceImpl().getGeneralSettings().isShowDebuggerOnBreakpoint()) {
          mySessionTab.toFront(true, this::updateExecutionPosition);
        }

        if (myTopFramePosition == null) {
          // if there is no source position available, we should somehow tell the user that session is stopped.
          // the best way is to show the stack frames.
          XDebugSessionTab.showFramesView(this);
        }

        mySessionTab.getUi().attractBy(XDebuggerUIConstants.LAYOUT_VIEW_BREAKPOINT_CONDITION);
      }
    });
  }

  myDispatcher.getMulticaster().sessionPaused();
}
 
Example #21
Source File: XDebugSessionImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public boolean breakpointReached(@Nonnull final XBreakpoint<?> breakpoint, @Nonnull final XSuspendContext suspendContext) {
  return breakpointReached(breakpoint, null, suspendContext);
}
 
Example #22
Source File: XSmartStepIntoHandler.java    From consulo with Apache License 2.0 4 votes vote down vote up
public void startStepInto(@Nonnull Variant variant, @Nullable XSuspendContext context) {
  startStepInto(variant);
}
 
Example #23
Source File: XDebugSessionImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
public void breakpointReachedNoProcessing(@Nonnull final XBreakpoint<?> breakpoint, @Nonnull XSuspendContext suspendContext) {
  breakpointReached(breakpoint, null, suspendContext, false);
}
 
Example #24
Source File: XDebugProcess.java    From consulo with Apache License 2.0 4 votes vote down vote up
/**
 * Resume execution.
 * Do not call this method directly. Use {@link XDebugSession#resume} instead
 */
public void resume(@Nullable XSuspendContext context) {
  //noinspection deprecation
  resume();
}
 
Example #25
Source File: XQueryDebugProcess.java    From intellij-xquery with Apache License 2.0 4 votes vote down vote up
@Override
public void startStepOver(XSuspendContext context) {
    dbgpIde.stepOver();
}
 
Example #26
Source File: XDebugSessionImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public XSuspendContext getSuspendContext() {
  return mySuspendContext;
}
 
Example #27
Source File: XDebugSessionImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public boolean breakpointReached(@Nonnull final XBreakpoint<?> breakpoint, @Nullable String evaluatedLogExpression,
                                 @Nonnull XSuspendContext suspendContext) {
  return breakpointReached(breakpoint, evaluatedLogExpression, suspendContext, true);
}
 
Example #28
Source File: SkylarkDebugProcess.java    From intellij with Apache License 2.0 4 votes vote down vote up
@Override
public void resume(@Nullable XSuspendContext context) {
  // unpausing only a single thread isn't well supported by the debugging API, so pass through a
  // null suspect context, indicating all threads should be unpaused
  startStepping(null, Stepping.NONE);
}
 
Example #29
Source File: MuleDebugProcess.java    From mule-intellij-plugins with Apache License 2.0 4 votes vote down vote up
@Override
public void startStepInto(@Nullable XSuspendContext context) {
  muleDebuggerSession.nextStep();
}
 
Example #30
Source File: MuleDebugProcess.java    From mule-intellij-plugins with Apache License 2.0 4 votes vote down vote up
@Override
public void startStepOut(@Nullable XSuspendContext context) {
  muleDebuggerSession.nextStep();
}