import org.eclipse.test.performance.Performance;
import org.eclipse.test.performance.PerformanceMeter;
import org.eclipse.tracecompass.ctf.core.CTFException;
-import org.eclipse.tracecompass.ctf.core.event.EventDefinition;
+import org.eclipse.tracecompass.ctf.core.event.IEventDefinition;
import org.eclipse.tracecompass.ctf.core.tests.shared.CtfTestTraceUtils;
import org.eclipse.tracecompass.ctf.core.trace.CTFTrace;
import org.eclipse.tracecompass.ctf.core.trace.CTFTraceReader;
try (CTFTraceReader traceReader = new CTFTraceReader(trace);) {
while (traceReader.hasMoreEvents()) {
- EventDefinition ed = traceReader.getCurrentEventDef();
+ IEventDefinition ed = traceReader.getCurrentEventDef();
/* Do something with the event */
ed.getCPU();
traceReader.advance();
import org.eclipse.test.performance.Performance;
import org.eclipse.test.performance.PerformanceMeter;
import org.eclipse.tracecompass.ctf.core.CTFException;
-import org.eclipse.tracecompass.ctf.core.event.EventDefinition;
+import org.eclipse.tracecompass.ctf.core.event.IEventDefinition;
import org.eclipse.tracecompass.ctf.core.tests.shared.CtfTestTraceUtils;
import org.eclipse.tracecompass.ctf.core.trace.CTFTrace;
import org.eclipse.tracecompass.ctf.core.trace.CTFTraceReader;
try (CTFTraceReader traceReader = new CTFTraceReader(trace);) {
/* Read the whole trace to find out the start and end times */
- EventDefinition firstEvent = traceReader.getCurrentEventDef();
+ IEventDefinition firstEvent = traceReader.getCurrentEventDef();
final long startTime = firstEvent.getTimestamp();
long endTime = startTime;
while (traceReader.hasMoreEvents()) {
- EventDefinition ev = traceReader.getCurrentEventDef();
+ IEventDefinition ev = traceReader.getCurrentEventDef();
endTime = ev.getTimestamp();
traceReader.advance();
}
import java.util.ArrayList;
import java.util.List;
-import org.eclipse.tracecompass.ctf.core.event.EventDefinition;
+import org.eclipse.tracecompass.ctf.core.event.IEventDefinition;
import org.eclipse.tracecompass.ctf.core.event.scope.ILexicalScope;
import org.eclipse.tracecompass.ctf.core.event.types.Definition;
import org.eclipse.tracecompass.ctf.core.event.types.Encoding;
import org.eclipse.tracecompass.ctf.core.event.types.StructDeclaration;
import org.eclipse.tracecompass.ctf.core.event.types.StructDefinition;
import org.eclipse.tracecompass.internal.ctf.core.event.EventDeclaration;
+import org.eclipse.tracecompass.internal.ctf.core.event.EventDefinition;
import org.junit.Before;
import org.junit.Test;
StructDefinition pContext = new StructDefinition(pContextDec, null, ILexicalScope.FIELDS.getPath(), new Definition[0]);
StructDefinition fields = new StructDefinition(fDec, null, ILexicalScope.FIELDS.getPath(), fDefs);
- int cpu = EventDefinition.UNKNOWN_CPU;
+ int cpu = IEventDefinition.UNKNOWN_CPU;
fixture.add(new EventDefinition(eventDeclaration, cpu, 100, null, null, null, null, null, null));
fixture.add(new EventDefinition(eventDeclaration, cpu, 100, null, null, null, null, fields, null));
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.tracecompass.ctf.core.CTFException;
import org.eclipse.tracecompass.ctf.core.CTFStrings;
-import org.eclipse.tracecompass.ctf.core.event.EventDefinition;
import org.eclipse.tracecompass.ctf.core.event.IEventDeclaration;
import org.eclipse.tracecompass.ctf.core.event.io.BitBuffer;
import org.eclipse.tracecompass.ctf.core.event.scope.ILexicalScope;
import org.eclipse.tracecompass.ctf.core.trace.CTFTrace;
import org.eclipse.tracecompass.ctf.core.trace.ICTFPacketDescriptor;
import org.eclipse.tracecompass.internal.ctf.core.event.EventDeclaration;
+import org.eclipse.tracecompass.internal.ctf.core.event.EventDefinition;
import org.eclipse.tracecompass.internal.ctf.core.trace.CTFPacketReader;
import org.eclipse.tracecompass.internal.ctf.core.trace.StreamInputPacketIndexEntry;
import org.junit.Test;
import java.util.Set;
import org.eclipse.tracecompass.ctf.core.CTFException;
-import org.eclipse.tracecompass.ctf.core.event.EventDefinition;
+import org.eclipse.tracecompass.ctf.core.event.IEventDefinition;
import org.eclipse.tracecompass.ctf.core.event.types.Definition;
import org.eclipse.tracecompass.ctf.core.event.types.Encoding;
import org.eclipse.tracecompass.ctf.core.event.types.ICompositeDefinition;
import org.eclipse.tracecompass.ctf.core.trace.CTFTrace;
import org.eclipse.tracecompass.ctf.core.trace.ICTFStream;
import org.eclipse.tracecompass.internal.ctf.core.event.EventDeclaration;
+import org.eclipse.tracecompass.internal.ctf.core.event.EventDefinition;
import org.eclipse.tracecompass.internal.ctf.core.trace.CTFStream;
import org.eclipse.tracecompass.testtraces.ctf.CtfTestTrace;
import org.junit.Before;
* The class <code>StreamInputReaderTest</code> contains tests for the class
* <code>{@link CTFStreamInputReader}</code>.
*
- * @author ematkho
- * @version $Revision: 1.0 $
+ * @author Matthew Khouzam
*/
@SuppressWarnings("javadoc")
public class CTFStreamInputReaderTest {
*/
@Test
public void testGetCurrentEvent() {
- EventDefinition result = fixture.getCurrentEvent();
- assertNotNull(result);
+ assertNotNull(fixture.getCurrentEvent());
}
/**
*/
@Test
public void testGetCurrentPacketContext() {
- EventDefinition currentEvent = fixture.getCurrentEvent();
+ IEventDefinition currentEvent = fixture.getCurrentEvent();
assertNotNull(currentEvent);
ICompositeDefinition result = currentEvent.getPacketContext();
assertNotNull(result);
public void testGoToLastEvent2() throws CTFException {
long timestamp = -1;
while (fixture.readNextEvent().equals(CTFResponse.OK)) {
- EventDefinition currentEvent = fixture.getCurrentEvent();
+ IEventDefinition currentEvent = fixture.getCurrentEvent();
assertNotNull(currentEvent);
timestamp = currentEvent.getTimestamp();
}
private long goToEnd() throws CTFException {
fixture.goToLastEvent();
- EventDefinition currentEvent = fixture.getCurrentEvent();
+ IEventDefinition currentEvent = fixture.getCurrentEvent();
assertNotNull(currentEvent);
return currentEvent.getTimestamp();
}
import java.io.InputStreamReader;
import org.eclipse.tracecompass.ctf.core.CTFException;
-import org.eclipse.tracecompass.ctf.core.event.EventDefinition;
+import org.eclipse.tracecompass.ctf.core.event.IEventDefinition;
import org.eclipse.tracecompass.ctf.core.tests.shared.LttngKernelTraceGenerator;
import org.eclipse.tracecompass.ctf.core.trace.CTFTrace;
import org.eclipse.tracecompass.ctf.core.trace.CTFTraceReader;
fixture.addStreamFile(stream);
reader.update();
assertTrue(reader.advance());
- EventDefinition currentEventDef = reader.getCurrentEventDef();
+ IEventDefinition currentEventDef = reader.getCurrentEventDef();
assertNotNull(reader.getCurrentEventDef());
assertEquals(16518l, currentEventDef.getTimestamp());
}
fixture.addStreamFile(stream);
reader.update();
assertTrue(reader.advance());
- EventDefinition currentEventDef = reader.getCurrentEventDef();
+ IEventDefinition currentEventDef = reader.getCurrentEventDef();
assertNotNull(currentEventDef);
assertEquals(223007L, currentEventDef.getTimestamp());
}
reader.update();
reader.update();
assertTrue(reader.advance());
- EventDefinition currentEventDef = reader.getCurrentEventDef();
+ IEventDefinition currentEventDef = reader.getCurrentEventDef();
assertNotNull(currentEventDef);
assertEquals(223007L, currentEventDef.getTimestamp());
}
import static org.junit.Assert.assertTrue;
import org.eclipse.tracecompass.ctf.core.CTFException;
-import org.eclipse.tracecompass.ctf.core.event.EventDefinition;
+import org.eclipse.tracecompass.ctf.core.event.IEventDefinition;
import org.eclipse.tracecompass.ctf.core.tests.shared.CtfTestTraceUtils;
import org.eclipse.tracecompass.ctf.core.trace.CTFTrace;
import org.eclipse.tracecompass.ctf.core.trace.CTFTraceReader;
*/
@Test
public void testGetCurrentEventDef_first() {
- EventDefinition result = fixture.getCurrentEventDef();
+ IEventDefinition result = fixture.getCurrentEventDef();
assertNotNull(result);
}
@Test
public void testGetCurrentEventDef_last() throws CTFException {
fixture.goToLastEvent();
- EventDefinition result = fixture.getCurrentEventDef();
+ IEventDefinition result = fixture.getCurrentEventDef();
assertNotNull(result);
}
import org.eclipse.core.runtime.URIUtil;
import org.eclipse.tracecompass.ctf.core.CTFException;
-import org.eclipse.tracecompass.ctf.core.event.EventDefinition;
+import org.eclipse.tracecompass.ctf.core.event.IEventDefinition;
import org.eclipse.tracecompass.ctf.core.tests.shared.CtfTestTraceUtils;
import org.eclipse.tracecompass.ctf.core.trace.CTFTrace;
import org.eclipse.tracecompass.ctf.core.trace.CTFTraceReader;
try (CTFTraceReader reader = new CTFTraceReader(outTrace)) {
while(reader.hasMoreEvents()) {
count++;
- EventDefinition def = reader.getCurrentEventDef();
+ IEventDefinition def = reader.getCurrentEventDef();
end = def.getTimestamp();
if (start == null) {
start = outTrace.getClock().getClockOffset() + reader.getStartTime();
import org.eclipse.tracecompass.ctf.core.CTFException;
import org.eclipse.tracecompass.ctf.core.CTFStrings;
-import org.eclipse.tracecompass.ctf.core.event.EventDefinition;
+import org.eclipse.tracecompass.ctf.core.event.IEventDefinition;
import org.eclipse.tracecompass.ctf.core.event.types.IntegerDefinition;
import org.eclipse.tracecompass.ctf.core.tests.shared.CtfTestTraceUtils;
import org.eclipse.tracecompass.ctf.core.trace.CTFTraceReader;
public void readTraces() {
if (fTraceEnum.getNbEvents() != -1) {
try (CTFTraceReader reader = new CTFTraceReader(CtfTestTraceUtils.getTrace(fTraceEnum))) {
- EventDefinition currentEventDef = reader.getCurrentEventDef();
+ IEventDefinition currentEventDef = reader.getCurrentEventDef();
double start = currentEventDef.getTimestamp();
long count = 0;
double end = start;
import static org.junit.Assert.assertTrue;
import org.eclipse.tracecompass.ctf.core.CTFException;
-import org.eclipse.tracecompass.ctf.core.event.EventDefinition;
import org.eclipse.tracecompass.ctf.core.event.IEventDeclaration;
-import org.eclipse.tracecompass.ctf.core.event.LostEventDeclaration;
+import org.eclipse.tracecompass.ctf.core.event.IEventDefinition;
+import org.eclipse.tracecompass.ctf.core.event.scope.IDefinitionScope;
import org.eclipse.tracecompass.ctf.core.event.types.StructDeclaration;
import org.eclipse.tracecompass.ctf.core.tests.shared.CtfTestTraceUtils;
import org.eclipse.tracecompass.ctf.core.trace.CTFTrace;
import org.eclipse.tracecompass.ctf.core.trace.CTFTraceReader;
import org.eclipse.tracecompass.internal.ctf.core.event.EventDeclaration;
+import org.eclipse.tracecompass.internal.ctf.core.event.LostEventDeclaration;
import org.eclipse.tracecompass.internal.ctf.core.trace.CTFStream;
import org.eclipse.tracecompass.testtraces.ctf.CtfTestTrace;
import org.junit.Before;
@Test
public void testEventDefinition() throws CTFException {
CTFTrace trace = CtfTestTraceUtils.getTrace(testTrace);
- EventDefinition ed = null;
+ IEventDefinition ed = null;
try (CTFTraceReader tr = new CTFTraceReader(trace);) {
tr.advance();
ed = tr.getCurrentEventDef();
}
-
+ assertTrue(ed instanceof IDefinitionScope);
+ IDefinitionScope ds = (IDefinitionScope)ed;
assertNotNull(ed);
- assertNotNull(ed.getScopePath());
+ assertNotNull(ds.getScopePath());
assertNotNull(ed.getDeclaration());
assertNotNull(ed.getFields());
assertNull(ed.getContext());
assertNotNull(ed.getPacketContext());
assertNotNull(ed.getCPU());
- assertNull(ed.lookupDefinition("context"));
- assertNotNull(ed.lookupDefinition("fields"));
- assertNull(ed.lookupDefinition("other"));
+ assertNull(ds.lookupDefinition("context"));
+ assertNotNull(ds.lookupDefinition("fields"));
+ assertNull(ds.lookupDefinition("other"));
assertNotNull(ed.toString());
}
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2011-2014 Ericsson, Ecole Polytechnique de Montreal and others
- *
- * All rights reserved. This program and the accompanying materials are made
- * available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Matthew Khouzam - Initial API and implementation
- * Contributors: Simon Marchi - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.tracecompass.ctf.core.event;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.jdt.annotation.Nullable;
-import org.eclipse.tracecompass.ctf.core.event.scope.IDefinitionScope;
-import org.eclipse.tracecompass.ctf.core.event.scope.ILexicalScope;
-import org.eclipse.tracecompass.ctf.core.event.scope.LexicalScope;
-import org.eclipse.tracecompass.ctf.core.event.types.Definition;
-import org.eclipse.tracecompass.ctf.core.event.types.ICompositeDefinition;
-import org.eclipse.tracecompass.ctf.core.event.types.IDefinition;
-import org.eclipse.tracecompass.ctf.core.event.types.StructDeclaration;
-import org.eclipse.tracecompass.ctf.core.event.types.StructDefinition;
-import org.eclipse.tracecompass.ctf.core.trace.ICTFPacketDescriptor;
-import org.eclipse.tracecompass.internal.ctf.core.event.EventDeclaration;
-
-/**
- * Representation of a particular instance of an event.
- */
-public final class EventDefinition implements IDefinitionScope {
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
-
- /**
- * Value representing an unknown cpu number.
- *
- * @since 2.0
- */
- public static final int UNKNOWN_CPU = -1;
-
- /**
- * A null event, can be used for testing or poison pilling
- */
- public static final @NonNull EventDefinition NULL_EVENT = new EventDefinition(new EventDeclaration(), UNKNOWN_CPU, -1L, null, null, null, null, null, null);
-
- /**
- * The corresponding event declaration.
- */
- private final IEventDeclaration fDeclaration;
-
- /**
- * The timestamp of the current event.
- */
- private final long fTimestamp;
-
- private final ICompositeDefinition fEventHeaderDefinition;
-
- /**
- * The event context structure definition.
- */
- private final ICompositeDefinition fEventContext;
-
- private final ICompositeDefinition fStreamContext;
-
- private final ICompositeDefinition fPacketContext;
-
- /**
- * The event fields structure definition.
- */
- private final ICompositeDefinition fFields;
-
- /**
- * The current cpu, could be @link {@link IPacketHeader#UNKNOWN_CPU}
- */
- private final int fCpu;
-
- private final @NonNull Map<String, Object> fPacketAttributes;
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
-
- /**
- * Constructs an event definition.
- *
- * @param declaration
- * The corresponding event declaration
- * @param cpu
- * The cpu source of the event. You can use UNKNOWN_CPU if it is
- * not known.
- * @param timestamp
- * event timestamp
- * @param eventHeaderDefinition
- * The event header definition, can be null if there is no header
- * definition
- * @param eventContext
- * The event context
- * @param packetContext
- * the packet context (the one with content size, not magic
- * number)
- * @param streamContext
- * the stream context
- * @param fields
- * The event fields
- * @param packetDescriptor
- * descriptor of the packet containing this event
- * @since 2.0
- */
- public EventDefinition(IEventDeclaration declaration,
- int cpu,
- long timestamp,
- ICompositeDefinition eventHeaderDefinition,
- ICompositeDefinition streamContext,
- ICompositeDefinition eventContext,
- ICompositeDefinition packetContext,
- ICompositeDefinition fields,
- @Nullable ICTFPacketDescriptor packetDescriptor) {
- fDeclaration = declaration;
- fEventHeaderDefinition = eventHeaderDefinition;
- fCpu = cpu;
- fTimestamp = timestamp;
- fFields = fields;
- fEventContext = eventContext;
- fPacketContext = packetContext;
- fStreamContext = streamContext;
- fPacketAttributes = packetDescriptor != null ? packetDescriptor.getAttributes() : Collections.EMPTY_MAP;
- }
-
- // ------------------------------------------------------------------------
- // Getters/Setters/Predicates
- // ------------------------------------------------------------------------
-
- /**
- * @since 1.0
- */
- @Override
- public ILexicalScope getScopePath() {
- String eventName = fDeclaration.getName();
- if (eventName == null) {
- return null;
- }
- ILexicalScope myScope = ILexicalScope.EVENT.getChild(eventName);
- if (myScope == null) {
- myScope = new LexicalScope(ILexicalScope.EVENT, eventName);
- }
- return myScope;
- }
-
- /**
- * Gets the declaration (the form) of the data
- *
- * @return the event declaration
- */
- public IEventDeclaration getDeclaration() {
- return fDeclaration;
- }
-
- /**
- * Get the event header
- *
- * @return the event header
- * @since 1.1
- */
- public ICompositeDefinition getEventHeader() {
- return fEventHeaderDefinition;
- }
-
- /**
- * Gets the fields of a definition
- *
- * @return the fields of a definition in struct form. Can be null.
- * @since 1.0
- */
- public ICompositeDefinition getFields() {
- return fFields;
- }
-
- /**
- * Gets the context of this event without the context of the stream
- *
- * @return the context in struct form
- * @since 1.0
- */
- public ICompositeDefinition getEventContext() {
- return fEventContext;
- }
-
- /**
- * Gets the context of this event within a stream
- *
- * @return the context in struct form
- * @since 1.0
- */
- public ICompositeDefinition getContext() {
-
- /* Most common case so far */
- if (fStreamContext == null) {
- return fEventContext;
- }
-
- /* streamContext is not null, but the context of the event is null */
- if (fEventContext == null) {
- return fStreamContext;
- }
-
- // TODO: cache if this is a performance issue
-
- /* The stream context and event context are assigned. */
- StructDeclaration mergedDeclaration = new StructDeclaration(1);
-
- List<Definition> fieldValues = new ArrayList<>();
-
- /* Add fields from the stream */
- List<@NonNull String> fieldNames = fStreamContext.getFieldNames();
- for (String fieldName : fieldNames) {
- Definition definition = fStreamContext.getDefinition(fieldName);
- mergedDeclaration.addField(fieldName, definition.getDeclaration());
- fieldValues.add(definition);
- }
-
- /*
- * Add fields from the event context, overwrite the stream ones if
- * needed.
- */
- for (String fieldName : fEventContext.getFieldNames()) {
- Definition definition = fEventContext.getDefinition(fieldName);
- mergedDeclaration.addField(fieldName, definition.getDeclaration());
- if (fieldNames.contains(fieldName)) {
- fieldValues.set((fieldNames.indexOf(fieldName)), definition);
- } else {
- fieldValues.add(definition);
- }
- }
- return new StructDefinition(mergedDeclaration, this, "context", //$NON-NLS-1$
- fieldValues.toArray(new Definition[fieldValues.size()]));
- }
-
- /**
- * Gets the context of packet the event is in.
- *
- * @return the packet context
- * @since 1.0
- */
- public ICompositeDefinition getPacketContext() {
- return fPacketContext;
- }
-
- /**
- * gets the CPU the event was generated by. Slightly LTTng specific
- *
- * @return The CPU the event was generated by
- */
- public int getCPU() {
- return fCpu;
- }
-
- /**
- * @return the timestamp
- */
- public long getTimestamp() {
- return fTimestamp;
- }
-
- /**
- * Get the packet attributes.
- *
- * @return the packet attributes, such as "device" and "timestamp_begin"
- * @since 2.0
- */
- public @NonNull Map<String, Object> getPacketAttributes() {
- return fPacketAttributes;
- }
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
-
- /**
- * @since 1.0
- */
- @Override
- public IDefinition lookupDefinition(String lookupPath) {
- if (lookupPath.equals("context")) { //$NON-NLS-1$
- return fEventContext;
- } else if (lookupPath.equals("fields")) { //$NON-NLS-1$
- return fFields;
- } else {
- return null;
- }
- }
-
- @Override
- public String toString() {
- Iterable<String> list;
- StringBuilder retString = new StringBuilder();
- final String cr = System.getProperty("line.separator");//$NON-NLS-1$
-
- retString.append("Event type: ").append(fDeclaration.getName()).append(cr); //$NON-NLS-1$
- retString.append("Timestamp: ").append(Long.toString(fTimestamp)).append(cr); //$NON-NLS-1$
-
- if (fEventContext != null) {
- list = fEventContext.getFieldNames();
-
- for (String field : list) {
- retString.append(field).append(" : ").append(fEventContext.getDefinition(field).toString()).append(cr); //$NON-NLS-1$
- }
- }
-
- if (fFields != null) {
- list = fFields.getFieldNames();
-
- for (String field : list) {
- retString.append(field).append(" : ").append(fFields.getDefinition(field).toString()).append(cr); //$NON-NLS-1$
- }
- }
-
- return retString.toString();
- }
-
-}
public static final long UNSET_EVENT_ID = -2L;
/**
- * Creates an instance of EventDefinition corresponding to this declaration.
+ * Creates an instance of {@link IEventDefinition} corresponding to this
+ * declaration.
*
* @param streamInputReader
- * The StreamInputReader for which this definition is created.
+ * The {@link CTFStreamInputReader} for which this definition is
+ * created.
* @param input
- * the bitbuffer input source
+ * the {@link BitBuffer} input source
* @param timestamp
* The timestamp when the event was taken
- * @return A new EventDefinition.
+ * @return A new {@link IEventDefinition}
* @throws CTFException
* As a bitbuffer is used to read, it could have wrapped
* IOExceptions.
+ * @since 2.0
*/
- EventDefinition createDefinition(CTFStreamInputReader streamInputReader, @NonNull BitBuffer input, long timestamp) throws CTFException;
+ IEventDefinition createDefinition(CTFStreamInputReader streamInputReader, @NonNull BitBuffer input, long timestamp) throws CTFException;
/**
* Gets the name of an event declaration
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2016 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are made
+ * available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.ctf.core.event;
+
+import java.util.Map;
+
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.tracecompass.ctf.core.event.types.ICompositeDefinition;
+
+/**
+ * IEventDefinition, an interface for representing individual events.
+ *
+ * @author Matthew Khouzam
+ * @since 2.0
+ */
+public interface IEventDefinition {
+
+ /**
+ * Value representing an unknown cpu number.
+ */
+ int UNKNOWN_CPU = -1;
+
+ /**
+ * Gets the declaration (the form) of the data
+ *
+ * @return the event declaration
+ */
+ IEventDeclaration getDeclaration();
+
+ /**
+ * Get the event header
+ *
+ * @return the event header
+ */
+ ICompositeDefinition getEventHeader();
+
+ /**
+ * Gets the fields of a definition
+ *
+ * @return the fields of a definition in struct form. Can be null.
+ */
+ ICompositeDefinition getFields();
+
+ /**
+ * Gets the context of this event without the context of the stream
+ *
+ * @return the context in struct form
+ */
+ ICompositeDefinition getEventContext();
+
+ /**
+ * Gets the context of this event within a stream
+ *
+ * @return the context in struct form
+ */
+ ICompositeDefinition getContext();
+
+ /**
+ * Gets the context of packet the event is in.
+ *
+ * @return the packet context
+ */
+ ICompositeDefinition getPacketContext();
+
+ /**
+ * gets the CPU the event was generated by. Slightly LTTng specific
+ *
+ * @return The CPU the event was generated by
+ */
+ int getCPU();
+
+ /**
+ * Get the timestamp, it is offsetted
+ *
+ * @return the timestamp
+ */
+ long getTimestamp();
+
+ /**
+ * Get the packet attributes.
+ *
+ * @return the packet attributes, such as "device" and "timestamp_begin"
+ */
+ @NonNull Map<@NonNull String, @NonNull Object> getPacketAttributes();
+
+}
\ No newline at end of file
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2015 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are made
- * available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Matthew Khouzam - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.tracecompass.ctf.core.event;
-
-import java.util.Collections;
-import java.util.Set;
-
-import org.eclipse.tracecompass.ctf.core.CTFException;
-import org.eclipse.tracecompass.ctf.core.CTFStrings;
-import org.eclipse.tracecompass.ctf.core.event.io.BitBuffer;
-import org.eclipse.tracecompass.ctf.core.event.types.IntegerDeclaration;
-import org.eclipse.tracecompass.ctf.core.event.types.StructDeclaration;
-import org.eclipse.tracecompass.ctf.core.trace.CTFStreamInputReader;
-import org.eclipse.tracecompass.ctf.core.trace.ICTFStream;
-
-/**
- * A lost event definition
- *
- * @author Matthew Khouzam
- * @since 1.0
- */
-public class LostEventDeclaration implements IEventDeclaration {
-
- /**
- * Id of lost events
- *
- * @since 1.0
- */
- public static final long LOST_EVENT_ID = -1L;
-
- /**
- * Gets a "lost" event. This is a synthetic event that is there to show that
- * there should be something there.
- */
- public static final LostEventDeclaration INSTANCE = new LostEventDeclaration();
-
- private final StructDeclaration fFields = new StructDeclaration(0);
-
- private LostEventDeclaration() {
- getFields().addField(CTFStrings.LOST_EVENTS_FIELD, IntegerDeclaration.UINT_32B_DECL);
- getFields().addField(CTFStrings.LOST_EVENTS_DURATION, IntegerDeclaration.UINT_64B_DECL);
- }
-
- @Override
- public EventDefinition createDefinition(CTFStreamInputReader streamInputReader, BitBuffer input, long timestamp) throws CTFException {
- return null;
- }
-
- @Override
- public String getName() {
- return CTFStrings.LOST_EVENT_NAME;
- }
-
- @Override
- public StructDeclaration getFields() {
- return fFields;
- }
-
- @Override
- public StructDeclaration getContext() {
- return null;
- }
-
- @Override
- public Long getId() {
- return LOST_EVENT_ID;
- }
-
- /**
- * @since 2.0
- */
- @Override
- public ICTFStream getStream() {
- return null;
- }
-
- @Override
- public long getLogLevel() {
- return 0;
- }
-
- @Override
- public Set<String> getCustomAttributes() {
- return Collections.<String> emptySet();
- }
-
- @Override
- public String getCustomAttribute(String key) {
- return null;
- }
-
-}
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.tracecompass.common.core.NonNullUtils;
import org.eclipse.tracecompass.ctf.core.CTFException;
-import org.eclipse.tracecompass.ctf.core.event.EventDefinition;
import org.eclipse.tracecompass.ctf.core.event.IEventDeclaration;
+import org.eclipse.tracecompass.ctf.core.event.IEventDefinition;
import org.eclipse.tracecompass.ctf.core.event.io.BitBuffer;
import org.eclipse.tracecompass.ctf.core.event.types.IDeclaration;
import org.eclipse.tracecompass.ctf.core.event.types.StructDeclaration;
* Reference to the current event of this trace file (iow, the last on that
* was read, the next one to be returned)
*/
- private @Nullable EventDefinition fCurrentEvent = null;
+ private @Nullable IEventDefinition fCurrentEvent = null;
private int fId;
*
* @return the current event in the stream, null if the stream is
* finished/empty/malformed
+ * @since 2.0
*/
- public @Nullable EventDefinition getCurrentEvent() {
+ public @Nullable IEventDefinition getCurrentEvent() {
return fCurrentEvent;
}
* timestamp.
*/
readNextEvent();
- EventDefinition currentEvent = getCurrentEvent();
+ IEventDefinition currentEvent = getCurrentEvent();
while (currentEvent != null && (currentEvent.getTimestamp() < timestamp)) {
readNextEvent();
currentEvent = getCurrentEvent();
/*
* Go until the end of that packet
*/
- EventDefinition prevEvent = null;
+ IEventDefinition prevEvent = null;
while (fCurrentEvent != null) {
prevEvent = fCurrentEvent;
- this.readNextEvent();
+ readNextEvent();
}
/*
* Go back to the previous event
*/
- this.setCurrentEvent(prevEvent);
+ setCurrentEvent(prevEvent);
}
/**
*
* @param currentEvent
* the event to set
+ * @since 2.0
*/
- public void setCurrentEvent(@Nullable EventDefinition currentEvent) {
+ public void setCurrentEvent(@Nullable IEventDefinition currentEvent) {
fCurrentEvent = currentEvent;
}
import java.util.Set;
import org.eclipse.tracecompass.ctf.core.CTFException;
-import org.eclipse.tracecompass.ctf.core.event.EventDefinition;
import org.eclipse.tracecompass.ctf.core.event.IEventDeclaration;
+import org.eclipse.tracecompass.ctf.core.event.IEventDefinition;
import org.eclipse.tracecompass.internal.ctf.core.Activator;
import org.eclipse.tracecompass.internal.ctf.core.trace.StreamInputReaderTimestampComparator;
*
* @return An event definition, or null of the trace reader reached the end
* of the trace.
+ * @since 2.0
*/
- public EventDefinition getCurrentEventDef() {
+ public IEventDefinition getCurrentEventDef() {
CTFStreamInputReader top = getTopStream();
return (top != null) ? top.getCurrentEvent() : null;
}
* We're in OK, there's a guaranteed top#getCurrentEvent() unless another
* thread does something bad.
*/
- EventDefinition currentEvent = checkNotNull(top.getCurrentEvent());
+ IEventDefinition currentEvent = checkNotNull(top.getCurrentEvent());
final long topEnd = fTrace.timestampCyclesToNanos(currentEvent.getTimestamp());
setEndTime(Math.max(topEnd, getEndTime()));
fEventCountPerTraceFile[top.getName()]++;
package org.eclipse.tracecompass.ctf.core.trace;
import org.eclipse.tracecompass.ctf.core.CTFException;
-import org.eclipse.tracecompass.ctf.core.event.EventDefinition;
+import org.eclipse.tracecompass.ctf.core.event.IEventDefinition;
import org.eclipse.tracecompass.ctf.core.event.types.ICompositeDefinition;
/**
* @throws CTFException
* If there was a problem reading the trace
*/
- EventDefinition readNextEvent() throws CTFException;
+ IEventDefinition readNextEvent() throws CTFException;
/**
* Get the packet being read
import org.eclipse.tracecompass.common.core.NonNullUtils;
import org.eclipse.tracecompass.ctf.core.CTFException;
import org.eclipse.tracecompass.ctf.core.CTFStrings;
-import org.eclipse.tracecompass.ctf.core.event.EventDefinition;
import org.eclipse.tracecompass.ctf.core.event.IEventDeclaration;
import org.eclipse.tracecompass.ctf.core.event.io.BitBuffer;
import org.eclipse.tracecompass.ctf.core.event.scope.ILexicalScope;
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2011-2014 Ericsson, Ecole Polytechnique de Montreal and others
+ *
+ * All rights reserved. This program and the accompanying materials are made
+ * available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: Matthew Khouzam - Initial API and implementation
+ * Contributors: Simon Marchi - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.internal.ctf.core.event;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
+import org.eclipse.tracecompass.ctf.core.event.IEventDeclaration;
+import org.eclipse.tracecompass.ctf.core.event.IEventDefinition;
+import org.eclipse.tracecompass.ctf.core.event.scope.IDefinitionScope;
+import org.eclipse.tracecompass.ctf.core.event.scope.ILexicalScope;
+import org.eclipse.tracecompass.ctf.core.event.scope.LexicalScope;
+import org.eclipse.tracecompass.ctf.core.event.types.Definition;
+import org.eclipse.tracecompass.ctf.core.event.types.ICompositeDefinition;
+import org.eclipse.tracecompass.ctf.core.event.types.IDefinition;
+import org.eclipse.tracecompass.ctf.core.event.types.StructDeclaration;
+import org.eclipse.tracecompass.ctf.core.event.types.StructDefinition;
+import org.eclipse.tracecompass.ctf.core.trace.ICTFPacketDescriptor;
+
+/**
+ * Representation of a particular instance of an event.
+ */
+public final class EventDefinition implements IDefinitionScope, IEventDefinition {
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+
+ /**
+ * The corresponding event declaration.
+ */
+ private final IEventDeclaration fDeclaration;
+
+ /**
+ * The timestamp of the current event.
+ */
+ private final long fTimestamp;
+
+ private final ICompositeDefinition fEventHeaderDefinition;
+
+ /**
+ * The event context structure definition.
+ */
+ private final ICompositeDefinition fEventContext;
+
+ private final ICompositeDefinition fStreamContext;
+
+ private final ICompositeDefinition fPacketContext;
+
+ /**
+ * The event fields structure definition.
+ */
+ private final ICompositeDefinition fFields;
+
+ /**
+ * The current cpu, could be @link {@link IPacketHeader#UNKNOWN_CPU}
+ */
+ private final int fCpu;
+
+ private final @NonNull Map<String, Object> fPacketAttributes;
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+
+ /**
+ * Constructs an event definition.
+ *
+ * @param declaration
+ * The corresponding event declaration
+ * @param cpu
+ * The cpu source of the event. You can use UNKNOWN_CPU if it is
+ * not known.
+ * @param timestamp
+ * event timestamp
+ * @param eventHeaderDefinition
+ * The event header definition, can be null if there is no header
+ * definition
+ * @param eventContext
+ * The event context
+ * @param packetContext
+ * the packet context (the one with content size, not magic
+ * number)
+ * @param streamContext
+ * the stream context
+ * @param fields
+ * The event fields
+ * @param packetDescriptor
+ * descriptor of the packet containing this event
+ * @since 2.0
+ */
+ public EventDefinition(IEventDeclaration declaration,
+ int cpu,
+ long timestamp,
+ ICompositeDefinition eventHeaderDefinition,
+ ICompositeDefinition streamContext,
+ ICompositeDefinition eventContext,
+ ICompositeDefinition packetContext,
+ ICompositeDefinition fields,
+ @Nullable ICTFPacketDescriptor packetDescriptor) {
+ fDeclaration = declaration;
+ fEventHeaderDefinition = eventHeaderDefinition;
+ fCpu = cpu;
+ fTimestamp = timestamp;
+ fFields = fields;
+ fEventContext = eventContext;
+ fPacketContext = packetContext;
+ fStreamContext = streamContext;
+ fPacketAttributes = packetDescriptor != null ? packetDescriptor.getAttributes() : Collections.EMPTY_MAP;
+ }
+
+ // ------------------------------------------------------------------------
+ // Getters/Setters/Predicates
+ // ------------------------------------------------------------------------
+
+ @Override
+ public ILexicalScope getScopePath() {
+ String eventName = fDeclaration.getName();
+ if (eventName == null) {
+ return null;
+ }
+ ILexicalScope myScope = ILexicalScope.EVENT.getChild(eventName);
+ if (myScope == null) {
+ myScope = new LexicalScope(ILexicalScope.EVENT, eventName);
+ }
+ return myScope;
+ }
+
+ @Override
+ public IEventDeclaration getDeclaration() {
+ return fDeclaration;
+ }
+
+ @Override
+ public ICompositeDefinition getEventHeader() {
+ return fEventHeaderDefinition;
+ }
+
+ @Override
+ public ICompositeDefinition getFields() {
+ return fFields;
+ }
+
+ @Override
+ public ICompositeDefinition getEventContext() {
+ return fEventContext;
+ }
+
+ @Override
+ public ICompositeDefinition getContext() {
+
+ /* Most common case so far */
+ if (fStreamContext == null) {
+ return fEventContext;
+ }
+
+ /* streamContext is not null, but the context of the event is null */
+ if (fEventContext == null) {
+ return fStreamContext;
+ }
+
+ // TODO: cache if this is a performance issue
+
+ /* The stream context and event context are assigned. */
+ StructDeclaration mergedDeclaration = new StructDeclaration(1);
+
+ List<Definition> fieldValues = new ArrayList<>();
+
+ /* Add fields from the stream */
+ List<@NonNull String> fieldNames = fStreamContext.getFieldNames();
+ for (String fieldName : fieldNames) {
+ Definition definition = fStreamContext.getDefinition(fieldName);
+ mergedDeclaration.addField(fieldName, definition.getDeclaration());
+ fieldValues.add(definition);
+ }
+
+ /*
+ * Add fields from the event context, overwrite the stream ones if
+ * needed.
+ */
+ for (String fieldName : fEventContext.getFieldNames()) {
+ Definition definition = fEventContext.getDefinition(fieldName);
+ mergedDeclaration.addField(fieldName, definition.getDeclaration());
+ if (fieldNames.contains(fieldName)) {
+ fieldValues.set((fieldNames.indexOf(fieldName)), definition);
+ } else {
+ fieldValues.add(definition);
+ }
+ }
+ return new StructDefinition(mergedDeclaration, this, "context", //$NON-NLS-1$
+ fieldValues.toArray(new Definition[fieldValues.size()]));
+ }
+
+ @Override
+ public ICompositeDefinition getPacketContext() {
+ return fPacketContext;
+ }
+
+ @Override
+ public int getCPU() {
+ return fCpu;
+ }
+
+ @Override
+ public long getTimestamp() {
+ return fTimestamp;
+ }
+
+ @Override
+ public Map<String, Object> getPacketAttributes() {
+ return fPacketAttributes;
+ }
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+
+ @Override
+ public IDefinition lookupDefinition(String lookupPath) {
+ if (lookupPath.equals("context")) { //$NON-NLS-1$
+ return fEventContext;
+ } else if (lookupPath.equals("fields")) { //$NON-NLS-1$
+ return fFields;
+ } else {
+ return null;
+ }
+ }
+
+ @Override
+ public String toString() {
+ Iterable<String> list;
+ StringBuilder retString = new StringBuilder();
+ final String cr = System.getProperty("line.separator");//$NON-NLS-1$
+
+ retString.append("Event type: ").append(fDeclaration.getName()).append(cr); //$NON-NLS-1$
+ retString.append("Timestamp: ").append(Long.toString(fTimestamp)).append(cr); //$NON-NLS-1$
+
+ if (fEventContext != null) {
+ list = fEventContext.getFieldNames();
+
+ for (String field : list) {
+ retString.append(field).append(" : ").append(fEventContext.getDefinition(field).toString()).append(cr); //$NON-NLS-1$
+ }
+ }
+
+ if (fFields != null) {
+ list = fFields.getFieldNames();
+
+ for (String field : list) {
+ retString.append(field).append(" : ").append(fFields.getDefinition(field).toString()).append(cr); //$NON-NLS-1$
+ }
+ }
+
+ return retString.toString();
+ }
+
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2015 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are made
+ * available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: Matthew Khouzam - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.internal.ctf.core.event;
+
+import java.util.Collections;
+import java.util.Set;
+
+import org.eclipse.tracecompass.ctf.core.CTFException;
+import org.eclipse.tracecompass.ctf.core.CTFStrings;
+import org.eclipse.tracecompass.ctf.core.event.IEventDeclaration;
+import org.eclipse.tracecompass.ctf.core.event.io.BitBuffer;
+import org.eclipse.tracecompass.ctf.core.event.types.IntegerDeclaration;
+import org.eclipse.tracecompass.ctf.core.event.types.StructDeclaration;
+import org.eclipse.tracecompass.ctf.core.trace.CTFStreamInputReader;
+import org.eclipse.tracecompass.ctf.core.trace.ICTFStream;
+
+/**
+ * A lost event definition
+ *
+ * @author Matthew Khouzam
+ * @since 1.0
+ */
+public class LostEventDeclaration implements IEventDeclaration {
+
+ /**
+ * Id of lost events
+ *
+ * @since 1.0
+ */
+ public static final long LOST_EVENT_ID = -1L;
+
+ /**
+ * Gets a "lost" event. This is a synthetic event that is there to show that
+ * there should be something there.
+ */
+ public static final LostEventDeclaration INSTANCE = new LostEventDeclaration();
+
+ private final StructDeclaration fFields = new StructDeclaration(0);
+
+ private LostEventDeclaration() {
+ getFields().addField(CTFStrings.LOST_EVENTS_FIELD, IntegerDeclaration.UINT_32B_DECL);
+ getFields().addField(CTFStrings.LOST_EVENTS_DURATION, IntegerDeclaration.UINT_64B_DECL);
+ }
+
+ @Override
+ public EventDefinition createDefinition(CTFStreamInputReader streamInputReader, BitBuffer input, long timestamp) throws CTFException {
+ return null;
+ }
+
+ @Override
+ public String getName() {
+ return CTFStrings.LOST_EVENT_NAME;
+ }
+
+ @Override
+ public StructDeclaration getFields() {
+ return fFields;
+ }
+
+ @Override
+ public StructDeclaration getContext() {
+ return null;
+ }
+
+ @Override
+ public Long getId() {
+ return LOST_EVENT_ID;
+ }
+
+ /**
+ * @since 2.0
+ */
+ @Override
+ public ICTFStream getStream() {
+ return null;
+ }
+
+ @Override
+ public long getLogLevel() {
+ return 0;
+ }
+
+ @Override
+ public Set<String> getCustomAttributes() {
+ return Collections.<String> emptySet();
+ }
+
+ @Override
+ public String getCustomAttribute(String key) {
+ return null;
+ }
+
+}
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.tracecompass.ctf.core.CTFException;
import org.eclipse.tracecompass.ctf.core.CTFStrings;
-import org.eclipse.tracecompass.ctf.core.event.EventDefinition;
import org.eclipse.tracecompass.ctf.core.event.IEventDeclaration;
-import org.eclipse.tracecompass.ctf.core.event.LostEventDeclaration;
import org.eclipse.tracecompass.ctf.core.event.io.BitBuffer;
import org.eclipse.tracecompass.ctf.core.event.scope.IDefinitionScope;
import org.eclipse.tracecompass.ctf.core.event.scope.ILexicalScope;
import org.eclipse.tracecompass.ctf.core.trace.ICTFPacketDescriptor;
import org.eclipse.tracecompass.ctf.core.trace.IPacketReader;
import org.eclipse.tracecompass.internal.ctf.core.event.EventDeclaration;
+import org.eclipse.tracecompass.internal.ctf.core.event.EventDefinition;
+import org.eclipse.tracecompass.internal.ctf.core.event.LostEventDeclaration;
import org.eclipse.tracecompass.internal.ctf.core.event.types.composite.EventHeaderDefinition;
/**
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.tracecompass.ctf.core.CTFException;
-import org.eclipse.tracecompass.ctf.core.event.EventDefinition;
import org.eclipse.tracecompass.ctf.core.event.types.ICompositeDefinition;
import org.eclipse.tracecompass.ctf.core.trace.ICTFPacketDescriptor;
import org.eclipse.tracecompass.ctf.core.trace.IPacketReader;
+import org.eclipse.tracecompass.internal.ctf.core.event.EventDefinition;
/**
* Null packet reader, used for unset packets
import java.io.Serializable;
import java.util.Comparator;
-import org.eclipse.tracecompass.ctf.core.event.EventDefinition;
+import org.eclipse.tracecompass.ctf.core.event.IEventDefinition;
import org.eclipse.tracecompass.ctf.core.trace.CTFStreamInputReader;
/**
*/
@Override
public int compare(CTFStreamInputReader a, CTFStreamInputReader b) {
- EventDefinition eventA = checkNotNull(a.getCurrentEvent());
- EventDefinition eventB = checkNotNull(b.getCurrentEvent());
+ IEventDefinition eventA = checkNotNull(a.getCurrentEvent());
+ IEventDefinition eventB = checkNotNull(b.getCurrentEvent());
long ta = eventA.getTimestamp();
long tb = eventB.getTimestamp();
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.tracecompass.ctf.core.CTFException;
-import org.eclipse.tracecompass.ctf.core.event.EventDefinition;
+import org.eclipse.tracecompass.ctf.core.event.IEventDefinition;
import org.eclipse.tracecompass.ctf.core.trace.CTFStreamInputReader;
import org.eclipse.tracecompass.ctf.core.trace.CTFTrace;
import org.eclipse.tracecompass.ctf.core.trace.CTFTraceReader;
public synchronized long getCurrentTimestamp() {
final CTFStreamInputReader top = super.getPrio().peek();
if (top != null) {
- EventDefinition currentEvent = top.getCurrentEvent();
+ IEventDefinition currentEvent = top.getCurrentEvent();
if (currentEvent != null) {
long ts = currentEvent.getTimestamp();
return fTrace.timestampCyclesToNanos(ts);
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
-import org.eclipse.tracecompass.ctf.core.event.EventDefinition;
import org.eclipse.tracecompass.ctf.core.event.IEventDeclaration;
+import org.eclipse.tracecompass.ctf.core.event.IEventDefinition;
import org.eclipse.tracecompass.ctf.core.event.types.ICompositeDefinition;
import org.eclipse.tracecompass.ctf.core.event.types.IDefinition;
import org.eclipse.tracecompass.ctf.core.trace.ICTFStream;
// ------------------------------------------------------------------------
private final @Nullable IEventDeclaration fEventDeclaration;
- private final EventDefinition fEvent;
+ private final IEventDefinition fEvent;
// ------------------------------------------------------------------------
// Attributes
String channel,
int cpu,
IEventDeclaration declaration,
- EventDefinition eventDefinition) {
+ IEventDefinition eventDefinition) {
super(trace,
rank,
timestamp,
fSourceCpu = -1;
fEventName = EMPTY_CTF_EVENT_NAME;
fEventDeclaration = null;
- fEvent = EventDefinition.NULL_EVENT;
+ fEvent = NullEventDefinition.INSTANCE;
fChannel = ""; //$NON-NLS-1$
fStream = null;
fPacketAttributes = Collections.EMPTY_MAP;
fSourceCpu = -1;
fEventName = EMPTY_CTF_EVENT_NAME;
fEventDeclaration = null;
- fEvent = EventDefinition.NULL_EVENT;
+ fEvent = NullEventDefinition.INSTANCE;
fChannel = ""; //$NON-NLS-1$
fStream = null;
fPacketAttributes = Collections.EMPTY_MAP;
* Extract the field information from the structDefinition haze-inducing
* mess, and put them into something ITmfEventField can cope with.
*/
- private static CtfTmfEventField[] parseFields(EventDefinition eventDef) {
+ private static CtfTmfEventField[] parseFields(IEventDefinition eventDef) {
List<CtfTmfEventField> fields = new ArrayList<>();
ICompositeDefinition structFields = eventDef.getFields();
}
/**
- * Gets the packet attributes. The result is an instance of one of
- * the following classes: <code>Entry<String, Long></code>, <code>Long</code>,
- * <code>String</code> or <code>Double</code>. The map contains pairs of key and
- * values where the key and value can never be null.
+ * Gets the packet attributes. The result is an instance of one of the
+ * following classes: <code>Entry<String, Long></code>, <code>Long</code>,
+ * <code>String</code> or <code>Double</code>. The map contains pairs of key
+ * and values where the key and value can never be null.
*
* @return gets the packet attributes
* @since 2.0
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.tracecompass.ctf.core.CTFStrings;
-import org.eclipse.tracecompass.ctf.core.event.EventDefinition;
import org.eclipse.tracecompass.ctf.core.event.IEventDeclaration;
+import org.eclipse.tracecompass.ctf.core.event.IEventDefinition;
import org.eclipse.tracecompass.ctf.core.event.types.IDefinition;
import org.eclipse.tracecompass.ctf.core.event.types.IntegerDefinition;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp;
* @return The newly-built CtfTmfEvent
* @since 2.0
*/
- public CtfTmfEvent createEvent(CtfTmfTrace trace, EventDefinition eventDef, @Nullable String fileName) {
+ public CtfTmfEvent createEvent(CtfTmfTrace trace, IEventDefinition eventDef, @Nullable String fileName) {
/* Prepare what to pass to CtfTmfEvent's constructor */
final IEventDeclaration eventDecl = eventDef.getDeclaration();
* @since 2.0
*/
protected static CtfTmfEvent createLostEvent(CtfTmfTrace trace,
- EventDefinition eventDef,
+ IEventDefinition eventDef,
final IEventDeclaration eventDecl,
final long ts,
final TmfNanoTimestamp timestamp,
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
-import org.eclipse.tracecompass.ctf.core.event.EventDefinition;
import org.eclipse.tracecompass.ctf.core.event.IEventDeclaration;
+import org.eclipse.tracecompass.ctf.core.event.IEventDefinition;
import org.eclipse.tracecompass.tmf.core.event.ITmfLostEvent;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange;
IEventDeclaration declaration,
TmfTimeRange timeRange,
long nbLost,
- EventDefinition def) {
+ IEventDefinition def) {
/*
* Only the factory should call this method, the cast to
* (TmfNanoTimestamp) should be safe.
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2016 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are made
+ * available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.tmf.ctf.core.event;
+
+import java.util.Collections;
+import java.util.Map;
+
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
+import org.eclipse.tracecompass.ctf.core.event.IEventDeclaration;
+import org.eclipse.tracecompass.ctf.core.event.IEventDefinition;
+import org.eclipse.tracecompass.ctf.core.event.types.ICompositeDefinition;
+
+/**
+ * Null event definition, used as a poison pill
+ *
+ * @author Matthew Khouzam
+ */
+@NonNullByDefault
+final class NullEventDefinition implements IEventDefinition {
+
+ public static final NullEventDefinition INSTANCE = new NullEventDefinition();
+
+ private NullEventDefinition() {
+ }
+
+ @Override
+ public long getTimestamp() {
+ return 0;
+ }
+
+ @Override
+ public @Nullable ICompositeDefinition getPacketContext() {
+ return null;
+ }
+
+ @Override
+ public Map<String, Object> getPacketAttributes() {
+ return Collections.EMPTY_MAP;
+ }
+
+ @Override
+ public @Nullable ICompositeDefinition getFields() {
+ return null;
+ }
+
+ @Override
+ public @Nullable ICompositeDefinition getEventHeader() {
+ return null;
+ }
+
+ @Override
+ public @Nullable ICompositeDefinition getEventContext() {
+ return null;
+ }
+
+ @Override
+ public @Nullable IEventDeclaration getDeclaration() {
+ return null;
+ }
+
+ @Override
+ public @Nullable ICompositeDefinition getContext() {
+ return null;
+ }
+
+ @Override
+ public int getCPU() {
+ return IEventDefinition.UNKNOWN_CPU;
+ }
+}
\ No newline at end of file
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
-import org.eclipse.tracecompass.ctf.core.event.EventDefinition;
import org.eclipse.tracecompass.ctf.core.event.IEventDeclaration;
+import org.eclipse.tracecompass.ctf.core.event.IEventDefinition;
import org.eclipse.tracecompass.lttng2.ust.core.analysis.debuginfo.UstDebugInfoSourceAspect;
import org.eclipse.tracecompass.tmf.core.event.lookup.ITmfCallsite;
import org.eclipse.tracecompass.tmf.core.event.lookup.ITmfSourceLookup;
* The event definition
*/
protected LttngUstEvent(CtfTmfTrace trace, long rank, TmfNanoTimestamp timestamp,
- String channel, int cpu, IEventDeclaration declaration, EventDefinition eventDefinition) {
+ String channel, int cpu, IEventDeclaration declaration, IEventDefinition eventDefinition) {
super(trace, rank, timestamp, channel, cpu, declaration, eventDefinition);
}
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.tracecompass.ctf.core.CTFStrings;
-import org.eclipse.tracecompass.ctf.core.event.EventDefinition;
import org.eclipse.tracecompass.ctf.core.event.IEventDeclaration;
+import org.eclipse.tracecompass.ctf.core.event.IEventDefinition;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp;
import org.eclipse.tracecompass.tmf.core.trace.ITmfContext;
import org.eclipse.tracecompass.tmf.ctf.core.event.CtfTmfEvent;
}
@Override
- public CtfTmfEvent createEvent(CtfTmfTrace trace, EventDefinition eventDef, @Nullable String fileName) {
+ public CtfTmfEvent createEvent(CtfTmfTrace trace, IEventDefinition eventDef, @Nullable String fileName) {
/* Prepare what to pass to CtfTmfEvent's constructor */
final IEventDeclaration eventDecl = eventDef.getDeclaration();
final long ts = eventDef.getTimestamp();