From: Geneviève Bastien Date: Tue, 30 Sep 2014 19:59:38 +0000 (-0400) Subject: Tmf: Fix a bug in CFV and Xml time graph views where entries have no parent X-Git-Url: http://git.efficios.com/?a=commitdiff_plain;h=0a35a36f4a0e5e76c386bb50baebf2738f04d687;p=deliverable%2Ftracecompass.git Tmf: Fix a bug in CFV and Xml time graph views where entries have no parent If a child entry starts before the parent entry, like it happens at the beginning of a trace, then in time graph views, they are not associated with the parent. Change-Id: I3fb72049248c13aecdc41e88420eaf4dfae24911 Signed-off-by: Geneviève Bastien Reviewed-on: https://git.eclipse.org/r/35342 Tested-by: Hudson CI Reviewed-by: Patrick Tasse --- diff --git a/org.eclipse.tracecompass.lttng2.kernel.ui/src/org/eclipse/tracecompass/internal/lttng2/kernel/ui/views/controlflow/ControlFlowView.java b/org.eclipse.tracecompass.lttng2.kernel.ui/src/org/eclipse/tracecompass/internal/lttng2/kernel/ui/views/controlflow/ControlFlowView.java index 927a31c16f..a81d2ed705 100644 --- a/org.eclipse.tracecompass.lttng2.kernel.ui/src/org/eclipse/tracecompass/internal/lttng2/kernel/ui/views/controlflow/ControlFlowView.java +++ b/org.eclipse.tracecompass.lttng2.kernel.ui/src/org/eclipse/tracecompass/internal/lttng2/kernel/ui/views/controlflow/ControlFlowView.java @@ -290,19 +290,18 @@ public class ControlFlowView extends AbstractTimeGraphView { 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); @@ -346,9 +345,17 @@ public class ControlFlowView extends AbstractTimeGraphView { 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)) { diff --git a/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/tmf/analysis/xml/ui/views/timegraph/XmlEntry.java b/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/tmf/analysis/xml/ui/views/timegraph/XmlEntry.java index 96ad597752..327a07d881 100644 --- a/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/tmf/analysis/xml/ui/views/timegraph/XmlEntry.java +++ b/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/tmf/analysis/xml/ui/views/timegraph/XmlEntry.java @@ -20,8 +20,6 @@ import org.eclipse.jdt.annotation.NonNull; 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; @@ -152,20 +150,14 @@ public class XmlEntry extends TimeGraphEntry implements IXmlStateSystemContainer /** 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 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; diff --git a/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/tmf/analysis/xml/ui/views/timegraph/XmlTimeGraphView.java b/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/tmf/analysis/xml/ui/views/timegraph/XmlTimeGraphView.java index 0a7938ff3c..2b99035d65 100644 --- a/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/tmf/analysis/xml/ui/views/timegraph/XmlTimeGraphView.java +++ b/org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/tmf/analysis/xml/ui/views/timegraph/XmlTimeGraphView.java @@ -449,9 +449,17 @@ public class XmlTimeGraphView extends AbstractTimeGraphView { 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; }