aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Christian Kouamé2013-05-17 12:04:01 (EDT)
committerAlexandre Montplaisir2013-07-04 18:44:18 (EDT)
commit3ee7910ce0a701fac4a98e486eedf2528f80c1ee (patch)
tree6dbd67b22e974709a64d844ad1ca967bce12e983
parent956cf7ff451239d9818aa290c95730f95e8df731 (diff)
downloadorg.eclipse.linuxtools-3ee7910ce0a701fac4a98e486eedf2528f80c1ee.zip
org.eclipse.linuxtools-3ee7910ce0a701fac4a98e486eedf2528f80c1ee.tar.gz
org.eclipse.linuxtools-3ee7910ce0a701fac4a98e486eedf2528f80c1ee.tar.bz2
CTF : Handle traces with events without eventIDrefs/changes/49/12949/5
Bug 387039 : First, the eventID was set to null when the event was created. We change it for -2 as default value when not set. Then, we must change the way to look for packetIndexEntry to adapt it to the particular case where there are many packetIndexEntry with the same timestamp. Change-Id: Ia3bf16cc1013e41c18b5305978d1b99c30624bdc Signed-off-by: Jean-Christian Kouame Reviewed-on: https://git.eclipse.org/r/12949 Tested-by: Hudson CI IP-Clean: Alexandre Montplaisir <alexmonthy@voxpopuli.im> Tested-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im> Reviewed-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/Stream.java10
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/StreamInputPacketReader.java2
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/event/EventDeclaration.java12
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/trace/StreamInputPacketIndex.java34
4 files changed, 44 insertions, 14 deletions
diff --git a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/Stream.java b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/Stream.java
index 774a95e..4482aec 100644
--- a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/Stream.java
+++ b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/Stream.java
@@ -19,6 +19,7 @@ import java.util.Set;
import org.eclipse.linuxtools.ctf.core.event.IEventDeclaration;
import org.eclipse.linuxtools.ctf.core.event.types.StructDeclaration;
+import org.eclipse.linuxtools.internal.ctf.core.event.EventDeclaration;
import org.eclipse.linuxtools.internal.ctf.core.event.metadata.exceptions.ParseException;
/**
@@ -243,9 +244,12 @@ public class Stream {
if (events.get(event.getId()) != null) {
throw new ParseException("Event id already exists"); //$NON-NLS-1$
}
-
- /* Put the event in the map */
- events.put(event.getId(), event);
+ if (event.getId() == null) {
+ events.put(EventDeclaration.UNSET_EVENT_ID, event);
+ } else {
+ /* Put the event in the map */
+ events.put(event.getId(), event);
+ }
}
/**
diff --git a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/StreamInputPacketReader.java b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/StreamInputPacketReader.java
index 9bd42b8..678cb02 100644
--- a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/StreamInputPacketReader.java
+++ b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/StreamInputPacketReader.java
@@ -286,7 +286,7 @@ public class StreamInputPacketReader implements IDefinitionScope {
*/
public EventDefinition readNextEvent() throws CTFReaderException {
/* Default values for those fields */
- long eventID = 0;
+ long eventID = EventDeclaration.UNSET_EVENT_ID;
long timestamp = 0;
if (lostEventsInThisPacket > lostSoFar) {
diff --git a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/event/EventDeclaration.java b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/event/EventDeclaration.java
index 26b3c75..28f5c7e 100644
--- a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/event/EventDeclaration.java
+++ b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/event/EventDeclaration.java
@@ -28,6 +28,12 @@ import org.eclipse.linuxtools.ctf.core.trace.StreamInputReader;
*/
public class EventDeclaration implements IEventDeclaration {
+ /** Id of lost events */
+ public static final long LOST_EVENT_ID = -1L;
+
+ /** Id of events when not set */
+ public static final long UNSET_EVENT_ID = -2L;
+
// ------------------------------------------------------------------------
// Attributes
// ------------------------------------------------------------------------
@@ -50,7 +56,7 @@ public class EventDeclaration implements IEventDeclaration {
/**
* Event id (can be null if only event in the stream).
*/
- private Long id = null;
+ private Long id = UNSET_EVENT_ID;
/**
* Stream to which belongs this event.
@@ -100,7 +106,7 @@ public class EventDeclaration implements IEventDeclaration {
public static synchronized EventDeclaration getLostEventDeclaration() {
EventDeclaration lostEvent = new EventDeclaration();
lostEvent.fields = new StructDeclaration(1);
- lostEvent.id = -1L;
+ lostEvent.id = LOST_EVENT_ID;
lostEvent.name = "Lost event"; //$NON-NLS-1$
return lostEvent;
}
@@ -218,7 +224,7 @@ public class EventDeclaration implements IEventDeclaration {
* @return is the id set?
*/
public boolean idIsSet() {
- return id != null;
+ return (id != null && id != UNSET_EVENT_ID);
}
/**
diff --git a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/trace/StreamInputPacketIndex.java b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/trace/StreamInputPacketIndex.java
index 14366d4..ef74805 100644
--- a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/trace/StreamInputPacketIndex.java
+++ b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/trace/StreamInputPacketIndex.java
@@ -40,6 +40,7 @@ public class StreamInputPacketIndex {
/**
* Gets the entries
+ *
* @return the entries
*/
public Vector<StreamInputPacketIndexEntry> getEntries() {
@@ -48,6 +49,7 @@ public class StreamInputPacketIndex {
/**
* Gets an iterator to the entries
+ *
* @return an iterator to the entries
*/
public ListIterator<StreamInputPacketIndexEntry> listIterator() {
@@ -56,7 +58,9 @@ public class StreamInputPacketIndex {
/**
* Gets an iterator to the entries at a given position
- * @param n the position to get
+ *
+ * @param n
+ * the position to get
* @return the iterator
*/
public ListIterator<StreamInputPacketIndexEntry> listIterator(int n) {
@@ -81,15 +85,13 @@ public class StreamInputPacketIndex {
assert (entry.getContentSizeBits() != 0);
if (entry.getTimestampBegin() > entry.getTimestampEnd()) {
- throw new CTFReaderException(
- "Packet begin timestamp is after end timestamp"); //$NON-NLS-1$
+ throw new CTFReaderException("Packet begin timestamp is after end timestamp"); //$NON-NLS-1$
}
if (!this.entries.isEmpty()) {
if (entry.getTimestampBegin() < this.entries.lastElement()
.getTimestampBegin()) {
- throw new CTFReaderException(
- "Packets begin timestamp decreasing"); //$NON-NLS-1$
+ throw new CTFReaderException("Packets begin timestamp decreasing"); //$NON-NLS-1$
}
}
@@ -119,7 +121,7 @@ public class StreamInputPacketIndex {
/*
* If the index is empty, return the iterator at the very beginning.
*/
- if( this.getEntries().isEmpty()) {
+ if (this.getEntries().isEmpty()) {
return this.getEntries().listIterator();
}
@@ -151,12 +153,30 @@ public class StreamInputPacketIndex {
* the packet to return is before the guess.
*/
max = guessI - 1;
- } else if (timestamp >= guessEntry.getTimestampBegin()) {
+ } else if (timestamp > guessEntry.getTimestampBegin()) {
/*
* If the timestamp is after the begin timestamp, we know that
* the packet to return is after the guess or is the guess.
*/
min = guessI;
+ } else if (timestamp == guessEntry.getTimestampBegin()) {
+ /*
+ * If the timestamp is equal to the begin timestamp, we want to
+ * return the first packetIndexEntry that have this timestamp.
+ */
+ if (guessI > 0) {
+ StreamInputPacketIndexEntry previousGuessEntry = this.entries.get(guessI - 1);
+ while (guessI > 0 && guessEntry.getTimestampBegin() == previousGuessEntry.getTimestampBegin()) {
+ guessEntry = previousGuessEntry;
+ guessI--;
+ if (guessI - 1 >= 0) {
+ previousGuessEntry = this.entries.get(guessI - 1);
+ }
+ }
+ min = guessI;
+ max = guessI;
+ }
+
}
}