package org.eclipse.tracecompass.tmf.analysis.xml.ui.views.timegraph;
+import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
+
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.TmfXmlUiStrings;
import org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.views.XmlViewInfo;
import org.eclipse.tracecompass.statesystem.core.ITmfStateSystem;
+import org.eclipse.tracecompass.statesystem.core.StateSystemUtils;
import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException;
import org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException;
import org.eclipse.tracecompass.statesystem.core.exceptions.StateValueTypeException;
import org.eclipse.tracecompass.tmf.core.statesystem.TmfStateSystemAnalysisModule;
import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
import org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager;
+import org.eclipse.tracecompass.tmf.core.trace.TmfTraceUtils;
import org.eclipse.tracecompass.tmf.ui.views.timegraph.AbstractTimeGraphView;
import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.ITimeGraphPresentationProvider2;
import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ILinkEvent;
List<Element> entries = XmlUtils.getChildElements(viewElement, TmfXmlUiStrings.ENTRY_ELEMENT);
Set<XmlEntry> entryList = new TreeSet<>(getEntryComparator());
for (ITmfTrace aTrace : TmfTraceManager.getTraceSet(trace)) {
+ aTrace = checkNotNull(aTrace);
if (monitor.isCanceled()) {
return;
}
/*
* No analysis specified, take all state system analysis modules
*/
- for (ITmfAnalysisModuleWithStateSystems module : aTrace.getAnalysisModulesOfClass(ITmfAnalysisModuleWithStateSystems.class)) {
+ for (ITmfAnalysisModuleWithStateSystems module : TmfTraceUtils.getAnalysisModulesOfClass(aTrace, ITmfAnalysisModuleWithStateSystems.class)) {
stateSystemModules.add(module);
}
} else {
for (String moduleId : analysisIds) {
- ITmfAnalysisModuleWithStateSystems module = aTrace.getAnalysisModuleOfClass(ITmfAnalysisModuleWithStateSystems.class, moduleId);
+ moduleId = checkNotNull(moduleId);
+ ITmfAnalysisModuleWithStateSystems module = TmfTraceUtils.getAnalysisModuleOfClass(aTrace, ITmfAnalysisModuleWithStateSystems.class, moduleId);
if (module != null) {
stateSystemModules.add(module);
}
}
private XmlEntry processEntry(@NonNull Element entryElement, @NonNull Element displayEl,
- XmlEntry parentEntry, int quark, ITmfStateSystem ss) {
+ @NonNull XmlEntry parentEntry, int quark, ITmfStateSystem ss) {
/*
* Get the start time and end time of this entry from the display
* attribute
entryStart, entryEnd, EntryDisplayType.DISPLAY, ss, entryElement);
}
- private void buildStatusEvent(XmlEntry traceEntry, IProgressMonitor monitor, long start, long end) {
+ private void buildStatusEvent(XmlEntry traceEntry, @NonNull IProgressMonitor monitor, long start, long end) {
long resolution = (end - start) / getDisplayWidth();
long startTime = Math.max(start, traceEntry.getStartTime());
long endTime = Math.min(end + 1, traceEntry.getEndTime());
boolean root = true;
if (!entry.getParentId().isEmpty()) {
XmlEntry parent = entryMap.get(entry.getParentId());
+ /*
+ * Associate the parent entry only if their time overlap. A
+ * child entry may start before its parent, for example at the
+ * beginning of the trace if a parent has not yet appeared in
+ * the state system. We just want to make sure that the entry
+ * didn't start after the parent ended or ended before the
+ * parent started.
+ */
if (parent != null &&
- entry.getStartTime() >= parent.getStartTime() &&
- entry.getStartTime() <= parent.getEndTime()) {
+ !(entry.getStartTime() > parent.getEndTime() ||
+ entry.getEndTime() < parent.getStartTime())) {
parent.addChild(entry);
root = false;
}
try {
if (xmlEntry.getType() == EntryDisplayType.DISPLAY) {
- List<ITmfStateInterval> statusIntervals = ssq.queryHistoryRange(quark, realStart, realEnd - 1, resolution, monitor);
+ List<ITmfStateInterval> statusIntervals = StateSystemUtils.queryHistoryRange(ssq, quark, realStart, realEnd - 1, resolution, monitor);
eventList = new ArrayList<>(statusIntervals.size());
long lastEndTime = -1;
for (ITmfStateInterval statusInterval : statusIntervals) {