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)) {
import org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.TmfXmlUiStrings;
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.interval.ITmfStateInterval;
import org.eclipse.tracecompass.tmf.analysis.xml.core.model.ITmfXmlModelFactory;
import org.eclipse.tracecompass.tmf.analysis.xml.core.model.ITmfXmlStateAttribute;
/** Return the state value of the first interval with a non-null value */
private String getFirstValue(Element stateAttribute) {
+
ITmfXmlModelFactory factory = TmfXmlReadOnlyModelFactory.getInstance();
ITmfXmlStateAttribute display = factory.createStateAttribute(stateAttribute, this);
int quark = display.getAttributeQuark(fBaseQuark);
if (quark != IXmlStateSystemContainer.ERROR_QUARK) {
- try {
- /* Find the first attribute with a parent */
- List<ITmfStateInterval> execNameIntervals = StateSystemUtils.queryHistoryRange(fSs, quark, getStartTime(), getEndTime());
- for (ITmfStateInterval execNameInterval : execNameIntervals) {
-
- if (!execNameInterval.getStateValue().isNull()) {
- return execNameInterval.getStateValue().toString();
- }
- }
- } catch (AttributeNotFoundException | StateSystemDisposedException e) {
+ ITmfStateInterval firstInterval = StateSystemUtils.queryUntilNonNullValue(fSs, quark, getStartTime(), getEndTime());
+ if (firstInterval != null) {
+ return firstInterval.getStateValue().toString();
}
}
return EMPTY_STRING;
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;
}