Fix NPE with traces that are time scaled.
authorMatthew Khouzam <matthew.khouzam@ericsson.com>
Tue, 21 Aug 2012 20:33:18 +0000 (16:33 -0400)
committerMatthew Khouzam <matthew.khouzam@ericsson.com>
Tue, 21 Aug 2012 21:06:32 +0000 (17:06 -0400)
Change-Id: I733ccd4e29c42fb3239c25f5e8dc6f7959000e13
Signed-off-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/7337
Reviewed-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
IP-Clean: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
Tested-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
Reviewed-by: Patrick Tasse <patrick.tasse@gmail.com>
IP-Clean: Patrick Tasse <patrick.tasse@gmail.com>
Tested-by: Patrick Tasse <patrick.tasse@gmail.com>
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfIterator.java

index d215d76371f84bf47187d779a949d8797be0d00b..62add563df8ee91460fab568d9751e418dddc8dc 100644 (file)
@@ -122,7 +122,7 @@ public class CtfIterator extends CTFTraceReader implements ITmfContext,
 
         /* Adjust the timestamp depending on the trace's offset */
         long currTimestamp = ctfLocationData.getTimestamp();
-        final long offsetTimestamp = currTimestamp - this.getTrace().getOffset();
+        final long offsetTimestamp = this.getCtfTmfTrace().getCTFTrace().timestampNanoToCycles(currTimestamp);
         if (offsetTimestamp < 0) {
             ret = super.seek(0L);
         } else {
@@ -133,17 +133,21 @@ public class CtfIterator extends CTFTraceReader implements ITmfContext,
          * Check if there is already one or more events for that timestamp, and
          * assign the location index correctly
          */
-        currTimestamp = this.getCurrentEvent().getTimestampValue();
         long index = 0;
-        for (long i = 0; i < ctfLocationData.getIndex(); i++) {
-            if (currTimestamp == this.getCurrentEvent().getTimestampValue()) {
-                index++;
-            } else {
-                index = 0;
+        if (this.getCurrentEvent() != null) {
+            currTimestamp = this.getCurrentEvent().getTimestampValue();
+
+            for (long i = 0; i < ctfLocationData.getIndex(); i++) {
+                if (currTimestamp == this.getCurrentEvent().getTimestampValue()) {
+                    index++;
+                } else {
+                    index = 0;
+                }
+                this.advance();
             }
-            this.advance();
+        } else {
+            ret= false;
         }
-
         /* Seek the current location accordingly */
         if (ret) {
             curLocation.setLocation(new CtfLocationData(getCurrentEvent().getTimestampValue(), index));
This page took 0.026527 seconds and 5 git commands to generate.