ss: Add timestamp parameter to debugPrint for intervals
authorGeneviève Bastien <gbastien+lttng@versatic.net>
Mon, 18 Apr 2016 14:51:41 +0000 (10:51 -0400)
committerGenevieve Bastien <gbastien+lttng@versatic.net>
Wed, 6 Jul 2016 15:58:42 +0000 (11:58 -0400)
Printing the intervals is useful for debugging, but for large history trees,
it can get very big. Printing only nodes intersecting a given time range may
be more realistic, for instance to debug an incoherent interval storage when
querying at time t.

Change-Id: I0d71725c6cbe3bd3ad8abf9e9b5d7588aefc094f
Signed-off-by: Geneviève Bastien <gbastien+lttng@versatic.net>
Reviewed-on: https://git.eclipse.org/r/70886
Reviewed-by: Hudson CI
Reviewed-by: Alexandre Montplaisir <alexmonthy@efficios.com>
Tested-by: Alexandre Montplaisir <alexmonthy@efficios.com>
statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/backend/historytree/HTNode.java
statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/backend/historytree/HistoryTree.java
statesystem/org.eclipse.tracecompass.statesystem.core/src/org/eclipse/tracecompass/internal/statesystem/core/backend/historytree/HistoryTreeBackend.java

index 6fb5d644a510e2b14c62f161a16500b714d13c0d..651120bb7da9e5e3506946ff63d5af08b316ff74 100644 (file)
@@ -604,7 +604,7 @@ public abstract class HTNode {
     @SuppressWarnings("nls")
     public void debugPrintIntervals(PrintWriter writer) {
         /* Only used for debugging, shouldn't be externalized */
-        writer.println("Node #" + fSequenceNumber + ":");
+        writer.println("Intervals for node #" + fSequenceNumber + ":");
 
         /* Array of children */
         if (getNodeType() == NodeType.CORE) { /* Only Core Nodes can have children */
index 33d33d120e144ed5e02e5ba9e826c7d2cdedb084..af0b7f6981a38b877616f4680c45afb953e15f8d 100644 (file)
@@ -795,10 +795,13 @@ public class HistoryTree {
     /* Only used for debugging, shouldn't be externalized */
     @SuppressWarnings("nls")
     private void preOrderPrint(PrintWriter writer, boolean printIntervals,
-            HTNode currentNode, int curDepth) {
+            HTNode currentNode, int curDepth, long ts) {
 
         writer.println(currentNode.toString());
-        if (printIntervals) {
+        /* Print intervals only if timestamp is negative or within the range of the node */
+        if (printIntervals &&
+                (ts <= 0 ||
+                (ts >= currentNode.getNodeStart() && ts <= currentNode.getNodeEnd()))) {
             currentNode.debugPrintIntervals(writer);
         }
 
@@ -814,7 +817,7 @@ public class HistoryTree {
                 int extension = node.getExtensionSequenceNumber();
                 while (extension != -1) {
                     HTNode nextNode = fTreeIO.readNode(extension);
-                    preOrderPrint(writer, printIntervals, nextNode, curDepth);
+                    preOrderPrint(writer, printIntervals, nextNode, curDepth, ts);
                 }
 
                 /* Print the child nodes */
@@ -824,7 +827,7 @@ public class HistoryTree {
                         writer.print("  ");
                     }
                     writer.print("+-");
-                    preOrderPrint(writer, printIntervals, nextNode, curDepth + 1);
+                    preOrderPrint(writer, printIntervals, nextNode, curDepth + 1, ts);
                 }
             } catch (ClosedChannelException e) {
                 Activator.getDefault().logError(e.getMessage());
@@ -843,15 +846,18 @@ public class HistoryTree {
      *            PrintWriter in which to write the output
      * @param printIntervals
      *            Flag to enable full output of the interval information
+     * @param ts
+     *            The timestamp that nodes have to intersect for intervals to be
+     *            printed. A negative value will print intervals for all nodes.
+     *            The timestamp only applies if printIntervals is true.
      */
-    public void debugPrintFullTree(PrintWriter writer, boolean printIntervals) {
+    public void debugPrintFullTree(PrintWriter writer, boolean printIntervals, long ts) {
         /* Only used for debugging, shouldn't be externalized */
 
-        preOrderPrint(writer, false, fLatestBranch.get(0), 0);
+        preOrderPrint(writer, false, fLatestBranch.get(0), 0, ts);
 
         if (printIntervals) {
-            writer.println("\nDetails of intervals:"); //$NON-NLS-1$
-            preOrderPrint(writer, true, fLatestBranch.get(0), 0);
+            preOrderPrint(writer, true, fLatestBranch.get(0), 0, ts);
         }
         writer.println('\n');
     }
index 97dd73ee29ec3f4284981bf3b9c421e16808aa95..c867fb94c71be55881ef586fc359acd1f1c95391 100644 (file)
@@ -366,7 +366,7 @@ public class HistoryTreeBackend implements IStateHistoryBackend {
     @Override
     public void debugPrint(PrintWriter writer) {
         /* By default don't print out all the intervals */
-        debugPrint(writer, false);
+        debugPrint(writer, false, -1);
     }
 
     /**
@@ -379,8 +379,12 @@ public class HistoryTreeBackend implements IStateHistoryBackend {
      *            The PrintWriter to which the debug info will be written
      * @param printIntervals
      *            Should we also print every contained interval individually?
+     * @param ts
+     *            The timestamp that nodes have to intersect for intervals to be
+     *            printed. A negative value will print intervals for all nodes.
+     *            The timestamp only applies if printIntervals is true.
      */
-    public void debugPrint(PrintWriter writer, boolean printIntervals) {
+    public void debugPrint(PrintWriter writer, boolean printIntervals, long ts) {
         /* Only used for debugging, shouldn't be externalized */
         writer.println("------------------------------"); //$NON-NLS-1$
         writer.println("State History Tree:\n"); //$NON-NLS-1$
@@ -389,6 +393,6 @@ public class HistoryTreeBackend implements IStateHistoryBackend {
                 + getAverageNodeUsage());
         writer.println(""); //$NON-NLS-1$
 
-        getSHT().debugPrintFullTree(writer, printIntervals);
+        getSHT().debugPrintFullTree(writer, printIntervals, ts);
     }
 }
This page took 0.02766 seconds and 5 git commands to generate.