aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Khouzam2012-04-24 17:39:00 (EDT)
committerMatthew Khouzam2012-05-01 09:47:44 (EDT)
commit315334f0b35862e29a2e9365d9d0efc9930da117 (patch)
tree73e3204ccf2c10ce386fe0df600be17cb4e7ad92
parent28cb7000de18c8015544327683b1c1e8142df82c (diff)
downloadorg.eclipse.linuxtools-315334f0b35862e29a2e9365d9d0efc9930da117.zip
org.eclipse.linuxtools-315334f0b35862e29a2e9365d9d0efc9930da117.tar.gz
org.eclipse.linuxtools-315334f0b35862e29a2e9365d9d0efc9930da117.tar.bz2
fix empty stream bug.
Signed-off-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/types/StructDeclarationTest.java17
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/CTFTraceReader.java34
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/StreamInputReader.java15
3 files changed, 35 insertions, 31 deletions
diff --git a/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/types/StructDeclarationTest.java b/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/types/StructDeclarationTest.java
index adaead4..d7c376b 100644
--- a/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/types/StructDeclarationTest.java
+++ b/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/types/StructDeclarationTest.java
@@ -18,7 +18,7 @@ import org.junit.Test;
/**
* The class <code>StructDeclarationTest</code> contains tests for the class
* <code>{@link StructDeclaration}</code>.
- *
+ *
* @author ematkho
* @version $Revision: 1.0 $
*/
@@ -28,7 +28,7 @@ public class StructDeclarationTest {
/**
* Launch the test.
- *
+ *
* @param args
* the command line arguments
*/
@@ -58,7 +58,7 @@ public class StructDeclarationTest {
@Test
public void testStructDeclaration() {
assertNotNull(fixture);
- assertEquals(1L, fixture.getMinAlign());
+ assertEquals(1L, fixture.getMaxAlign());
String regex = "^\\[declaration\\] struct\\[[0-9a-f]{1,8}\\]$"; //$NON-NLS-1$
assertTrue(fixture.toString().matches(regex));
@@ -112,7 +112,7 @@ public class StructDeclarationTest {
*/
@Test
public void testGetMinAlign() {
- long result = fixture.getMinAlign();
+ long result = fixture.getMaxAlign();
assertEquals(1L, result);
}
@@ -128,15 +128,6 @@ public class StructDeclarationTest {
}
/**
- * Run the void setMinAlign(long) method test.
- */
- @Test
- public void testSetMinAlign() {
- long minAlign = 1L;
- fixture.setMinAlign(minAlign);
- }
-
- /**
* Run the String toString() method test.
*/
@Test
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 59d80c7..da15fb7 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
@@ -352,25 +352,29 @@ public class CTFTraceReader {
* Seek the trace reader.
*/
final long streamIndex = streamInputReader.seekIndex(index);
- tempIndex = Math.max(tempIndex, streamIndex);
- EventDefinition currentEvent = streamInputReader.getCurrentEvent();
- /*
- * Maybe we're at the beginning of a trace.
- */
- if( currentEvent == null ){
- streamInputReader.readNextEvent();
- currentEvent = streamInputReader.getCurrentEvent();
- }
- if( currentEvent != null ) {
- tempTimestamp = Math.max(tempTimestamp,
- currentEvent.timestamp);
- } else {
+ if( streamIndex != -1 )
+ {
+ tempIndex = Math.max(tempIndex, streamIndex);
+ EventDefinition currentEvent = streamInputReader.getCurrentEvent();
/*
- * probably beyond the last event
+ * Maybe we're at the beginning of a trace.
*/
- tempIndex = goToZero();
+ if( currentEvent == null ){
+ streamInputReader.readNextEvent();
+ currentEvent = streamInputReader.getCurrentEvent();
+ }
+ if( currentEvent != null ) {
+ tempTimestamp = Math.max(tempTimestamp,
+ currentEvent.timestamp);
+ } else {
+ /*
+ * probably beyond the last event
+ */
+ tempIndex = goToZero();
+ }
}
+
}
} catch (CTFReaderException e) {
/*
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 4bcd872..707d073 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
@@ -198,6 +198,10 @@ public class StreamInputReader {
public long seekIndex(long index) throws CTFReaderException {
/*
+ * we need to check if a trace is empty too.
+ */
+ StreamInputPacketIndexEntry sipie = null;
+ /*
* Search in the index for the packet to search in.
*/
this.packetIndexIt = this.streamInput.getIndex().searchIndex(index);
@@ -205,6 +209,8 @@ public class StreamInputReader {
* Switch to this packet.
*/
goToNextPacket();
+
+ sipie = this.packetReader.getCurrentPacket();
/*
* Read the first packet
*/
@@ -212,9 +218,12 @@ 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?"); //$NON-NLS-1$
+ if (this.packetReader.getCurrentPacket() == null) {
+ if( !((sipie.getIndexBegin() == 0) && (sipie.getIndexEnd() == Long.MAX_VALUE))) {
+ throw new CTFReaderException(
+ "Current packet null in index seek, did you index your trace yet?"); //$NON-NLS-1$
+ }
+ return -1;
}
return this.packetReader.getCurrentPacket().getIndexBegin();