@Override protected @Nullable List<ITimeEvent> getEventList( @NonNull TimeGraphEntry entry, ITmfStateSystem ssq, @NonNull List<List<ITmfStateInterval>> fullStates, @Nullable List<ITmfStateInterval> prevFullState, @NonNull IProgressMonitor monitor) { List<ITimeEvent> eventList = null; // List<List<ITimeEvent>> List = new ArrayList<>(fullStates.size()); OPS_NEUTRON_ENTRY resourcesEntry = (OPS_NEUTRON_ENTRY) entry; int quark = resourcesEntry.getQuark(); if (resourcesEntry.getType().equals(Type.SERVICE)) { int statusQuark; try { statusQuark = ssq.getQuarkRelative(quark, "Action"); // $NON-NLS-1$ } catch (AttributeNotFoundException e) { e.printStackTrace(); return null; } eventList = new ArrayList<>(fullStates.size()); ITmfStateInterval lastInterval = prevFullState == null || statusQuark >= prevFullState.size() ? null : prevFullState.get(statusQuark); long lastStartTime = lastInterval == null ? -1 : lastInterval.getStartTime(); long lastEndTime = lastInterval == null ? -1 : lastInterval.getEndTime() + 1; for (List<ITmfStateInterval> fullState : fullStates) { if (monitor.isCanceled()) { return null; } if (statusQuark >= fullState.size()) { // No information on this CPU (yet?), skip it for now continue; } ITmfStateInterval statusInterval = fullState.get(statusQuark); int status = statusInterval.getStateValue().unboxInt(); long time = statusInterval.getStartTime(); long duration = statusInterval.getEndTime() - time + 1; if (time == lastStartTime) { continue; } if (!statusInterval.getStateValue().isNull()) { if (lastEndTime != time && lastEndTime != -1) { eventList.add(new TimeEvent(entry, lastEndTime, time - lastEndTime)); } eventList.add(new TimeEvent(entry, time, duration, status)); } else { eventList.add(new NullTimeEvent(entry, time, duration)); } lastStartTime = time; lastEndTime = time + duration; } } return eventList; }
@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; }