com.intellij.xdebugger.frame.XExecutionStack Java Examples

The following examples show how to use com.intellij.xdebugger.frame.XExecutionStack. 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
void listFrames(long threadId, XExecutionStack.XStackFrameContainer container) {
  DebugEvent response =
      transport.sendRequest(
          DebugRequest.newBuilder()
              .setListFrames(
                  StarlarkDebuggingProtos.ListFramesRequest.newBuilder().setThreadId(threadId)));
  if (response == null) {
    container.errorOccurred("No frames data received from the Skylark debugger");
    return;
  }
  if (response.hasError()) {
    container.errorOccurred(response.getError().getMessage());
    return;
  }
  checkState(response.getPayloadCase() == PayloadCase.LIST_FRAMES);
  List<StarlarkDebuggingProtos.Frame> frames = response.getListFrames().getFrameList();
  container.addStackFrames(
      frames.stream().map(f -> convert(threadId, f)).collect(Collectors.toList()), true);
}
 
Example #2
Source File: XFramesView.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void updateFrames(XExecutionStack executionStack, @Nonnull XDebugSession session, @Nullable XStackFrame frameToSelect) {
  if (mySelectedStack != null) {
    getOrCreateBuilder(mySelectedStack, session).stop();
  }

  mySelectedStack = executionStack;
  if (executionStack != null) {
    mySelectedFrameIndex = myExecutionStacksWithSelection.get(executionStack);
    StackFramesListBuilder builder = getOrCreateBuilder(executionStack, session);
    builder.setToSelect(frameToSelect != null ? frameToSelect : mySelectedFrameIndex);
    myListenersEnabled = false;
    builder.initModel(myFramesList.getModel());
    myListenersEnabled = !builder.start();
  }
}
 
Example #3
Source File: XFramesView.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void addExecutionStacks(List<? extends XExecutionStack> executionStacks) {
  for (XExecutionStack executionStack : executionStacks) {
    if (!myExecutionStacksWithSelection.contains(executionStack)) {
      //noinspection unchecked
      myThreadComboBox.addItem(executionStack);
      myExecutionStacksWithSelection.put(executionStack, 0);
    }
  }
}
 
Example #4
Source File: SkylarkSuspendContext.java    From intellij with Apache License 2.0 5 votes vote down vote up
@Override
public XExecutionStack[] getExecutionStacks() {
  final Collection<PausedThreadState> threads = debugProcess.getPausedThreads();
  if (threads.isEmpty()) {
    return XExecutionStack.EMPTY_ARRAY;
  }
  XExecutionStack[] stacks = new XExecutionStack[threads.size()];
  int i = 0;
  for (PausedThreadState thread : threads) {
    stacks[i++] = new SkylarkExecutionStack(debugProcess, thread);
  }
  return stacks;
}
 
Example #5
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 #6
Source File: ThreadComboBoxRenderer.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
protected void customizeCellRenderer(@Nonnull JList<? extends XExecutionStack> list, XExecutionStack value, int index, boolean selected, boolean hasFocus) {
  if (value != null) {
    append(value.getDisplayName());
    setIcon(value.getIcon());
  }
}
 
Example #7
Source File: XDebugSessionImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void showExecutionPoint() {
  if (mySuspendContext != null) {
    XExecutionStack executionStack = mySuspendContext.getActiveExecutionStack();
    if (executionStack != null) {
      XStackFrame topFrame = executionStack.getTopFrame();
      if (topFrame != null) {
        setCurrentStackFrame(executionStack, topFrame, true);
        myDebuggerManager.showExecutionPosition();
      }
    }
  }
}
 
Example #8
Source File: XDebugSessionImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void setCurrentStackFrame(@Nonnull XExecutionStack executionStack, @Nonnull XStackFrame frame, boolean isTopFrame) {
  if (mySuspendContext == null) return;

  boolean frameChanged = myCurrentStackFrame != frame;
  myCurrentExecutionStack = executionStack;
  myCurrentStackFrame = frame;
  myIsTopFrame = isTopFrame;
  activateSession();

  if (frameChanged) {
    myDispatcher.getMulticaster().stackFrameChanged();
  }
}
 
Example #9
Source File: XDebugSessionImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
public XExecutionStack getCurrentExecutionStack() {
  return myCurrentExecutionStack;
}
 
Example #10
Source File: CppSuspendContext.java    From CppTools with Apache License 2.0 4 votes vote down vote up
@Override
public XExecutionStack[] getExecutionStacks() {
  return myThreadStacks;
}
 
Example #11
Source File: CppSuspendContext.java    From CppTools with Apache License 2.0 4 votes vote down vote up
@Override
public XExecutionStack getActiveExecutionStack() {
  return myActiveThreadStack;
}
 
Example #12
Source File: XFramesView.java    From consulo with Apache License 2.0 4 votes vote down vote up
private StackFramesListBuilder(final XExecutionStack executionStack, XDebugSession session) {
  myExecutionStack = executionStack;
  mySession = session;
  myStackFrames = new ArrayList<>();
}
 
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: XFramesView.java    From consulo with Apache License 2.0 4 votes vote down vote up
private StackFramesListBuilder getOrCreateBuilder(XExecutionStack executionStack, XDebugSession session) {
  return myBuilders.computeIfAbsent(executionStack, k -> new StackFramesListBuilder(executionStack, session));
}
 
Example #15
Source File: XFramesView.java    From consulo with Apache License 2.0 4 votes vote down vote up
public void selectFrame(XExecutionStack stack, XStackFrame frame) {
  myThreadComboBox.setSelectedItem(stack);

  EdtExecutorService.getInstance().execute(() -> myFramesList.setSelectedValue(frame, true));
}
 
Example #16
Source File: MuleSuspendContext.java    From mule-intellij-plugins with Apache License 2.0 4 votes vote down vote up
@Override
public XExecutionStack getActiveExecutionStack() {
    return muleExecutionStack;
}
 
Example #17
Source File: XDebugSession.java    From consulo with Apache License 2.0 4 votes vote down vote up
default void setCurrentStackFrame(@Nonnull XExecutionStack executionStack, @Nonnull XStackFrame frame) {
  setCurrentStackFrame(executionStack, frame, frame.equals(executionStack.getTopFrame()));
}
 
Example #18
Source File: XQuerySuspendContext.java    From intellij-xquery with Apache License 2.0 4 votes vote down vote up
@Nullable
@Override
public XExecutionStack getActiveExecutionStack() {
    return new XQueryExecutionStack("XQuery stack", dbgpIde, project);
}
 
Example #19
Source File: DartVmServiceSuspendContext.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@NotNull
@Override
public XExecutionStack getActiveExecutionStack() {
  return myActiveExecutionStack;
}
 
Example #20
Source File: VmServiceWrapper.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public void computeStackFrames(@NotNull final String isolateId,
                               final int firstFrameIndex,
                               @NotNull final XExecutionStack.XStackFrameContainer container,
                               @Nullable final InstanceRef exception) {
  addRequest(() -> myVmService.getStack(isolateId, new StackConsumer() {
    @Override
    public void received(final Stack vmStack) {
      ApplicationManager.getApplication().executeOnPooledThread(() -> {
        InstanceRef exceptionToAddToFrame = exception;

        // Check for async causal frames; fall back to using regular sync frames.
        ElementList<Frame> elementList = vmStack.getAsyncCausalFrames();
        if (elementList == null) {
          elementList = vmStack.getFrames();
        }

        final List<Frame> vmFrames = Lists.newArrayList(elementList);
        final List<XStackFrame> xStackFrames = new ArrayList<>(vmFrames.size());

        for (final Frame vmFrame : vmFrames) {
          if (vmFrame.getKind() == FrameKind.AsyncSuspensionMarker) {
            // Render an asynchronous gap.
            final XStackFrame markerFrame = new DartAsyncMarkerFrame();
            xStackFrames.add(markerFrame);
          }
          else {
            final DartVmServiceStackFrame stackFrame =
              new DartVmServiceStackFrame(myDebugProcess, isolateId, vmFrame, vmFrames, exceptionToAddToFrame);
            stackFrame.setIsDroppableFrame(vmFrame.getKind() == FrameKind.Regular);
            xStackFrames.add(stackFrame);

            if (!stackFrame.isInDartSdkPatchFile()) {
              // The exception (if any) is added to the frame where debugger stops and to the upper frames.
              exceptionToAddToFrame = null;
            }
          }
        }
        container.addStackFrames(firstFrameIndex == 0 ? xStackFrames : xStackFrames.subList(firstFrameIndex, xStackFrames.size()), true);
      });
    }

    @Override
    public void onError(final RPCError error) {
      container.errorOccurred(error.getMessage());
    }
  }));
}
 
Example #21
Source File: DartVmServiceSuspendContext.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@NotNull
@Override
public XExecutionStack getActiveExecutionStack() {
  return myActiveExecutionStack;
}
 
Example #22
Source File: VmServiceWrapper.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public void computeStackFrames(@NotNull final String isolateId,
                               final int firstFrameIndex,
                               @NotNull final XExecutionStack.XStackFrameContainer container,
                               @Nullable final InstanceRef exception) {
  addRequest(() -> myVmService.getStack(isolateId, new StackConsumer() {
    @Override
    public void received(final Stack vmStack) {
      ApplicationManager.getApplication().executeOnPooledThread(() -> {
        InstanceRef exceptionToAddToFrame = exception;

        // Check for async causal frames; fall back to using regular sync frames.
        ElementList<Frame> elementList = vmStack.getAsyncCausalFrames();
        if (elementList == null) {
          elementList = vmStack.getFrames();
        }

        final List<Frame> vmFrames = Lists.newArrayList(elementList);
        final List<XStackFrame> xStackFrames = new ArrayList<>(vmFrames.size());

        for (final Frame vmFrame : vmFrames) {
          if (vmFrame.getKind() == FrameKind.AsyncSuspensionMarker) {
            // Render an asynchronous gap.
            final XStackFrame markerFrame = new DartAsyncMarkerFrame();
            xStackFrames.add(markerFrame);
          }
          else {
            final DartVmServiceStackFrame stackFrame =
              new DartVmServiceStackFrame(myDebugProcess, isolateId, vmFrame, vmFrames, exceptionToAddToFrame);
            stackFrame.setIsDroppableFrame(vmFrame.getKind() == FrameKind.Regular);
            xStackFrames.add(stackFrame);

            if (!stackFrame.isInDartSdkPatchFile()) {
              // The exception (if any) is added to the frame where debugger stops and to the upper frames.
              exceptionToAddToFrame = null;
            }
          }
        }
        container.addStackFrames(firstFrameIndex == 0 ? xStackFrames : xStackFrames.subList(firstFrameIndex, xStackFrames.size()), true);
      });
    }

    @Override
    public void onError(final RPCError error) {
      container.errorOccurred(error.getMessage());
    }
  }));
}
 
Example #23
Source File: WeaveSuspendContext.java    From mule-intellij-plugins with Apache License 2.0 4 votes vote down vote up
@Override
public XExecutionStack getActiveExecutionStack()
{
    return weaveExecutionStack;
}
 
Example #24
Source File: XDebugSession.java    From consulo with Apache License 2.0 votes vote down vote up
void setCurrentStackFrame(@Nonnull XExecutionStack executionStack, @Nonnull XStackFrame frame, boolean isTopFrame);