Tmf: Fix a bug in CFV and Xml time graph views where entries have no parent
[deliverable/tracecompass.git] / org.eclipse.tracecompass.lttng2.kernel.ui / src / org / eclipse / tracecompass / internal / lttng2 / kernel / ui / views / controlflow / ControlFlowView.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)) {
This page took 0.02709 seconds and 5 git commands to generate.