summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorMatthew Khouzam2012-03-29 10:38:52 (EDT)
committer Francois Chouinard2012-04-16 14:20:12 (EDT)
commitef3e3f83bea4e1c1071f1d692096eafb9a444f65 (patch)
tree12880954af82b92e65fb44c20c91f81375c855b0
parentd2ada18550e299323a68a43746f6b5d23406dcf5 (diff)
downloadorg.eclipse.linuxtools-ef3e3f83bea4e1c1071f1d692096eafb9a444f65.zip
org.eclipse.linuxtools-ef3e3f83bea4e1c1071f1d692096eafb9a444f65.tar.gz
org.eclipse.linuxtools-ef3e3f83bea4e1c1071f1d692096eafb9a444f65.tar.bz2
add fallback for seeking by unindexed traces
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/headless/ReadTrace.java9
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/CTFTraceReaderTest.java3
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/CTFTraceReader.java33
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/StreamInputReader.java5
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/.classpath1
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/META-INF/MANIFEST.MF3
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfIterator.java10
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfTrace.java6
8 files changed, 49 insertions, 21 deletions
diff --git a/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/headless/ReadTrace.java b/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/headless/ReadTrace.java
index 9d28f30..d5424ab 100644
--- a/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/headless/ReadTrace.java
+++ b/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/headless/ReadTrace.java
@@ -93,7 +93,12 @@ public class ReadTrace {
System.out.print(val);
System.out.print(", ");
}
- testSeekIndex(trace);
+ try {
+ testSeekIndex(trace);
+ } catch (CTFReaderException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
try {
testSeekIndex(trace);
@@ -166,7 +171,7 @@ public class ReadTrace {
return Long.MIN_VALUE;
}
- public static void testSeekIndex(CTFTrace trace) {
+ public static void testSeekIndex(CTFTrace trace) throws CTFReaderException {
CTFTraceReader fixture = new CTFTraceReader(trace);
long rank = 300000L;
long timeRank = 4281275394331L;
diff --git a/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/CTFTraceReaderTest.java b/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/CTFTraceReaderTest.java
index 67ff442..3177f54 100644
--- a/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/CTFTraceReaderTest.java
+++ b/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/CTFTraceReaderTest.java
@@ -284,9 +284,10 @@ public class CTFTraceReaderTest {
/**
* Run the boolean seek(long) method test.
+ * @throws CTFReaderException
*/
@Test
- public void testSeekIndex() {
+ public void testSeekIndex() throws CTFReaderException {
long rank = 30000L;
long first, second = 0, third , fourth;
/*
diff --git a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/CTFTraceReader.java b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/CTFTraceReader.java
index 2632eea..5ebf5cc 100644
--- a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/CTFTraceReader.java
+++ b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/CTFTraceReader.java
@@ -19,7 +19,7 @@ import java.util.Vector;
import org.eclipse.linuxtools.ctf.core.event.EventDefinition;
import org.eclipse.linuxtools.internal.ctf.core.Activator;
-
+
/**
* Reads the events of a trace.
*/
@@ -339,14 +339,29 @@ public class CTFTraceReader {
long tempIndex = Long.MIN_VALUE;
long tempTimestamp = Long.MIN_VALUE;
- for (StreamInputReader streamInputReader : this.streamInputReaders) {
+ try {
+ for (StreamInputReader streamInputReader : this.streamInputReaders) {
+ /*
+ * Seek the trace reader.
+ */
+ final long streamIndex = streamInputReader.seekIndex(index);
+ tempIndex = Math.max(tempIndex, streamIndex);
+ tempTimestamp = Math.max(tempTimestamp,
+ streamInputReader.getCurrentEvent().timestamp);
+
+ }
+ } catch (CTFReaderException e) {
/*
- * Seek the trace reader.
+ * Important, if it failed, it's because it's not yet indexed,
+ * so we have to manually advance to the right value.
*/
- final long streamIndex = streamInputReader.seekIndex(index);
- tempIndex = Math.max(tempIndex, streamIndex);
- tempTimestamp = Math.max(tempTimestamp, streamInputReader.getCurrentEvent().timestamp);
-
+ for (StreamInputReader streamInputReader : this.streamInputReaders) {
+ /*
+ * Seek the trace reader.
+ */
+ streamInputReader.seek(0);
+ }
+ tempIndex = 0;
}
for (StreamInputReader streamInputReader : this.streamInputReaders) {
/*
@@ -360,8 +375,8 @@ public class CTFTraceReader {
/*
* advance for offset
*/
- while( (prio.peek().getCurrentEvent().timestamp < tempTimestamp) && hasMoreEvents() )
- {
+ while ((prio.peek().getCurrentEvent().timestamp < tempTimestamp)
+ && hasMoreEvents()) {
this.advance();
}
long pos = tempIndex;
diff --git a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/StreamInputReader.java b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/StreamInputReader.java
index 46e2fd1..4150c84 100644
--- a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/StreamInputReader.java
+++ b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/StreamInputReader.java
@@ -184,7 +184,7 @@ public class StreamInputReader {
}
- public long seekIndex(long index)
+ public long seekIndex(long index) throws CTFReaderException
{
/*
* Search in the index for the packet to search in.
@@ -201,6 +201,9 @@ public class StreamInputReader {
/*
* get the current index
*/
+ if(this.packetReader.getCurrentPacket() == null){
+ throw new CTFReaderException("Current packet null in index seek, did you index your trace yet?");
+ }
return this.packetReader.getCurrentPacket().getIndexBegin();
}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/.classpath b/lttng/org.eclipse.linuxtools.tmf.core.tests/.classpath
index 2a987e2..a2dcfc3 100644
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/.classpath
+++ b/lttng/org.eclipse.linuxtools.tmf.core.tests/.classpath
@@ -4,5 +4,6 @@
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="stubs"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/org.eclipse.linuxtools.tmf.core"/>
<classpathentry kind="output" path="bin"/>
</classpath>
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/META-INF/MANIFEST.MF b/lttng/org.eclipse.linuxtools.tmf.core.tests/META-INF/MANIFEST.MF
index 31c3c81..f09ae57 100644
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/META-INF/MANIFEST.MF
+++ b/lttng/org.eclipse.linuxtools.tmf.core.tests/META-INF/MANIFEST.MF
@@ -11,5 +11,6 @@ Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Require-Bundle: org.junit;bundle-version="3.8.2",
org.eclipse.core.runtime;bundle-version="3.7.0",
org.eclipse.core.resources;bundle-version="3.7.100",
- org.eclipse.linuxtools.tmf.core;bundle-version="0.4.0"
+ org.eclipse.linuxtools.tmf.core;bundle-version="0.4.0",
+ org.eclipse.linuxtools.ctf.core;bundle-version="0.1.0"
Export-Package: org.eclipse.linuxtools.tmf.tests.stubs.trace;x-friends:="org.eclipse.linuxtools.tmf.ui.tests"
diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfIterator.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfIterator.java
index d37a3ef..64a5125 100644
--- a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfIterator.java
+++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfIterator.java
@@ -31,8 +31,8 @@ public class CtfIterator extends CTFTraceReader implements ITmfContext,
public CtfIterator(CtfTmfTrace trace, long timestampValue, long rank) {
super(trace.getCTFTrace());
this.ctfTmfTrace = trace;
- this.curLocation = (new CtfLocation(
- this.getCurrentEvent().getTimestampValue()));
+ this.curLocation = (new CtfLocation(this.getCurrentEvent()
+ .getTimestampValue()));
if (this.getCurrentEvent().getTimestampValue() != timestampValue) {
this.seek(timestampValue);
}
@@ -85,7 +85,7 @@ public class CtfIterator extends CTFTraceReader implements ITmfContext,
@Override
public void setRank(long rank) {
- seekRank( rank );
+ seekRank(rank);
}
/*
@@ -96,8 +96,8 @@ public class CtfIterator extends CTFTraceReader implements ITmfContext,
@Override
public CtfIterator clone() {
CtfIterator clone = null;
- clone = new CtfIterator(ctfTmfTrace,
- this.getCurrentEvent().getTimestampValue(), curRank);
+ clone = new CtfIterator(ctfTmfTrace, this.getCurrentEvent()
+ .getTimestampValue(), curRank);
return clone;
}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfTrace.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfTrace.java
index 7183885..418cc38 100644
--- a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfTrace.java
+++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfTrace.java
@@ -83,6 +83,8 @@ public class CtfTmfTrace extends TmfEventProvider<CtfTmfEvent> implements
// this.fEndTime.clone()));
}
+
+
@Override
public void indexTrace(boolean waitForCompletion) {
}
@@ -242,8 +244,8 @@ public class CtfTmfTrace extends TmfEventProvider<CtfTmfEvent> implements
@Override
public double getLocationRatio(ITmfLocation<?> location) {
CtfIterator curLocation = (CtfIterator) location;
- return ((double) curLocation.getCurrentEvent().getTimestampValue() -
- curLocation.getStartTime())
+ return ((double) curLocation.getCurrentEvent().getTimestampValue() - curLocation
+ .getStartTime())
/ (curLocation.getEndTime() - curLocation.getStartTime());
}