Tmf: Fix a bug in CFV and Xml time graph views where entries have no parent
authorGeneviève Bastien <gbastien+lttng@versatic.net>
Tue, 30 Sep 2014 19:59:38 +0000 (15:59 -0400)
committerGenevieve Bastien <gbastien+lttng@versatic.net>
Thu, 30 Oct 2014 14:51:11 +0000 (10:51 -0400)
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 <gbastien+lttng@versatic.net>
Reviewed-on: https://git.eclipse.org/r/35342
Tested-by: Hudson CI
Reviewed-by: Patrick Tasse <patrick.tasse@gmail.com>
org.eclipse.tracecompass.lttng2.kernel.ui/src/org/eclipse/tracecompass/internal/lttng2/kernel/ui/views/controlflow/ControlFlowView.java
org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/tmf/analysis/xml/ui/views/timegraph/XmlEntry.java
org.eclipse.tracecompass.tmf.analysis.xml.ui/src/org/eclipse/tracecompass/tmf/analysis/xml/ui/views/timegraph/XmlTimeGraphView.java

index 927a31c16fdebce45df46eff3e5de61cce4131e8..a81d2ed7058bfa99f94db0c0196ab4c47908626a 100644 (file)
@@ -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)) {
index 96ad597752dabb776412f7bbc0a274c4bce55200..327a07d8819ace83faa1a24d209f79379eeae882 100644 (file)
@@ -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<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;
index 0a7938ff3c20870b61f5c957a1dd5f0f4a362dba..2b99035d65b4935d4dc32344af6a4037a79af98f 100644 (file)
@@ -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;
                 }
This page took 0.03162 seconds and 5 git commands to generate.