Fix lost events to work after multiple reloads
authorMatthew Khouzam <matthew.khouzam@ericsson.com>
Fri, 13 Jul 2012 18:55:17 +0000 (14:55 -0400)
committerAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Fri, 13 Jul 2012 20:28:25 +0000 (16:28 -0400)
Change-Id: If086a2c99d6276b8b4b19b55124526f3ee468f70
Signed-off-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Signed-off-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/StreamInputPacketReader.java
org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/trace/StreamInputPacketIndexEntry.java

index 4c3c3447ddbdce0a7debd532adc41d5d18ecd354..015e2543d96d7e29fbe31d57264bc847f655da27 100644 (file)
@@ -32,7 +32,7 @@ import org.eclipse.linuxtools.internal.ctf.core.trace.StreamInputPacketIndexEntr
 
 /**
  * CTF trace packet reader. Reads the events of a packet of a trace file.
- * 
+ *
  * @version 1.0
  * @author Matthew Khouzam
  * @author Simon Marchi
@@ -103,6 +103,8 @@ public class StreamInputPacketReader implements IDefinitionScope {
 
     private int lostSoFar;
 
+    private int lostEventsInThisPacket;
+
     // ------------------------------------------------------------------------
     // Attributes
     // ------------------------------------------------------------------------
@@ -304,10 +306,13 @@ public class StreamInputPacketReader implements IDefinitionScope {
                 Definition lostEventsdef = getStreamPacketContextDef()
                         .lookupDefinition("events_discarded"); //$NON-NLS-1$
                 if (cpuiddef instanceof IntegerDefinition) {
-                    lostEvents = (int) ((IntegerDefinition) lostEventsdef)
+                    int totalLostEvents = (int) ((IntegerDefinition) lostEventsdef)
                             .getValue();
+                    lostEventsInThisPacket = totalLostEvents - lostEvents;
+                    lostEvents = totalLostEvents;
+                    currentPacket.setLostEvents(lostEventsInThisPacket);
+                    lostSoFar = 0;
                 }
-
             }
 
             /*
@@ -348,7 +353,7 @@ public class StreamInputPacketReader implements IDefinitionScope {
         Long eventID = null;
         long timestamp = 0;
 
-        if (lostEvents > lostSoFar) {
+        if (lostEventsInThisPacket > lostSoFar) {
             EventDefinition eventDef = EventDeclaration
                     .getLostEventDeclaration().createDefinition(
                             streamInputReader);
index aa1baf2ac1109f7b4d45cc6efc764f731179230d..e6f602bdc3cf3aec2574c8a5d17b42d5a65aeb41 100644 (file)
@@ -54,6 +54,11 @@ public class StreamInputPacketIndexEntry {
      */
     private long timestampEnd = 0;
 
+    /**
+     * How many lost events are there?
+     */
+    private long lostEvents = 0;
+
     // ------------------------------------------------------------------------
     // Constructors
     // ------------------------------------------------------------------------
@@ -183,4 +188,17 @@ public class StreamInputPacketIndexEntry {
         this.timestampEnd = timestampEnd;
     }
 
+    /**
+     * @return the lostEvents
+     */
+    public long getLostEvents() {
+        return lostEvents;
+    }
+
+    /**
+     * @param lostEvents the lostEvents to set
+     */
+    public void setLostEvents(long lostEvents) {
+        this.lostEvents = lostEvents;
+    }
 }
This page took 0.030288 seconds and 5 git commands to generate.