Example #1
0
    protected void commandCancelled() {
      if (!DebuggerManagerThreadImpl.isManagerThread()) {
        return;
      }
      // context thread is not suspended
      final DebuggerContextImpl context = getDebuggerContext();

      final SuspendContextImpl suspendContext = context.getSuspendContext();
      if (suspendContext == null) {
        return;
      }
      final ThreadReferenceProxyImpl threadToSelect = context.getThreadProxy();
      if (threadToSelect == null) {
        return;
      }

      if (!suspendContext.isResumed()) {
        final SuspendContextImpl threadContext =
            SuspendManagerUtil.getSuspendContextForThread(suspendContext, threadToSelect);
        context
            .getDebugProcess()
            .getManagerThread()
            .schedule(new RebuildFramesListCommand(context, threadContext));
        refillThreadsCombo(threadToSelect);
      }
    }
Example #2
0
    public void threadAction() {
      if (myRefreshOnly && myThreadDescriptorsToUpdate.length != myThreadsCombo.getItemCount()) {
        // there is no sense in refreshing combobox if thread list has changed since creation of
        // this command
        return;
      }

      final DebuggerContextImpl context = getDebuggerContext();

      final ThreadReferenceProxyImpl threadToSelect = context.getThreadProxy();
      if (threadToSelect == null) {
        return;
      }

      final SuspendContextImpl threadContext =
          SuspendManagerUtil.getSuspendContextForThread(
              context.getSuspendContext(), threadToSelect);
      final ThreadDescriptorImpl currentThreadDescriptor =
          (ThreadDescriptorImpl) myThreadsCombo.getSelectedItem();
      final ThreadReferenceProxyImpl currentThread =
          currentThreadDescriptor != null ? currentThreadDescriptor.getThreadReference() : null;

      if (myRefreshOnly && threadToSelect.equals(currentThread)) {
        context
            .getDebugProcess()
            .getManagerThread()
            .schedule(new UpdateFramesListCommand(context, threadContext));
      } else {
        context
            .getDebugProcess()
            .getManagerThread()
            .schedule(new RebuildFramesListCommand(context, threadContext));
      }

      if (myRefreshOnly) {
        final EvaluationContextImpl evaluationContext = context.createEvaluationContext();
        for (ThreadDescriptorImpl descriptor : myThreadDescriptorsToUpdate) {
          descriptor.setContext(evaluationContext);
          descriptor.updateRepresentation(
              evaluationContext, DescriptorLabelListener.DUMMY_LISTENER);
        }
        DebuggerInvocationUtil.swingInvokeLater(
            getProject(),
            new Runnable() {
              public void run() {
                try {
                  myThreadsListener.setEnabled(false);
                  selectThread(threadToSelect);
                  myFramesList.repaint();
                } finally {
                  myThreadsListener.setEnabled(true);
                }
              }
            });
      } else { // full rebuild
        refillThreadsCombo(threadToSelect);
      }
    }
 private boolean shouldApplyContext(DebuggerContextImpl context) {
   SuspendContextImpl suspendContext = context.getSuspendContext();
   SuspendContextImpl currentContext = (SuspendContextImpl) getSession().getSuspendContext();
   if (suspendContext != null && !suspendContext.equals(currentContext)) return true;
   JavaExecutionStack currentExecutionStack =
       currentContext != null ? currentContext.getActiveExecutionStack() : null;
   return currentExecutionStack == null
       || !Comparing.equal(context.getThreadProxy(), currentExecutionStack.getThreadProxy());
 }
Example #4
0
 public void contextAction() throws Exception {
   updateFrameList(myDebuggerContext.getThreadProxy());
   DebuggerInvocationUtil.swingInvokeLater(
       getProject(),
       new Runnable() {
         public void run() {
           try {
             myFramesListener.setEnabled(false);
             final StackFrameProxyImpl contextFrame = getDebuggerContext().getFrameProxy();
             if (contextFrame != null) {
               selectFrame(contextFrame);
             }
           } finally {
             myFramesListener.setEnabled(true);
           }
         }
       });
 }
Example #5
0
    public void contextAction() throws Exception {
      final ThreadReferenceProxyImpl thread = myDebuggerContext.getThreadProxy();
      try {
        if (!getSuspendContext().getDebugProcess().getSuspendManager().isSuspended(thread)) {
          DebuggerInvocationUtil.swingInvokeLater(
              getProject(),
              new Runnable() {
                public void run() {
                  try {
                    myFramesListener.setEnabled(false);
                    synchronized (myFramesList) {
                      final DefaultListModel model = myFramesList.getModel();
                      model.clear();
                      model.addElement(
                          new Object() {
                            public String toString() {
                              return DebuggerBundle.message("frame.panel.frames.not.available");
                            }
                          });
                      myFramesList.setSelectedIndex(0);
                    }
                  } finally {
                    myFramesListener.setEnabled(true);
                  }
                }
              });

          return;
        }
      } catch (ObjectCollectedException e) {
        return;
      }

      List<StackFrameProxyImpl> frames;
      try {
        frames = thread.frames();
      } catch (EvaluateException e) {
        frames = Collections.emptyList();
      }

      final StackFrameProxyImpl contextFrame = myDebuggerContext.getFrameProxy();
      final EvaluationContextImpl evaluationContext = myDebuggerContext.createEvaluationContext();
      final DebuggerManagerThreadImpl managerThread =
          myDebuggerContext.getDebugProcess().getManagerThread();
      final MethodsTracker tracker = new MethodsTracker();
      final int totalFramesCount = frames.size();
      int index = 0;
      final long timestamp = System.nanoTime();
      for (StackFrameProxyImpl stackFrameProxy : frames) {
        managerThread.schedule(
            new AppendFrameCommand(
                getSuspendContext(),
                stackFrameProxy,
                evaluationContext,
                tracker,
                index++,
                stackFrameProxy.equals(contextFrame),
                totalFramesCount,
                timestamp));
      }
    }
 private void unsetPausedIfNeeded(DebuggerContextImpl context) {
   SuspendContextImpl suspendContext = context.getSuspendContext();
   if (suspendContext != null && context.getThreadProxy() != suspendContext.getThread()) {
     ((XDebugSessionImpl) getSession()).unsetPaused();
   }
 }