Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick Tasse2014-05-16 12:31:23 -0400
committerPatrick Tasse2014-06-03 17:02:05 -0400
commitc97ab50940658a66f74cf880a07fb26ee3c6cfd9 (patch)
tree1131d41b1de981841ef674387572c846e055218f
parent4ca33ea2acd5c1efa147f46cdbb7bb1dd2e7e791 (diff)
downloadorg.eclipse.linuxtools-c97ab50940658a66f74cf880a07fb26ee3c6cfd9.tar.gz
org.eclipse.linuxtools-c97ab50940658a66f74cf880a07fb26ee3c6cfd9.tar.xz
org.eclipse.linuxtools-c97ab50940658a66f74cf880a07fb26ee3c6cfd9.zip
tmf: Bug 421475: Inaccurate seek for traces with timestamp transform
The CtfLocation now holds the original (untransformed) timestamp value. Change-Id: I8f1b435469fd3c9ee32720fc367524d734abb145 Signed-off-by: Patrick Tasse <patrick.tasse@gmail.com> Reviewed-on: https://git.eclipse.org/r/27860 Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com> Tested-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/CTFTrace.java30
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ctf.core/src/org/eclipse/linuxtools/tmf/ctf/core/CtfIterator.java23
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ctf.core/src/org/eclipse/linuxtools/tmf/ctf/core/CtfTmfContext.java7
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ctf.core/src/org/eclipse/linuxtools/tmf/ctf/core/CtfTmfTrace.java12
4 files changed, 58 insertions, 14 deletions
diff --git a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/CTFTrace.java b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/CTFTrace.java
index 563d8215cc..51af54d73d 100644
--- a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/CTFTrace.java
+++ b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/CTFTrace.java
@@ -738,6 +738,36 @@ public class CTFTrace implements IDefinitionScope, AutoCloseable {
}
/**
+ * Gets the current first packet start time
+ * @return the current start time
+ * @since 3.0
+ */
+ public long getCurrentStartTime() {
+ long currentStart = Long.MAX_VALUE;
+ for (CTFStream stream : fStreams.values()) {
+ for (CTFStreamInput si : stream.getStreamInputs()) {
+ currentStart = Math.min(currentStart, si.getIndex().getEntries().get(0).getTimestampBegin());
+ }
+ }
+ return timestampCyclesToNanos(currentStart);
+ }
+
+ /**
+ * Gets the current last packet end time
+ * @return the current end time
+ * @since 3.0
+ */
+ public long getCurrentEndTime() {
+ long currentEnd = Long.MIN_VALUE;
+ for (CTFStream stream : fStreams.values()) {
+ for (CTFStreamInput si : stream.getStreamInputs()) {
+ currentEnd = Math.max(currentEnd, si.getTimestampEnd());
+ }
+ }
+ return timestampCyclesToNanos(currentEnd);
+ }
+
+ /**
* Does the trace need to time scale?
*
* @return if the trace is in ns or cycles.
diff --git a/lttng/org.eclipse.linuxtools.tmf.ctf.core/src/org/eclipse/linuxtools/tmf/ctf/core/CtfIterator.java b/lttng/org.eclipse.linuxtools.tmf.ctf.core/src/org/eclipse/linuxtools/tmf/ctf/core/CtfIterator.java
index a08b29c3d5..7d384fbcbd 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ctf.core/src/org/eclipse/linuxtools/tmf/ctf/core/CtfIterator.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ctf.core/src/org/eclipse/linuxtools/tmf/ctf/core/CtfIterator.java
@@ -14,8 +14,8 @@
package org.eclipse.linuxtools.tmf.ctf.core;
import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException;
-import org.eclipse.linuxtools.ctf.core.trace.CTFTraceReader;
import org.eclipse.linuxtools.ctf.core.trace.CTFStreamInputReader;
+import org.eclipse.linuxtools.ctf.core.trace.CTFTraceReader;
import org.eclipse.linuxtools.internal.tmf.ctf.core.Activator;
import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
import org.eclipse.linuxtools.tmf.core.trace.location.ITmfLocation;
@@ -140,6 +140,21 @@ public class CtfIterator extends CTFTraceReader
}
/**
+ * Return the current timestamp location pointed to by the iterator.
+ * This is the timestamp for use in CtfLocation, not the event timestamp.
+ *
+ * @return long The current timestamp location
+ */
+ public synchronized long getCurrentTimestamp() {
+ final CTFStreamInputReader top = super.getPrio().peek();
+ if (top != null) {
+ long ts = top.getCurrentEvent().getTimestamp();
+ return fTrace.getCTFTrace().timestampCyclesToNanos(ts);
+ }
+ return 0;
+ }
+
+ /**
* Seek this iterator to a given location.
*
* @param ctfLocationData
@@ -210,8 +225,6 @@ public class CtfIterator extends CTFTraceReader
@Override
public synchronized boolean advance() {
- long index = fCurLocation.getLocationInfo().getIndex();
- long timestamp = fCurLocation.getLocationInfo().getTimestamp();
boolean ret = false;
try {
ret = super.advance();
@@ -220,8 +233,10 @@ public class CtfIterator extends CTFTraceReader
}
if (ret) {
- final long timestampValue = getCurrentEvent().getTimestamp().getValue();
+ long timestamp = fCurLocation.getLocationInfo().getTimestamp();
+ final long timestampValue = getCurrentTimestamp();
if (timestamp == timestampValue) {
+ long index = fCurLocation.getLocationInfo().getIndex();
fCurLocation = new CtfLocation(timestampValue, index + 1);
} else {
fCurLocation = new CtfLocation(timestampValue, 0L);
diff --git a/lttng/org.eclipse.linuxtools.tmf.ctf.core/src/org/eclipse/linuxtools/tmf/ctf/core/CtfTmfContext.java b/lttng/org.eclipse.linuxtools.tmf.ctf.core/src/org/eclipse/linuxtools/tmf/ctf/core/CtfTmfContext.java
index 991049445f..0825b84f2f 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ctf.core/src/org/eclipse/linuxtools/tmf/ctf/core/CtfTmfContext.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ctf.core/src/org/eclipse/linuxtools/tmf/ctf/core/CtfTmfContext.java
@@ -126,11 +126,12 @@ public class CtfTmfContext implements ITmfContext {
*/
public synchronized boolean advance() {
final CtfLocationInfo curLocationData = fCurLocation.getLocationInfo();
- boolean retVal = getIterator().advance();
- CtfTmfEvent currentEvent = getIterator().getCurrentEvent();
+ CtfIterator iterator = getIterator();
+ boolean retVal = iterator.advance();
+ CtfTmfEvent currentEvent = iterator.getCurrentEvent();
if (currentEvent != null) {
- final long timestampValue = currentEvent.getTimestamp().getValue();
+ final long timestampValue = iterator.getCurrentTimestamp();
if (curLocationData.getTimestamp() == timestampValue) {
fCurLocation = new CtfLocation(timestampValue, curLocationData.getIndex() + 1);
} else {
diff --git a/lttng/org.eclipse.linuxtools.tmf.ctf.core/src/org/eclipse/linuxtools/tmf/ctf/core/CtfTmfTrace.java b/lttng/org.eclipse.linuxtools.tmf.ctf.core/src/org/eclipse/linuxtools/tmf/ctf/core/CtfTmfTrace.java
index 8d7ecac771..2566ff3c59 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ctf.core/src/org/eclipse/linuxtools/tmf/ctf/core/CtfTmfTrace.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ctf.core/src/org/eclipse/linuxtools/tmf/ctf/core/CtfTmfTrace.java
@@ -260,14 +260,12 @@ public class CtfTmfTrace extends TmfTrace
context.setRank(0);
}
if (currentLocation.getLocationInfo() == CtfLocation.INVALID_LOCATION) {
- currentLocation = new CtfLocation(getEndTime().getValue() + 1, 0L);
+ currentLocation = new CtfLocation(getCTFTrace().getCurrentEndTime() + 1, 0L);
}
context.setLocation(currentLocation);
if (location == null) {
- CtfTmfEvent event = getIterator(this, context).getCurrentEvent();
- if (event != null) {
- currentLocation = new CtfLocation(event.getTimestamp().getValue(), 0);
- }
+ long timestamp = getIterator(this, context).getCurrentTimestamp();
+ currentLocation = new CtfLocation(timestamp, 0);
}
if (context.getRank() != 0) {
context.setRank(ITmfContext.UNKNOWN_RANK);
@@ -283,8 +281,8 @@ public class CtfTmfTrace extends TmfTrace
context.setRank(ITmfContext.UNKNOWN_RANK);
return context;
}
- final long end = this.getEndTime().getValue();
- final long start = this.getStartTime().getValue();
+ final long end = getCTFTrace().getCurrentEndTime();
+ final long start = getCTFTrace().getCurrentStartTime();
final long diff = end - start;
final long ratioTs = Math.round(diff * ratio) + start;
context.seek(ratioTs);

Back to the top