import java.util.Map;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.tracecompass.internal.lttng2.kernel.core.Attributes;
import org.eclipse.tracecompass.internal.lttng2.kernel.ui.Activator;
import org.eclipse.tracecompass.internal.lttng2.kernel.ui.Messages;
-import org.eclipse.tracecompass.lttng2.kernel.core.analysis.LttngKernelAnalysisModule;
+import org.eclipse.tracecompass.lttng2.kernel.core.analysis.kernel.LttngKernelAnalysis;
+import org.eclipse.tracecompass.lttng2.kernel.core.analysis.kernel.LttngKernelThreadInformationProvider;
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.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.model.ILinkEvent;
import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeEvent;
@Override
protected void buildEventList(final ITmfTrace trace, ITmfTrace parentTrace, IProgressMonitor monitor) {
- if (trace == null) {
- return;
- }
- ITmfStateSystem ssq = TmfStateSystemAnalysisModule.getStateSystem(trace, LttngKernelAnalysisModule.ID);
+ ITmfStateSystem ssq = TmfStateSystemAnalysisModule.getStateSystem(trace, LttngKernelAnalysis.ID);
if (ssq == null) {
return;
}
String execName = execNameInterval.getStateValue().unboxStr();
long startTime = execNameInterval.getStartTime();
long endTime = execNameInterval.getEndTime() + 1;
+
if (entry == null) {
ITmfStateInterval ppidInterval = null;
try {
int ppidQuark = ssq.getQuarkRelative(threadQuark, Attributes.PPID);
- ppidInterval = ssq.querySingleState(startTime, ppidQuark);
+ ppidInterval = StateSystemUtils.queryUntilNonNullValue(ssq, ppidQuark, startTime, endTime);
} catch (AttributeNotFoundException e) {
/* No info, keep PPID at -1 */
- } catch (StateSystemDisposedException e) {
- /* SS is closing down, time to bail */
- break;
}
+
int ppid = -1;
- if (!(ppidInterval == null) && !ppidInterval.getStateValue().isNull()) {
+ if (ppidInterval != null) {
ppid = ppidInterval.getStateValue().unboxInt();
}
entry = new ControlFlowEntry(threadQuark, trace, execName, threadId, ppid, startTime, endTime);
boolean root = (entry.getParent() == null);
if (root && entry.getParentThreadId() > 0) {
for (ControlFlowEntry parent : entryList) {
+ /*
+ * 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.getThreadId() == entry.getParentThreadId() &&
- entry.getStartTime() >= parent.getStartTime() &&
- entry.getStartTime() <= parent.getEndTime()) {
+ !(entry.getStartTime() > parent.getEndTime() ||
+ entry.getEndTime() < parent.getStartTime())) {
parent.addChild(entry);
root = false;
if (rootList != null && rootList.contains(entry)) {
removeFromEntryList(parentTrace, rootListToRemove);
}
- private void buildStatusEvents(ITmfTrace trace, ControlFlowEntry entry, IProgressMonitor monitor, long start, long end) {
+ private void buildStatusEvents(ITmfTrace trace, ControlFlowEntry entry, @NonNull IProgressMonitor monitor, long start, long end) {
if (start < entry.getEndTime() && end > entry.getStartTime()) {
- ITmfStateSystem ssq = TmfStateSystemAnalysisModule.getStateSystem(entry.getTrace(), LttngKernelAnalysisModule.ID);
+ ITmfStateSystem ssq = TmfStateSystemAnalysisModule.getStateSystem(entry.getTrace(), LttngKernelAnalysis.ID);
if (ssq == null) {
return;
}
if (realEnd <= realStart) {
return null;
}
- ITmfStateSystem ssq = TmfStateSystemAnalysisModule.getStateSystem(entry.getTrace(), LttngKernelAnalysisModule.ID);
- if (ssq == null) {
+ LttngKernelAnalysis kernelAnalysis = TmfTraceUtils.getAnalysisModuleOfClass(entry.getTrace(), LttngKernelAnalysis.class, LttngKernelAnalysis.ID);
+ if (kernelAnalysis == null) {
return null;
}
try {
- int statusQuark = ssq.getQuarkRelative(entry.getThreadQuark(), Attributes.STATUS);
- List<ITmfStateInterval> statusIntervals = StateSystemUtils.queryHistoryRange(ssq, statusQuark, realStart, realEnd - 1, resolution, monitor);
+ List<ITmfStateInterval> statusIntervals = LttngKernelThreadInformationProvider.getStatusIntervalsForThread(kernelAnalysis, entry.getThreadId(), realStart, realEnd, resolution, monitor);
eventList = new ArrayList<>(statusIntervals.size());
long lastEndTime = -1;
for (ITmfStateInterval statusInterval : statusIntervals) {
eventList.add(new TimeEvent(entry, time, duration, status));
lastEndTime = time + duration;
}
- } catch (AttributeNotFoundException | TimeRangeException e) {
- e.printStackTrace();
- } catch (StateSystemDisposedException e) {
- /* Ignored */
+ } catch (TimeRangeException e) {
+ Activator.getDefault().logError(e.getMessage());
}
return eventList;
}
if (trace == null) {
continue;
}
- ITmfStateSystem ssq = TmfStateSystemAnalysisModule.getStateSystem(trace, LttngKernelAnalysisModule.ID);
+ ITmfStateSystem ssq = TmfStateSystemAnalysisModule.getStateSystem(trace, LttngKernelAnalysis.ID);
if (ssq == null) {
continue;
}
if (trace == null) {
continue;
}
- ITmfStateSystem ssq = TmfStateSystemAnalysisModule.getStateSystem(trace, LttngKernelAnalysisModule.ID);
+ ITmfStateSystem ssq = TmfStateSystemAnalysisModule.getStateSystem(trace, LttngKernelAnalysis.ID);
if (ssq == null) {
continue;
}