コード例 #1
0
  @Override
  public boolean isActive(ITimeGraphEntry element) {
    if (element instanceof ControlFlowEntry) {
      ControlFlowEntry cfe = (ControlFlowEntry) element;

      TmfTraceManager traceManager = TmfTraceManager.getInstance();
      TmfTraceContext traceContext = traceManager.getCurrentTraceContext();
      TmfTimeRange winRange = traceContext.getWindowRange();
      TmfTimeRange selRange = traceContext.getSelectionRange();

      /* Take precedence of selection over window range. */
      long beginTS = selRange.getStartTime().getValue();
      long endTS = selRange.getEndTime().getValue();

      /* No selection, take window range */
      if (beginTS == endTS) {
        beginTS = winRange.getStartTime().getValue();
        endTS = winRange.getEndTime().getValue();
      }

      ITmfTrace trace = cfe.getTrace();
      ITmfStateSystem ssq =
          TmfStateSystemAnalysisModule.getStateSystem(trace, KernelAnalysisModule.ID);
      if (ssq != null) {
        beginTS = Math.max(beginTS, ssq.getStartTime());
        endTS = Math.min(endTS, ssq.getCurrentEndTime());
        if (beginTS > endTS) {
          return false;
        }
        try {
          int statusQuark = ssq.getQuarkRelative(cfe.getThreadQuark(), Attributes.STATUS);

          /* Get the initial state at beginTS */
          ITmfStateInterval currentInterval = ssq.querySingleState(beginTS, statusQuark);
          if (isIntervalInStateActive(currentInterval)) {
            return true;
          }

          /* Get the following state changes */
          long ts = currentInterval.getEndTime();
          while (ts != -1 && ts < endTS) {
            ts++; /* To "jump over" to the next state in the history */
            currentInterval = ssq.querySingleState(ts, statusQuark);
            if (isIntervalInStateActive(currentInterval)) {
              return true;
            }
            ts = currentInterval.getEndTime();
          }
        } catch (AttributeNotFoundException | StateSystemDisposedException e) {
          /* Ignore ... */
        }
      }
    }

    return false;
  }
コード例 #2
0
  @Override
  protected IStatus run(IProgressMonitor monitor) {

    /* Wait until the analysis is ready to be queried */
    fStatsMod.waitForInitialization();
    ITmfStatistics stats = fStatsMod.getStatistics();
    if (stats == null) {
      /* It should have worked, but didn't */
      throw new IllegalStateException();
    }

    /*
     * TODO Eventually this could be exposed through the
     * TmfStateSystemAnalysisModule directly.
     */
    ITmfStateSystem ss = fStatsMod.getStateSystem(TmfStatisticsEventTypesModule.ID);
    if (ss == null) {
      /*
       * It should be instantiated after the
       * statsMod.waitForInitialization() above.
       */
      throw new IllegalStateException();
    }

    /*
     * Periodically update the statistics while they are being built (or, if
     * the back-end is already completely built, it will skip over the
     * while() immediately.
     */
    long start = 0;
    long end = 0;
    boolean finished = false;
    do {
      /* This model update is done every second */
      if (monitor.isCanceled()) {
        fViewer.removeFromJobs(fIsGlobal, fJobTrace);
        return Status.CANCEL_STATUS;
      }
      finished = ss.waitUntilBuilt(LIVE_UPDATE_DELAY);
      TmfTimeRange localtimeRange = fTimerange;
      /*
       * The generic statistics are stored in nanoseconds, so we must make
       * sure the time range is scaled correctly.
       */
      start = localtimeRange.getStartTime().normalize(0, TIME_SCALE).getValue();
      end = localtimeRange.getEndTime().normalize(0, TIME_SCALE).getValue();

      Map<String, Long> map = stats.getEventTypesInRange(start, end);
      updateStats(map);
    } while (!finished);

    /* Query one last time for the final values */
    Map<String, Long> map = stats.getEventTypesInRange(start, end);
    updateStats(map);
    fViewer.refreshPieCharts(fIsGlobal, !fIsGlobal);
    /*
     * Remove job from map so that new range selection updates can be
     * processed.
     */
    fViewer.removeFromJobs(fIsGlobal, fJobTrace);
    return Status.OK_STATUS;
  }
コード例 #3
0
 private void timeGraphIsReadyCondition(@NonNull TmfTimeRange selectionRange) {
   IWorkbenchPart part = fViewBot.getViewReference().getPart(false);
   fBot.waitUntil(
       ConditionHelpers.timeGraphIsReadyCondition(
           (AbstractTimeGraphView) part, selectionRange, selectionRange.getEndTime()));
 }