*/
@Test
public void testEventContextIsSet() {
- assertTrue(fixture.eventContextIsSet());
+ assertTrue(fixture.isEventContextSet());
}
/**
* Run the boolean eventContextIsSet() method test.
*/
@Test
public void testEventHeaderIsSet() {
- assertTrue(fixture.eventHeaderIsSet());
+ assertTrue(fixture.isEventHeaderSet());
}
/**
*/
@Test
public void testIdIsSet() {
- boolean result = fixture.idIsSet();
+ boolean result = fixture.isIdSet();
assertTrue(result);
}
*/
@Test
public void testPacketContextIsSet() {
- boolean result = fixture.packetContextIsSet();
+ boolean result = fixture.isPacketContextSet();
assertTrue(result);
}
import static org.junit.Assert.assertNotNull;
import org.eclipse.linuxtools.ctf.core.event.types.Definition;
+import org.eclipse.linuxtools.ctf.core.event.types.IDeclaration;
import org.eclipse.linuxtools.ctf.core.event.types.IDefinitionScope;
import org.eclipse.linuxtools.internal.ctf.core.event.io.BitBuffer;
import org.junit.After;
/**
* The class <code>DefinitionTest</code> contains tests for the class
* <code>{@link Definition}</code>.
- *
+ *
* @author ematkho
* @version $Revision: 1.0 $
*/
/**
* Launch the test.
- *
+ *
* @param args
* the command line arguments
*/
/* Just a test, no need to implement anything */
}
+ @Override
+ public IDeclaration getDeclaration() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
}
@Test
assertNotNull(result);
}
- /**
- * Run the String getLabel(long) method test.
- */
- @Test
- public void testGetLabel() {
- long i = 0;
- String result = fixture.getLabel(i);
-
- assertNull(result);
- }
-
/**
* Run the String query(long) method test.
*/
/**
* Creates a "lost" event. This is a synthetic event that is there to show
* that there should be something there.
- * @return
+ * @return the lost event
*/
public synchronized static EventDeclaration getLostEventDeclaration(){
EventDeclaration lostEvent = new EventDeclaration();
// Getters/Setters/Predicates
// ------------------------------------------------------------------------
+ /**
+ * Sets a name for an event Declaration
+ * @param name the name
+ */
public void setName(String name) {
this.name = name;
}
+ /**
+ * Gets the name of en event declaration
+ * @return the name
+ */
public String getName() {
return name;
}
+ /**
+ * Sets the context for an event declaration (see CTF specification)
+ * @param context the context in structdeclaration format
+ */
public void setContext(StructDeclaration context) {
this.context = context;
}
+ /**
+ * Sets the fields of an event declaration
+ * @param fields the fields in structdeclaration format
+ */
public void setFields(StructDeclaration fields) {
this.fields = fields;
}
+ /**
+ * Gets the fields of an event declaration
+ * @return fields the fields in structdeclaration format
+ */
public StructDeclaration getFields() {
return fields;
}
+ /**
+ * Gets the context of an event declaration
+ * @return context the fields in structdeclaration format
+ */
public StructDeclaration getContext() {
return context;
}
+ /**
+ * Sets the id of am event declaration
+ * @param id the id
+ */
public void setId(long id) {
this.id = id;
}
+ /**
+ * Gets the id of am event declaration
+ * return id the id
+ */
public Long getId() {
return id;
}
+ /**
+ * Sets the stream of am event declaration
+ * @param stream the stream
+ */
public void setStream(Stream stream) {
this.stream = stream;
}
+ /**
+ * Gets the stream of am event declaration
+ * @return stream the stream
+ */
public Stream getStream() {
return stream;
}
+ /**
+ * Is the name of the event declaration set
+ * @return is the name set?
+ */
public boolean nameIsSet() {
return name != null;
}
+ /**
+ * Is the context set
+ * @return is the context set
+ */
public boolean contextIsSet() {
return context != null;
}
+ /**
+ * Is a field set?
+ * @return Is the field set?
+ */
public boolean fieldsIsSet() {
return fields != null;
}
+ /**
+ * Is the id set?
+ * @return is the id set?
+ */
public boolean idIsSet() {
return id != null;
}
+ /**
+ * Is the stream set?
+ * @return is the stream set?
+ */
public boolean streamIsSet() {
return stream != null;
}
+ /**
+ * What is the log level of this event
+ * @return the log level.
+ */
public long getLogLevel() {
return logLevel;
}
+ /**
+ * Sets the log level
+ * @param level the log level
+ */
public void setLogLevel( long level){
logLevel = level;
}
return "event"; //$NON-NLS-1$
}
+ /**
+ * Gets the declaration (the form) of the data
+ *
+ * @return the event declaration
+ */
public EventDeclaration getDeclaration() {
return declaration;
}
+ /**
+ * Gets the fields of a definition
+ *
+ * @return the fields of a definition in struct form. Can be null.
+ */
public StructDefinition getFields() {
return fields;
}
+ /**
+ * Gets the context of this event
+ *
+ * @return the context in struct form
+ */
public StructDefinition getContext() {
return context;
}
+ /**
+ * Gets the stream input reader that this event was made by
+ *
+ * @return the parent
+ */
public StreamInputReader getStreamInputReader() {
return streamInputReader;
}
+ /**
+ * Gets the context of packet the event is in.
+ *
+ * @return the packet context
+ */
public StructDefinition getPacketContext() {
return streamInputReader.getCurrentPacketContext();
}
+ /**
+ * gets the CPU the event was generated by. Slightly LTTng specific
+ *
+ * @return The CPU the event was generated by
+ */
public int getCPU() {
return streamInputReader.getCPU();
}
}
/**
- * @param timestamp the timestamp to set
+ * @param timestamp
+ * the timestamp to set
*/
public void setTimestamp(long timestamp) {
this.timestamp = timestamp;
}
/**
- * @param context the context to set
+ * @param context
+ * the context to set
*/
public void setContext(StructDefinition context) {
this.context = context;
}
/**
- * @param fields the fields to set
+ * @param fields
+ * the fields to set
*/
public void setFields(StructDefinition fields) {
this.fields = fields;
list = context.getDeclaration().getFieldsList();
for (String field : list) {
- retString.append(field + " : " + definitions.get(field).toString() + cr); //$NON-NLS-1$
+ retString.append(field
+ + " : " + definitions.get(field).toString() + cr); //$NON-NLS-1$
}
}
list = fields.getDeclaration().getFieldsList();
for (String field : list) {
- retString.append(field + " : " + definitions.get(field).toString() + cr); //$NON-NLS-1$
+ retString.append(field
+ + " : " + definitions.get(field).toString() + cr); //$NON-NLS-1$
}
}
// Constructors
// ------------------------------------------------------------------------
+ /**
+ * Constructor
+ * @param length how many elements in the array
+ * @param elemType what type of element is in the array
+ */
public ArrayDeclaration(int length, IDeclaration elemType) {
this.length = length;
this.elemType = elemType;
// Getters/Setters/Predicates
// ------------------------------------------------------------------------
+ /**
+ *
+ * @return the type of element in the array
+ */
public IDeclaration getElementType() {
return elemType;
}
+ /**
+ *
+ * @return how many elements in the array
+ */
public int getLength() {
return length;
}
// Constructors
// ------------------------------------------------------------------------
+ /**
+ * Constructor
+ * @param declaration the parent declaration
+ * @param definitionScope the parent scope
+ * @param fieldName the field name
+ */
public ArrayDefinition(ArrayDeclaration declaration,
IDefinitionScope definitionScope, String fieldName) {
super(definitionScope, fieldName);
this.definitions = definitions;
}
+ /**
+ * Get the element at i
+ * @param i the index (cannot be negative)
+ * @return The element at I, if I > length, null, if I < 0, the method throws an out of bounds exception
+ */
public Definition getElem(int i) {
if (i > definitions.length) {
return null;
return definitions[i];
}
+ @Override
public ArrayDeclaration getDeclaration() {
return declaration;
}
import org.eclipse.linuxtools.internal.ctf.core.event.io.BitBuffer;
/**
- * <b><u>Definition</u></b>
+ * <b><u>Definition</u></b><br>
+ * A definition is like an object of a declaration class. It fills the declaration with values. <br>
+ * An example: <br>
+ * int i = 0; <br>
+ * <b>int</b> is the declaration.<br>
+ * <b>i</b> is the definition.<br>
+ * <b>0</b> is the value assigned to the definition, not the declaration.<br>
+ *
*/
public abstract class Definition {
// Constructors
// ------------------------------------------------------------------------
+ /**
+ * Constructor
+ *
+ * @param definitionScope
+ * the definition is in a scope, (normally a struct) what is it?
+ * @param fieldName
+ * the name of the definition. (it is a field in the parent
+ * scope)
+ */
public Definition(IDefinitionScope definitionScope, String fieldName) {
this.definitionScope = definitionScope;
this.fieldName = fieldName;
// Operations
// ------------------------------------------------------------------------
+ /**
+ *
+ * @return gets the declaration of a datatype
+ *
+ */
+ public abstract IDeclaration getDeclaration();
+
+ /**
+ * Read the definition from a bitbuffer
+ *
+ * @param input
+ * the bitbuffer containing the data to read.
+ */
public abstract void read(BitBuffer input);
@Override
* Encoding types
*/
public enum Encoding {
- UTF8, ASCII, NONE
+ /** UTF-8 encoding */
+ UTF8,
+ /** Ascii encoding */
+ ASCII,
+ /** No encoding, maybe not even text */
+ NONE
}
// Constructors
// ------------------------------------------------------------------------
+ /**
+ * constructor
+ *
+ * @param containerType
+ * the enum is an int, this is the type that the data is
+ * contained in. If you have 1000 possible values, you need at
+ * least a 10 bit enum. If you store 2 values in a 128 bit int,
+ * you are wasting space.
+ */
public EnumDeclaration(IntegerDeclaration containerType) {
this.containerType = containerType;
}
// Getters/Setters/Predicates
// ------------------------------------------------------------------------
+ /**
+ *
+ * @return The container type
+ */
public IntegerDeclaration getContainerType() {
return containerType;
}
public long getAlignment() {
return this.getContainerType().getAlignment();
}
+
// ------------------------------------------------------------------------
// Operations
// ------------------------------------------------------------------------
return new EnumDefinition(this, definitionScope, fieldName);
}
+ /**
+ * Add a value. Do not overlap, this is <i><u><b>not</i></u></b> an interval tree.
+ * @param low lowest value that this int can be to have label as a return string
+ * @param high highest value that this int can be to have label as a return string
+ * @param label the name of the value.
+ * @return was the value be added? true == success
+ */
public boolean add(long low, long high, String label) {
return table.add(low, high, label);
}
+ /**
+ * check if the label for a value (enum a{day=0,night=1} would return "day" for query(0)
+ * @param value the value to lookup
+ * @return the label of that value, can be null
+ */
public String query(long value) {
return table.query(value);
}
- public String getLabel(long i) {
- return table.getLabel(i);
- }
-
/*
* Maps integer range -> string. A simple list for now, but feel free to
* optimize it. Babeltrace suggests an interval tree.
public EnumTable() {
}
- public String getLabel(long i) {
- for (Range r : ranges) {
- if (r.intersects(i)) {
- return r.str;
- }
- }
- return null;
- }
-
public boolean add(long low, long high, String label) {
Range newRange = new Range(low, high, label);
return true;
}
+ /**
+ * return the first label that matches a value
+ * @param value the value to query
+ * @return the label corresponding to that value
+ */
public String query(long value) {
for (Range r : ranges) {
if (r.intersects(value)) {
return r.str;
}
}
-
return null;
}
return "[declaration] enum[" + Integer.toHexString(hashCode()) + ']'; //$NON-NLS-1$
}
-
}
// Constructors
// ------------------------------------------------------------------------
+ /**
+ * Constructor
+ * @param declaration the parent declaration
+ * @param definitionScope the parent scope
+ * @param fieldName the field name
+ */
public EnumDefinition(EnumDeclaration declaration,
IDefinitionScope definitionScope, String fieldName) {
super(definitionScope, fieldName);
// Getters/Setters/Predicates
// ------------------------------------------------------------------------
+ /**
+ * Gets the value of the enum in string format so "Enum a{DAY="0", NIGHT="1"}; will return "DAY"
+ * @return the value of the enum.
+ */
public String getValue() {
return value;
}
+ /**
+ * Gets the value of the enum in string format so "Enum a{DAY="0", NIGHT="1"}; will return 0
+ * @return the value of the enum.
+ */
public long getIntegerValue() {
return integerValue.getValue();
}
+ /**
+ * Sets the value of the enum in string format so "Enum a{DAY="0", NIGHT="1"}; will set 0
+ * @param Value The value of the enum.
+ */
public void setIntegerValue(long Value) {
integerValue.setValue(Value);
value = ((Long) integerValue.getValue()).toString();
}
+ @Override
+ public EnumDeclaration getDeclaration() {
+ return declaration;
+ }
+
// ------------------------------------------------------------------------
// Operations
// ------------------------------------------------------------------------
import java.nio.ByteOrder;
-
+/**
+ * Float declaration
+ *
+ * @author Matthew Khouzam
+ *
+ */
public class FloatDeclaration implements IDeclaration {
// ------------------------------------------------------------------------
// Constructors
// ------------------------------------------------------------------------
+ /**
+ * Constructor
+ * @param exponent the exponent size in bits
+ * @param mantissa the mantissa size in bits (+1 for sign) (see ctf spec)
+ * @param byteOrder the byte order
+ * @param alignment the alignment
+ */
public FloatDeclaration(int exponent, int mantissa, ByteOrder byteOrder,
long alignment) {
mant = mantissa;
import org.eclipse.linuxtools.internal.ctf.core.event.io.BitBuffer;
+/**
+ * Float definition
+ * @author Matthew Khouzam
+ *
+ */
public class FloatDefinition extends Definition {
// ------------------------------------------------------------------------
// Attributes
// Contructors
// ------------------------------------------------------------------------
+ /**
+ * Constructor
+ *
+ * @param declaration
+ * the parent declaration
+ * @param definitionScope
+ * the parent scope
+ * @param fieldName
+ * the field name
+ */
public FloatDefinition(FloatDeclaration declaration,
IDefinitionScope definitionScope, String fieldName) {
super(definitionScope, fieldName);
// Gettters/Setters/Predicates
// ------------------------------------------------------------------------
+ /**
+ * THe value of a float stored, fit into a double. This should be extended
+ * for exotic floats if this is necessary.
+ *
+ * @return the value of the float field fit into a double.
+ */
public double getValue() {
return value;
}
+ /**
+ * Sets the value of the float
+ *
+ * @param val
+ * the value of the float
+ */
public void setValue(double val) {
value = val;
}
+ @Override
public FloatDeclaration getDeclaration() {
return declaration;
}
*/
public interface IDeclaration {
+ /**
+ * Create a definition from this declaration
+ *
+ * @param definitionScope
+ * the definition scope, the parent where the definition will be
+ * placed
+ * @param fieldName
+ * the name of the definition
+ * @return a reference to the definition
+ */
public Definition createDefinition(IDefinitionScope definitionScope,
String fieldName);
+ /**
+ * The minimum alignment. if the field is 32 bits, the definition will pad
+ * all the data up to (position%32==0)
+ *
+ * @return the alignment in bits
+ */
public long getAlignment();
}
*/
public interface IDefinitionScope {
+ /**
+ * Gets the path in a C style for the scope.
+ * @return the path
+ */
public String getPath();
/**
// Constructors
// ------------------------------------------------------------------------
+ /**
+ * Contructor
+ * @param len the length in bits
+ * @param signed is the integer signed? false == unsigned
+ * @param base the base (10-16 are most common)
+ * @param byteOrder Big endian little endian or other
+ * @param encoding ascii, utf8 or none.
+ * @param clock the clock path, can be null
+ * @param alignment the minimum alignment
+ */
public IntegerDeclaration(int len, boolean signed, int base,
ByteOrder byteOrder, Encoding encoding, String clock, long alignment) {
this.length = len;
// Gettters/Setters/Predicates
// ------------------------------------------------------------------------
+ /**
+ * Is the integer signed?
+ * @return the is the integer signed
+ */
public boolean isSigned() {
return signed;
}
+ /**
+ * get the integer base commonly decimal or hex
+ * @return the integer base
+ */
public int getBase() {
return base;
}
+ /**
+ * gets the byte order
+ * @return the byte order
+ */
public ByteOrder getByteOrder() {
return byteOrder;
}
+ /**
+ * get encoding, chars are 8 bit ints
+ * @return the encoding
+ */
public Encoding getEncoding() {
return encoding;
}
+ /**
+ * is the integer a character (8 bits and encoded?)
+ * @return is the integer a char
+ */
public boolean isCharacter() {
return (length == 8) && (encoding != Encoding.NONE);
}
+ /**
+ * How many bits is this int
+ * @return the length of the int
+ */
public int getLength() {
return length;
}
return alignment;
}
+ /**
+ * The integer's clock, since timestamps are stored in ints
+ * @return the integer's clock, can be null. (most often it is)
+ */
public String getClock(){
return clock;
}
// Contructors
// ------------------------------------------------------------------------
+ /**
+ * Constructor
+ * @param declaration the parent declaration
+ * @param definitionScope the parent scope
+ * @param fieldName the field name
+ */
public IntegerDefinition(IntegerDeclaration declaration,
IDefinitionScope definitionScope, String fieldName) {
super(definitionScope, fieldName);
// Gettters/Setters/Predicates
// ------------------------------------------------------------------------
+ /**
+ * Gets the value of the integer
+ * @return the value of the integer (in long)
+ */
public long getValue() {
return value;
}
+ /**
+ * Sets the value of an integer
+ * @param val the value
+ */
public void setValue(long val) {
value = val;
}
+ @Override
public IntegerDeclaration getDeclaration() {
return declaration;
}
import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException;
/**
- * <b><u>SequenceDeclaration</u></b>
+ * <b><u>SequenceDeclaration</u></b> <br>
+ * An array where the size is fixed but declared in the trace, unlike array
+ * where it is declared with a literal
*/
public class SequenceDeclaration implements IDeclaration {
// Constructors
// ------------------------------------------------------------------------
+ /**
+ * Constuctor
+ *
+ * @param lengthName
+ * the name of the field describing the lenght
+ * @param elemType
+ */
public SequenceDeclaration(String lengthName, IDeclaration elemType) {
this.elemType = elemType;
this.lengthName = lengthName;
// Gettters/Setters/Predicates
// ------------------------------------------------------------------------
+ /**
+ * Gets the element type
+ * @return the element type
+ */
public IDeclaration getElementType() {
return elemType;
}
+ /**
+ * Gets the name of the length field
+ * @return the name of the length field
+ */
public String getLengthName() {
return lengthName;
}
public long getAlignment() {
return getElementType().getAlignment();
}
+
// ------------------------------------------------------------------------
// Operations
// ------------------------------------------------------------------------
// Constructors
// ------------------------------------------------------------------------
+ /**
+ * Constructor
+ *
+ * @param declaration
+ * the parent declaration
+ * @param definitionScope
+ * the parent scope
+ * @param fieldName
+ * the field name
+ */
public SequenceDefinition(SequenceDeclaration declaration,
- IDefinitionScope definitionScope, String fieldName) throws CTFReaderException {
+ IDefinitionScope definitionScope, String fieldName)
+ throws CTFReaderException {
super(definitionScope, fieldName);
Definition lenDef = null;
this.declaration = declaration;
if (definitionScope != null) {
- lenDef = definitionScope.lookupDefinition(declaration.getLengthName());
+ lenDef = definitionScope.lookupDefinition(declaration
+ .getLengthName());
}
- if (lenDef == null) {
- throw new CTFReaderException("Sequence length field not found"); //$NON-NLS-1$
- }
+ if (lenDef == null) {
+ throw new CTFReaderException("Sequence length field not found"); //$NON-NLS-1$
+ }
- if (!(lenDef instanceof IntegerDefinition)) {
- throw new CTFReaderException("Sequence length field not integer"); //$NON-NLS-1$
- }
+ if (!(lenDef instanceof IntegerDefinition)) {
+ throw new CTFReaderException("Sequence length field not integer"); //$NON-NLS-1$
+ }
- lengthDefinition = (IntegerDefinition) lenDef;
+ lengthDefinition = (IntegerDefinition) lenDef;
if (this.lengthDefinition.getDeclaration().isSigned()) {
throw new CTFReaderException("Sequence length must not be signed"); //$NON-NLS-1$
// Getters/Setters/Predicates
// ------------------------------------------------------------------------
+ @Override
public SequenceDeclaration getDeclaration() {
return declaration;
}
+ /**
+ * The length of the sequence in number of elements so a sequence of 5
+ * GIANT_rediculous_long_ints is the same as a sequence of 5 bits. (5)
+ *
+ * @return the length of the sequence
+ */
public int getLength() {
return currentLength;
}
+ /**
+ * Get the element at i
+ *
+ * @param i
+ * the index (cannot be negative)
+ * @return The element at I, if I > length, null, if I < 0, the method
+ * throws an out of bounds exception
+ */
public Definition getElem(int i) {
if (i > definitions.length) {
return null;
return definitions[i];
}
+ /**
+ * Is the sequence a null terminated string?
+ * @return true == is a string, false == is not a string
+ */
public boolean isString() {
IntegerDeclaration elemInt;
}
for (; i < currentLength; i++) {
- newDefinitions[i] = declaration.getElementType().createDefinition(
- definitionScope, fieldName + "[" + i + "]"); //$NON-NLS-1$ //$NON-NLS-2$
+ newDefinitions[i] = declaration.getElementType()
+ .createDefinition(definitionScope,
+ fieldName + "[" + i + "]"); //$NON-NLS-1$ //$NON-NLS-2$
}
definitions = newDefinitions;
// Constructors
// ------------------------------------------------------------------------
- public Encoding getEncoding() {
- return encoding;
- }
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
-
+ /**
+ * Generate a UTF8 string declaration
+ */
public StringDeclaration() {
}
+ /**
+ * generate an encoded string declaration
+ * @param encoding the encoding, utf8 or ascii
+ */
public StringDeclaration(Encoding encoding) {
this.encoding = encoding;
}
// Getters/Setters/Predicates
// ------------------------------------------------------------------------
+ /**
+ *
+ * @return the character encoding.
+ */
+ public Encoding getEncoding() {
+ return encoding;
+ }
+
+ /**
+ *
+ * @param encoding the character encoding to set
+ */
public void setEncoding(Encoding encoding) {
this.encoding = encoding;
}
// Constructors
// ------------------------------------------------------------------------
+ /**
+ * Constructor
+ * @param declaration the parent declaration
+ * @param definitionScope the parent scope
+ * @param fieldName the field name
+ */
public StringDefinition(StringDeclaration declaration,
IDefinitionScope definitionScope, String fieldName) {
super(definitionScope, fieldName);
// Getters/Setters/Predicates
// ------------------------------------------------------------------------
+ @Override
public StringDeclaration getDeclaration() {
return declaration;
}
+ /**
+ * Sets the string declaration
+ * @param declaration the declaration
+ */
public void setDeclaration(StringDeclaration declaration) {
this.declaration = declaration;
}
+ /**
+ * Gets the string
+ * @return the stringbuilder
+ */
public StringBuilder getString() {
return string;
}
+ /**
+ * Sets a stringbuilder for the definition
+ * @param string the stringbuilder
+ */
public void setString(StringBuilder string) {
this.string = string;
}
+ /**
+ * Gets the string (value)
+ * @return the string
+ */
public String getValue() {
return string.toString();
}
// Constructors
// ------------------------------------------------------------------------
+ /**
+ * The struct declaration, add fields later
+ *
+ * @param align
+ * the minimum alignment of the struct. (if a struct is 8bit
+ * aligned and has a 32 bit aligned field, the struct becomes 32
+ * bit aligned.
+ */
public StructDeclaration(long align) {
this.maxAlign = Math.max(align, 1);
}
// Getters/Setters/Predicates
// ------------------------------------------------------------------------
+ /**
+ * Get current alignment
+ * @return the alignment of the struct and all its fields
+ */
public long getMaxAlign() {
return maxAlign;
}
+ /**
+ * Query if the struct has a given field
+ * @param name the name of the field, scopeless please
+ * @return does the field exist?
+ */
public boolean hasField(String name) {
return this.fields.containsKey(name);
}
+ /**
+ * get the fields of the struct in a map. Faster access time than a list.
+ * @return a HashMap of the fields (key is the name)
+ */
public HashMap<String, IDeclaration> getFields() {
return this.fields;
}
+ /**
+ * Gets the field list. Very important since the map of fields does not retain the order of the fields.
+ * @return the field list.
+ */
public List<String> getFieldsList() {
return this.fieldsList;
}
public long getAlignment() {
return this.maxAlign;
}
+
// ------------------------------------------------------------------------
// Operations
// ------------------------------------------------------------------------
return new StructDefinition(this, definitionScope, fieldName);
}
+ /**
+ * Add a field to the struct
+ * @param name the name of the field, scopeless
+ * @param declaration the declaration of the field
+ */
public void addField(String name, IDeclaration declaration) {
this.fields.put(name, declaration);
this.fieldsList.add(name);
maxAlign = Math.max(maxAlign, declaration.getAlignment());
- if( maxAlign == 1 )
- {
- maxAlign =1;
+ if (maxAlign == 1) {
+ maxAlign = 1;
}
}
return "[declaration] struct[" + Integer.toHexString(hashCode()) + ']'; //$NON-NLS-1$
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see java.lang.Object#hashCode()
*/
@Override
return result;
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
// Constructors
// ------------------------------------------------------------------------
+ /**
+ * Constructor
+ *
+ * @param declaration
+ * the parent declaration
+ * @param definitionScope
+ * the parent scope
+ * @param fieldName
+ * the field name
+ */
public StructDefinition(StructDeclaration declaration,
IDefinitionScope definitionScope, String structFieldName) {
super(definitionScope, structFieldName);
return path;
}
+ /**
+ * @return The definitions of all the fields
+ */
public HashMap<String, Definition> getDefinitions() {
return definitions;
}
+ @Override
public StructDeclaration getDeclaration() {
return declaration;
}
@Override
public void read(BitBuffer input) {
final int align = (int) declaration.getAlignment();
- int pos = input.position() + ((align-(input.position() % align))%align);
+ int pos = input.position()
+ + ((align - (input.position() % align)) % align);
input.position(pos);
final List<String> fieldList = declaration.getFieldsList();
for (String fName : fieldList) {
return retVal;
}
+ /**
+ * Lookup an array in a struct. if the name returns a non-array (like an
+ * int) than the method returns null
+ *
+ * @param name
+ * the name of the array
+ * @return the array or null.
+ */
public ArrayDefinition lookupArray(String name) {
Definition def = lookupDefinition(name);
return (ArrayDefinition) ((def instanceof ArrayDefinition) ? def : null);
}
+ /**
+ * Lookup an enum in a struct. if the name returns a non-enum (like an int)
+ * than the method returns null
+ *
+ * @param name
+ * the name of the enum
+ * @return the enum or null.
+ */
public EnumDefinition lookupEnum(String name) {
Definition def = lookupDefinition(name);
return (EnumDefinition) ((def instanceof EnumDefinition) ? def : null);
}
+ /**
+ * Lookup an integer in a struct. if the name returns a non-integer (like an
+ * float) than the method returns null
+ *
+ * @param name
+ * the name of the integer
+ * @return the integer or null.
+ */
public IntegerDefinition lookupInteger(String name) {
Definition def = lookupDefinition(name);
return (IntegerDefinition) ((def instanceof IntegerDefinition) ? def
: null);
}
+ /**
+ * Lookup a sequence in a struct. if the name returns a non-sequence (like
+ * an int) than the method returns null
+ *
+ * @param name
+ * the name of the sequence
+ * @return the sequence or null.
+ */
public SequenceDefinition lookupSequence(String name) {
Definition def = lookupDefinition(name);
return (SequenceDefinition) ((def instanceof SequenceDefinition) ? def
: null);
}
+ /**
+ * Lookup a string in a struct. if the name returns a non-string (like
+ * an int) than the method returns null
+ *
+ * @param name
+ * the name of the string
+ * @return the string or null.
+ */
public StringDefinition lookupString(String name) {
Definition def = lookupDefinition(name);
return (StringDefinition) ((def instanceof StringDefinition) ? def
: null);
}
+ /**
+ * Lookup a struct in a struct. if the name returns a non-struct (like
+ * an int) than the method returns null
+ *
+ * @param name
+ * the name of the struct
+ * @return the struct or null.
+ */
public StructDefinition lookupStruct(String name) {
Definition def = lookupDefinition(name);
return (StructDefinition) ((def instanceof StructDefinition) ? def
: null);
}
+ /**
+ * Lookup a variant in a struct. if the name returns a non-variant (like
+ * an int) than the method returns null
+ *
+ * @param name
+ * the name of the variant
+ * @return the variant or null.
+ */
public VariantDefinition lookupVariant(String name) {
Definition def = lookupDefinition(name);
return (VariantDefinition) ((def instanceof VariantDefinition) ? def
builder.append("{ "); //$NON-NLS-1$
}
- ListIterator<String> listIterator = this.declaration.getFieldsList().listIterator();
+ ListIterator<String> listIterator = this.declaration.getFieldsList()
+ .listIterator();
while (listIterator.hasNext()) {
String field = listIterator.next();
// Constructors
// ------------------------------------------------------------------------
+ /**
+ * constructor
+ */
public VariantDeclaration() {
}
// Getters/Setters/Predicates
// ------------------------------------------------------------------------
+ /**
+ * @return Does the variant have a tag
+ */
public boolean isTagged() {
return tag != null;
}
+ /**
+ * Lookup if a field exists in the variant
+ * @param fieldTag the field tag name
+ * @return true = field tag exists
+ */
public boolean hasField(String fieldTag) {
return fields.containsKey(fieldTag);
}
+ /**
+ * Sets the tag in a variant
+ * @param tag the tag
+ */
public void setTag(String tag) {
this.tag = tag;
}
+ /**
+ * gets current variant tag
+ * @return the variant tag.
+ */
public String getTag() {
return this.tag;
}
+ /**
+ * Gets the fields of the variant
+ * @return the fields of the variant
+ */
public HashMap<String, IDeclaration> getFields() {
return this.fields;
}
return new VariantDefinition(this, definitionScope, fieldName);
}
+ /**
+ *
+ * @param fieldTag
+ * @param declaration
+ */
public void addField(String fieldTag, IDeclaration declaration) {
fields.put(fieldTag, declaration);
}
// Constructors
// ------------------------------------------------------------------------
+ /**
+ * Constructor
+ * @param declaration the parent declaration
+ * @param definitionScope the parent scope
+ * @param fieldName the field name
+ */
public VariantDefinition(VariantDeclaration declaration,
IDefinitionScope definitionScope, String fieldName) {
super(definitionScope, fieldName);
// Getters/Setters/Predicates
// ------------------------------------------------------------------------
+ @Override
public VariantDeclaration getDeclaration() {
return declaration;
}
+ /**
+ * Sets the variant declaration
+ * @param declaration the variant declaration
+ */
public void setDeclaration(VariantDeclaration declaration) {
this.declaration = declaration;
}
+ /**
+ * Gets the tag
+ * @return the tag definition
+ */
public EnumDefinition getTagDefinition() {
return tagDefinition;
}
+ /**
+ * Sets the tag
+ * @param tagDefinition the tag
+ */
public void setTagDefinition(EnumDefinition tagDefinition) {
this.tagDefinition = tagDefinition;
}
+ /**
+ * Get the definitions in the variant
+ * @return the definitions
+ */
public HashMap<String, Definition> getDefinitions() {
return definitions;
}
+ /**
+ * Set the definitions in a variant
+ * @param definitions the definitions
+ */
public void setDefinitions(HashMap<String, Definition> definitions) {
this.definitions = definitions;
}
+ /**
+ * Set the current field
+ * @param currentField the current field
+ */
public void setCurrentField(String currentField) {
this.currentField = currentField;
}
return path;
}
+ /**
+ * Get the current field name
+ * @return the current field name
+ */
+ public String getCurrentFieldName() {
+ return currentField;
+ }
+
+ /**
+ * Get the current field
+ * @return the current field
+ */
+ public Definition getCurrentField() {
+ return definitions.get(currentField);
+ }
+
+
// ------------------------------------------------------------------------
// Operations
// ------------------------------------------------------------------------
return definitions.get(lookupPath);
}
- public String getCurrentFieldName() {
- return currentField;
- }
-
- public Definition getCurrentField() {
- return definitions.get(currentField);
- }
+ /**
+ * Lookup an array in a struct. if the name returns a non-array (like an
+ * int) than the method returns null
+ *
+ * @param name
+ * the name of the array
+ * @return the array or null.
+ */
public ArrayDefinition lookupArray(String name) {
- Definition def = definitions.get(name);
+ Definition def = lookupDefinition(name);
return (ArrayDefinition) ((def instanceof ArrayDefinition) ? def : null);
}
+ /**
+ * Lookup an enum in a struct. if the name returns a non-enum (like an int)
+ * than the method returns null
+ *
+ * @param name
+ * the name of the enum
+ * @return the enum or null.
+ */
public EnumDefinition lookupEnum(String name) {
- Definition def = definitions.get(name);
+ Definition def = lookupDefinition(name);
return (EnumDefinition) ((def instanceof EnumDefinition) ? def : null);
}
+ /**
+ * Lookup an integer in a struct. if the name returns a non-integer (like an
+ * float) than the method returns null
+ *
+ * @param name
+ * the name of the integer
+ * @return the integer or null.
+ */
public IntegerDefinition lookupInteger(String name) {
- Definition def = definitions.get(name);
+ Definition def = lookupDefinition(name);
return (IntegerDefinition) ((def instanceof IntegerDefinition) ? def
: null);
}
+ /**
+ * Lookup a sequence in a struct. if the name returns a non-sequence (like
+ * an int) than the method returns null
+ *
+ * @param name
+ * the name of the sequence
+ * @return the sequence or null.
+ */
public SequenceDefinition lookupSequence(String name) {
- Definition def = definitions.get(name);
+ Definition def = lookupDefinition(name);
return (SequenceDefinition) ((def instanceof SequenceDefinition) ? def
: null);
}
+ /**
+ * Lookup a string in a struct. if the name returns a non-string (like
+ * an int) than the method returns null
+ *
+ * @param name
+ * the name of the string
+ * @return the string or null.
+ */
public StringDefinition lookupString(String name) {
- Definition def = definitions.get(name);
+ Definition def = lookupDefinition(name);
return (StringDefinition) ((def instanceof StringDefinition) ? def
: null);
}
+ /**
+ * Lookup a struct in a struct. if the name returns a non-struct (like
+ * an int) than the method returns null
+ *
+ * @param name
+ * the name of the struct
+ * @return the struct or null.
+ */
public StructDefinition lookupStruct(String name) {
- Definition def = definitions.get(name);
+ Definition def = lookupDefinition(name);
return (StructDefinition) ((def instanceof StructDefinition) ? def
: null);
}
+ /**
+ * Lookup a variant in a struct. if the name returns a non-variant (like
+ * an int) than the method returns null
+ *
+ * @param name
+ * the name of the variant
+ * @return the variant or null.
+ */
public VariantDefinition lookupVariant(String name) {
- Definition def = definitions.get(name);
+ Definition def = lookupDefinition(name);
return (VariantDefinition) ((def instanceof VariantDefinition) ? def
: null);
}
eventDecs.put(stream.getId(), new HashMap<Long,EventDeclaration>());
}
+ /**
+ * gets the Environment variables from the trace metadata (See CTF spec)
+ * @return the environment variables in a hashmap form (key value)
+ */
public HashMap<String, String> getEnvironment() {
return environment;
}
+ /**
+ * Look up a specific environment variable
+ * @param key the key to look for
+ * @return the value of the variable, can be null.
+ */
public String lookupEnvironment(String key) {
return environment.get(key);
}
+ /**
+ * Add a variable to the environment variables
+ * @param varName the name of the variable
+ * @param varValue the value of the variable
+ */
public void addEnvironmentVar(String varName, String varValue) {
environment.put(varName, varValue);
}
+ /**
+ * Add a clock to the clock list
+ * @param nameValue the name of the clock (full name with scope)
+ * @param ctfClock the clock
+ */
public void addClock(String nameValue, CTFClock ctfClock) {
clocks.put(nameValue, ctfClock);
}
+ /**
+ * gets the clock with a specific name
+ * @param name the name of the clock.
+ * @return the clock
+ */
public CTFClock getClock(String name) {
return clocks.get(name);
}
private CTFClock singleClock;
private long singleOffset;
+ /**
+ * gets the clock if there is only one. (this is 100% of the use cases as of June 2012)
+ * @return the clock
+ */
public final CTFClock getClock() {
if (clocks.size() == 1) {
if (singleClock == null) {
return null;
}
+ /**
+ * gets the time offset of a clock with respect to UTC in nanoseconds
+ * @return the time offset of a clock with respect to UTC in nanoseconds
+ */
public final long getOffset() {
if (getClock() == null) {
return 0;
return singleOffset;
}
+ /**
+ * Does a given stream contain any events?
+ * @param id the stream ID
+ * @return true if the stream has events.
+ */
public boolean hasEvents(Long id){
return eventDecs.containsKey(id);
}
+
+ /**
+ * Add an event declaration map to the events map.
+ * @param id the id of a stream
+ * @return the hashmap containing events.
+ */
public HashMap<Long, EventDeclaration> createEvents(Long id){
HashMap<Long, EventDeclaration> value = eventDecs.get(id);
if( value == null ) {
*/
private long endTime;
-
protected void setEndTime(long endTime) {
this.endTime = endTime;
}
* Add it back in the queue.
*/
this.prio.add(top);
- final long topEnd = top.getCurrentEvent().getTimestamp() + this.getTrace().getOffset();
- this.setEndTime( Math.max(topEnd, this.getEndTime()));
+ final long topEnd = top.getCurrentEvent().getTimestamp()
+ + this.getTrace().getOffset();
+ this.setEndTime(Math.max(topEnd, this.getEndTime()));
this.eventCountPerTraceFile[top.getName()]++;
if (top.getCurrentEvent() != null) {
return tempIndex;
}
+ /**
+ * gets the stream with the oldest event
+ *
+ * @return the stream with the oldest event
+ */
public StreamInputReader getTopStream() {
return this.prio.peek();
}
}
}
+ /**
+ * gets the last event timestamp that was read. This is NOT necessarily the
+ * last event in a trace, just the last one read so far.
+ *
+ * @return the last event
+ */
public long getEndTime() {
return this.endTime;
}
return "CTFTraceReader [trace=" + trace + ']'; //$NON-NLS-1$
}
+ /**
+ * Gets the parent trace
+ *
+ * @return the parent trace
+ */
public CTFTrace getTrace() {
return trace;
}
// Getters/Setters/Predicates
// ------------------------------------------------------------------------
- /* Getters, setters and stuff. */
-
+ /**
+ * Gets the current packet
+ *
+ * @return the current packet
+ */
public StreamInputPacketIndexEntry getCurrentPacket() {
return this.currentPacket;
}
+ /**
+ * Gets the steamPacketContext Definition
+ *
+ * @return steamPacketContext Definition
+ */
public StructDefinition getStreamPacketContextDef() {
return this.streamPacketContextDef;
}
+ /**
+ * Gets the CPU (core) number
+ *
+ * @return the CPU (core) number
+ */
public int getCPU() {
return this.currentCpu;
}
return null;
}
+ /**
+ * Gets the stream event context definition (see CTF specs)
+ *
+ * @return the definition of the stream event context (the form not the
+ * content)
+ */
public StructDefinition getStreamEventContextDef() {
return this.streamEventContextDef;
}
+ /**
+ * Sets the stream event context definition
+ *
+ * @param streamEventContextDef
+ * The stream event context definition
+ */
public void setStreamEventContextDef(StructDefinition streamEventContextDef) {
this.streamEventContextDef = streamEventContextDef;
}
+ /**
+ * Gets the stream event header definition
+ *
+ * @return the stream event header definition
+ */
public StructDefinition getStreamEventHeaderDef() {
return this.streamEventHeaderDef;
}
+ /**
+ * Sets the stream event header definition
+ *
+ * @param streamEventHeaderDef
+ * the stream event header definition
+ */
public void setStreamEventHeaderDef(StructDefinition streamEventHeaderDef) {
this.streamEventHeaderDef = streamEventHeaderDef;
}
+ /**
+ * Sets the stream packet context definition
+ *
+ * @param streamPacketContextDef
+ * the stream packet context definition
+ */
public void setStreamPacketContextDef(
StructDefinition streamPacketContextDef) {
this.streamPacketContextDef = streamPacketContextDef;
}
+ /**
+ * Gets the trace packet header definition
+ *
+ * @return the trace packet header definition
+ */
public StructDefinition getTracePacketHeaderDef() {
return this.tracePacketHeaderDef;
}
+ /**
+ * Sets the trace packet header definition
+ *
+ * @param tracePacketHeaderDef
+ * the trace packet header definition
+ */
public void setTracePacketHeaderDef(StructDefinition tracePacketHeaderDef) {
this.tracePacketHeaderDef = tracePacketHeaderDef;
}
+ /**
+ * @return the parent stream input reader
+ */
public StreamInputReader getStreamInputReader() {
return this.streamInputReader;
}
+ /**
+ *
+ * @return THe bit buffer that reads the file.
+ */
public BitBuffer getBitBuffer() {
return bitBuffer;
}
// Getters/Setters/Predicates
// ------------------------------------------------------------------------
+ /**
+ * Gets the current event in this stream
+ *
+ * @return the current event in the stream, null if the stream is
+ * finished/empty/malformed
+ */
public EventDefinition getCurrentEvent() {
return this.currentEvent;
}
+ /**
+ * gets the current packet context
+ *
+ * @return the current packet context (size, lost events and such)
+ */
public StructDefinition getCurrentPacketContext() {
return this.packetReader.getStreamPacketContextDef();
}
+ /**
+ * Gets the byte order for a trace
+ *
+ * @return the trace byte order
+ */
public ByteOrder getByteOrder() {
return streamInput.getStream().getTrace().getByteOrder();
}
+ /**
+ * Gets the name of the stream (it's an id and a number)
+ *
+ * @return gets the stream name (it's a number)
+ */
public int getName() {
return this.name;
}
+ /**
+ * Sets the name of the stream
+ *
+ * @param name
+ * the name of the stream, (it's a number)
+ */
public void setName(int name) {
this.name = name;
}
+ /**
+ * Gets the CPU of a stream. It's the same as the one in /proc or running
+ * the asm CPUID instruction
+ *
+ * @return The CPU id (a number)
+ */
public int getCPU() {
return this.packetReader.getCPU();
}
+ /**
+ * Gets the filename of the stream being read
+ * @return The filename of the stream being read
+ */
public String getFilename() {
return streamInput.getFilename();
}
}
}
- /*
+ /*autogenerate javadoc getter setter
* If an event is available, read it.
*/
if (this.packetReader.hasMoreEvents()) {
// do nothing here
}
}
- if( this.packetReader.getCurrentPacket() == null){
+ if (this.packetReader.getCurrentPacket() == null) {
gotoPacket(timestamp);
}
goToNextPacket();
}
+ /**
+ * Seeks the last event of a stream and returns it.
+ */
public void goToLastEvent() {
/*
* Search in the index for the packet to search in.
this.parent = parent;
}
+ /**
+ * Sets the current event in a stream input reader
+ * @param currentEvent the event to set
+ */
public void setCurrentEvent(EventDefinition currentEvent) {
this.currentEvent = currentEvent;
}
// ------------------------------------------------------------------------
/**
- * CTF magic number.
+ * CTF magic number. (sort of looks like CTF CTF CT)
*/
public final static int CTF_MAGIC = 0xC1FC1FC1;
/**
- * TSDL magic number.
+ * TSDL magic number. (sort of looks like TSDL LSDT)
*/
public final static int TSDL_MAGIC = 0x75D11D57;
// Attributes
// ------------------------------------------------------------------------
- // The plug-in ID
+ /**
+ * The plug-in ID
+ */
public static final String PLUGIN_ID = "org.eclipse.linuxtools.ctf"; //$NON-NLS-1$
- // The shared instance
+ /**
+ * The shared instance
+ */
private static Activator fPlugin;
// ------------------------------------------------------------------------
// Constructors
// ------------------------------------------------------------------------
+ /**
+ * Constructor
+ */
public Activator() {
setDefault(this);
}
// Accessors
// ------------------------------------------------------------------------
+ /**
+ * Get the default activator
+ * @return the default activator
+ */
public static Activator getDefault() {
return fPlugin;
}
+ /**
+ * Sets the default activator
+ *
+ * @param plugin the default activator
+ */
private static void setDefault(Activator plugin) {
fPlugin = plugin;
}
// Logging
// ------------------------------------------------------------------------
+ /**
+ * Log a message
+ * @param msg the message to log
+ */
public void log(String msg) {
log(msg, null);
}
+ /**
+ * Log a message with an exception
+ * @param msg the message
+ * @param e the exception
+ */
public void log(String msg, Exception e) {
getLog().log(new Status(IStatus.INFO, PLUGIN_ID, IStatus.OK, msg, e));
}
/**
* <b><u>BitBuffer</u></b>
* <p>
- * TODO Implement me. Please.
+ * A bitwise buffer capable of accessing fields with bit offsets.
*/
public class BitBuffer {
// ------------------------------------------------------------------------
/* default bit width */
+ /** 8 bits to a char */
public static final int BIT_CHAR = 8;
+ /** 16 bits to a short */
public static final int BIT_SHORT = 16;
+ /** 32 bits to an int */
public static final int BIT_INT = 32;
+ /** 32 bits to a float */
public static final int BIT_FLOAT = 32;
+ /** 64 bits to a long */
public static final int BIT_LONG = 64;
// ------------------------------------------------------------------------
// ------------------------------------------------------------------------
// Constructors
// ------------------------------------------------------------------------
-
+ /**
+ * Default constructor, makes a bigendian buffer
+ */
public BitBuffer() {
this(null, ByteOrder.BIG_ENDIAN);
}
+ /**
+ * Constructor, makes a bigendian buffer
+ *
+ * @param buf
+ * the bytebuffer to read
+ */
public BitBuffer(ByteBuffer buf) {
this(buf, ByteOrder.BIG_ENDIAN);
}
+ /**
+ * Constructor that is fully parametrisable
+ *
+ * @param buf
+ * the buffer to read
+ * @param order
+ * the byte order (big endian, little endian, network?)
+ */
public BitBuffer(ByteBuffer buf, ByteOrder order) {
setByteBuffer(buf);
order(order);
// Buffer attributes handling
// ------------------------------------------------------------------------
+ /**
+ * Can this buffer be read for thus amount of bits?
+ *
+ * @param length
+ * the length in bits to read
+ * @return does the buffer have enough room to read the next "length"
+ */
public boolean canRead(int length) {
return canRead(pos, length);
}
+ /**
+ * Can this buffer be read for thus amount of bits?
+ *
+ * @param index
+ * the position in the buffer to read
+ * @param length
+ * the length in bits to read
+ * @return does the buffer have enough room to read the next "length"
+ */
public boolean canRead(int index, int length) {
if (buf == null) {
return false;
return true;
}
+ /**
+ * Sets the order of the buffer.
+ *
+ * @param order
+ * The order of the buffer.
+ */
public void order(ByteOrder order) {
this.byteOrder = order;
if (buf != null) {
}
}
+ /**
+ * Sets the order of the buffer.
+ *
+ * @return The order of the buffer.
+ */
public ByteOrder order() {
return byteOrder;
}
+ /**
+ * Sets the position in the buffer.
+ *
+ * @param order
+ * The position of the buffer.
+ */
public void position(int newPosition) {
this.pos = newPosition;
}
+ /**
+ *
+ * Sets the position in the buffer.
+ *
+ * @return order The position of the buffer.
+ */
public int position() {
return pos;
}
+ /**
+ * Sets the byte buffer
+ *
+ * @param buf
+ * the byte buffer
+ */
public void setByteBuffer(ByteBuffer buf) {
this.buf = buf;
if (buf != null) {
clear();
}
+ /**
+ * Gets the byte buffer
+ *
+ * @return The byte buffer
+ */
public ByteBuffer getByteBuffer() {
return buf;
}
+ /**
+ * Sets the byte order
+ *
+ * @param byteOrder
+ * The byte order
+ */
public void setByteOrder(ByteOrder byteOrder) {
this.byteOrder = byteOrder;
}
+ /**
+ * Gets the byte order
+ *
+ * @return The byte order
+ */
public ByteOrder getByteOrder() {
return byteOrder;
}
+ /**
+ * resets the bitbuffer.
+ */
public void clear() {
position(0);
package org.eclipse.linuxtools.internal.ctf.core.event.metadata;
+/**
+ * Strings generated from the TSDL grammar. Note that they are static final so
+ * they get quarked. See CTF specs for more details
+ *
+ * @author Matthew Khouzam and All
+ *
+ */
public interface CTFStrings {
+ /** None */
public static final String NONE = "none"; //$NON-NLS-1$
+ /** Ascii */
public static final String ASCII = "ASCII"; //$NON-NLS-1$
+ /** UTF8 */
public static final String UTF8 = "UTF8"; //$NON-NLS-1$
+ /** b (for binary like b11010010 */
public static final String BIN = "b"; //$NON-NLS-1$
+ /** Binary */
public static final String BINARY = "binary"; //$NON-NLS-1$
+ /** Octal like o177 */
public static final String OCTAL_CTE = "o"; //$NON-NLS-1$
+ /** Octal like oct177 */
public static final String OCT = "oct"; //$NON-NLS-1$
+ /** Octal like octal177 */
public static final String OCTAL = "octal"; //$NON-NLS-1$
+ /** Pointer (memory address for all the hardcore Java gurus out there)*/
public static final String POINTER = "p"; //$NON-NLS-1$
+ /** X for hex */
public static final String X2 = "X"; //$NON-NLS-1$
+ /** x for hex */
public static final String X = "x"; //$NON-NLS-1$
+ /** hex */
public static final String HEX = "hex"; //$NON-NLS-1$
+ /** Hexadecimal */
public static final String HEXADECIMAL = "hexadecimal"; //$NON-NLS-1$
+ /** unsigned like in 10000ul */
public static final String UNSIGNED_CTE = "u"; //$NON-NLS-1$
+ /** Decimal */
public static final String DEC_CTE = "d"; //$NON-NLS-1$
+ /** Integer like 1000i */
public static final String INT_MOD = "i"; //$NON-NLS-1$
+ /** Decimal */
public static final String DEC = "dec"; //$NON-NLS-1$
+ /** Decimal */
public static final String DECIMAL = "decimal"; //$NON-NLS-1$
+ /** native for byteorders*/
public static final String NATIVE = "native"; //$NON-NLS-1$
+ /** network for byteorders*/
public static final String NETWORK = "network"; //$NON-NLS-1$
+ /** Big endian */
public static final String BE = "be"; //$NON-NLS-1$
+ /** Little endian */
public static final String LE = "le"; //$NON-NLS-1$
+ /** Alignment of a field */
public static final String ALIGN = "align"; //$NON-NLS-1$
+ /** Mantissa digits */
public static final String MANT_DIG = "mant_dig"; //$NON-NLS-1$
+ /** Exponent digits */
public static final String EXP_DIG = "exp_dig"; //$NON-NLS-1$
+ /** Loglevel */
public static final String LOGLEVEL2 = "loglevel"; //$NON-NLS-1$
+ /** Name */
public static final String NAME2 = "name"; //$NON-NLS-1$
+ /** Event context */
public static final String EVENT_CONTEXT = "event.context"; //$NON-NLS-1$
+ /** Fields */
public static final String FIELDS_STRING = "fields"; //$NON-NLS-1$
+ /** context */
public static final String CONTEXT = "context"; //$NON-NLS-1$
+ /** Stream ID */
public static final String STREAM_ID = "stream_id"; //$NON-NLS-1$
+ /** Packet context */
public static final String PACKET_CONTEXT = "packet.context"; //$NON-NLS-1$
+ /** ID */
public static final String ID = "id"; //$NON-NLS-1$
+ /** Packet Header */
public static final String PACKET_HEADER = "packet.header"; //$NON-NLS-1$
+ /** Event Header */
public static final String EVENT_HEADER = "event.header"; //$NON-NLS-1$
+ /** Byte order */
public static final String BYTE_ORDER = "byte_order"; //$NON-NLS-1$
+ /** UUID */
public static final String UUID_STRING = "uuid"; //$NON-NLS-1$
+ /** False */
public static final String FALSE2 = "FALSE"; //$NON-NLS-1$
+ /** False */
public static final String FALSE = "false"; //$NON-NLS-1$
+ /** True */
public static final String TRUE2 = "TRUE"; //$NON-NLS-1$
+ /** True */
public static final String TRUE = "true"; //$NON-NLS-1$
+ /** Minor (Vresion)*/
public static final String MINOR = "minor"; //$NON-NLS-1$
+ /** Major (Vresion)*/
public static final String MAJOR = "major"; //$NON-NLS-1$
-
}
// Constructor
// ------------------------------------------------------------------------
+ /**
+ * Constuctor
+ * @param tree the tree (antlr generated) with the parsed TSDL data.
+ * @param trace the trace containing the places to put all the read metadata
+ */
public IOStructGen(CommonTree tree, CTFTrace trace) {
this.trace = trace;
this.tree = tree;
}
+ /**
+ * Parse the tree and populate the trace defined in the constructor.
+ * @throws ParseException
+ */
public void generate() throws ParseException {
parseRoot(tree);
}
}
}
- if (stream.idIsSet()) {
+ if (stream.isIdSet()) {
if (!trace.packetHeaderIsSet()
|| !trace.getPacketHeader().hasField(CTFStrings.STREAM_ID)) {
throw new ParseException(
String left = concatenateUnaryStrings(leftStrings);
if (left.equals(CTFStrings.ID)) {
- if (stream.idIsSet()) {
+ if (stream.isIdSet()) {
throw new ParseException("stream id already defined"); //$NON-NLS-1$
}
stream.setId(streamID);
} else if (left.equals(CTFStrings.EVENT_HEADER)) {
- if (stream.eventHeaderIsSet()) {
+ if (stream.isEventHeaderSet()) {
throw new ParseException("event.header already defined"); //$NON-NLS-1$
}
stream.setEventHeader((StructDeclaration) eventHeaderDecl);
} else if (left.equals(CTFStrings.EVENT_CONTEXT)) {
- if (stream.eventContextIsSet()) {
+ if (stream.isEventContextSet()) {
throw new ParseException("event.context already defined"); //$NON-NLS-1$
}
stream.setEventContext((StructDeclaration) eventContextDecl);
} else if (left.equals(CTFStrings.PACKET_CONTEXT)) {
- if (stream.packetContextIsSet()) {
+ if (stream.isPacketContextSet()) {
throw new ParseException("packet.context already defined"); //$NON-NLS-1$
}
private static final long serialVersionUID = 7901917601459652080L;
+ /**
+ * Enoty constructor
+ */
public ParseException() {
super();
}
/**
* Constructor
*
- * @param message
+ * @param message (to be sent to logs
*/
public ParseException(String message) {
super(message);
// Getters/Setters/Predicates
// ------------------------------------------------------------------------
+ /**
+ * Sets the id of a stream
+ * @param id the id of a stream
+ */
public void setId(long id) {
this.id = id;
this.events = trace.createEvents(this.id);
}
+ /**
+ * Gets the id of a stream
+ * @return id the id of a stream
+ */
public Long getId() {
return id;
}
- public boolean idIsSet() {
+ /**
+ * Is the id of a stream set
+ * @param Is id the id of a stream set
+ */
+ public boolean isIdSet() {
return id != null;
}
- public boolean eventHeaderIsSet() {
+ /**
+ *
+ * @return is the event header set (timestamp and stuff) (see Ctf Spec)
+ */
+ public boolean isEventHeaderSet() {
return eventHeaderDecl != null;
}
- public boolean eventContextIsSet() {
+ /**
+ *
+ * @return is the event context set (pid and stuff) (see Ctf Spec)
+ */
+ public boolean isEventContextSet() {
return eventContextDecl != null;
}
- public boolean packetContextIsSet() {
+ /**
+ *
+ * @return Is the packet context set (see Ctf Spec)
+ */
+ public boolean isPacketContextSet() {
return packetContextDecl != null;
}
+ /**
+ *
+ * @param eventHeader the current event header for all events in this stream
+ */
public void setEventHeader(StructDeclaration eventHeader) {
this.eventHeaderDecl = eventHeader;
}
+ /**
+ *
+ * @param eventContext the context for all events in this stream
+ */
public void setEventContext(StructDeclaration eventContext) {
this.eventContextDecl = eventContext;
}
+ /**
+ *
+ * @param packetContext the packet context for all packets in this stream
+ */
public void setPacketContext(StructDeclaration packetContext) {
this.packetContextDecl = packetContext;
}
+ /**
+ *
+ * @return the event header declaration in structdeclaration form
+ */
public StructDeclaration getEventHeaderDecl() {
return eventHeaderDecl;
}
+ /**
+ *
+ * @return the event context declaration in structdeclaration form
+ */
public StructDeclaration getEventContextDecl() {
return eventContextDecl;
}
+ /**
+ *
+ * @return the packet context declaration in structdeclaration form
+ */
public StructDeclaration getPacketContextDecl() {
return packetContextDecl;
}
+ /**
+ *
+ * @return the set of all stream inputs for this stream
+ */
public Set<StreamInput> getStreamInputs() {
return inputs;
}
+ /**
+ *
+ * @return the parent trace
+ */
public CTFTrace getTrace() {
return trace;
}
+ /**
+ *
+ * @return all the event declarations for this stream, using the id as a key for the hashmap.
+ */
public HashMap<Long, EventDeclaration> getEvents() {
return events;
}
// Getters/Setters/Predicates
// ------------------------------------------------------------------------
+ /**
+ * Gets the stream the streamInput wrapper is wrapping
+ * @return the stream the streamInput wrapper is wrapping
+ */
public Stream getStream() {
return stream;
}
+ /**
+ * the common streamInput Index
+ * @return the stream input Index
+ */
public StreamInputPacketIndex getIndex() {
return index;
}
+ /**
+ * Gets the filechannel of the streamInput. This is a limited Java ressource.
+ * @return the filechannel
+ */
public FileChannel getFileChannel() {
return fileChannel;
}
+ /**
+ * Gets the filename of the streamInput file.
+ * @return the filename of the streaminput file.
+ */
public String getFilename() {
return file.getName();
}
+ /**
+ * gets the last read timestamp of a stream. (this is not necessarily the last time in the stream.)
+ * @return the last read timestamp
+ */
public long getTimestampEnd() {
return timestampEnd;
}
+ /**
+ * Sets the last read timestamp of a stream. (this is not necessarily the last time in the stream.)
+ * @param timestampEnd the last read timestamp
+ */
public void setTimestampEnd(long timestampEnd) {
this.timestampEnd = timestampEnd;
}
+ /**
+ * useless for streaminputs
+ */
@Override
public String getPath() {
return ""; //$NON-NLS-1$
}
+ /**
+ * Adds the next packet header index entry to the index of a stream input.
+ * @warning slow
+ * @warning can corrupt data if not used properly
+ * @return true if there are more packets to add
+ * @throws CTFReaderException
+ */
public boolean addPacketHeaderIndex() throws CTFReaderException {
long currentPos = 0L;
if (!index.getEntries().isEmpty()) {
// Getters/Setters/Predicates
// ------------------------------------------------------------------------
+ /**
+ * Gets the entries
+ * @return the entries
+ */
public Vector<StreamInputPacketIndexEntry> getEntries() {
return this.entries;
}
+ /**
+ * Gets an iterator to the entries
+ * @return an iterator to the entries
+ */
public ListIterator<StreamInputPacketIndexEntry> listIterator() {
return this.entries.listIterator();
}
+ /**
+ * Gets an iterator to the entries at a given position
+ * @param n the position to get
+ * @return the iterator
+ */
public ListIterator<StreamInputPacketIndexEntry> listIterator(int n) {
return this.entries.listIterator(n);
}
// Attributes
// ------------------------------------------------------------------------
- public static final long INVALID_INDEX = Long.MAX_VALUE;
/**
* Offset of the packet in the file, in bytes
private final CtfTmfTrace ctfTmfTrace;
+ /**
+ * An invalid location
+ */
final public static CtfLocation NULL_LOCATION = new CtfLocation(
CtfLocation.INVALID_LOCATION);
private CtfLocation curLocation;
/**
* Method setLocation.
* @param location ITmfLocation<?>
- * @see org.eclipse.linuxtools.tmf.core.trace.ITmfContext#setLocation(ITmfLocation<?>)
*/
@Override
public void setLocation(final ITmfLocation<?> location) {
*/
public class CtfLocation implements ITmfLocation<Long>, Cloneable {
+ /**
+ * An invalid location
+ */
public static final Long INVALID_LOCATION = -1L;
/**
return this.getName();
}
+ /**
+ * gets the event type for an event name
+ * @param eventName the event name
+ * @return the event type
+ */
public static CtfTmfEventType get(String eventName){
return (CtfTmfEventType) TmfEventTypeManager.getInstance().getType(CONTEXT_ID, eventName);
}
/**
*/
public enum TimestampType {
- FULL_DATE, DAY, NANOS, SECONDS
+ /**
+ * yyyy/mm/dd hh:mm:ss.nnnnnnnnnn
+ */
+ FULL_DATE,
+ /**
+ * hh:mm:ss.nnnnnnnnnn
+ */
+ DAY,
+ /**
+ * nnnnnnnnnnnnnnnnnnnnn ns
+ */
+ NANOS,
+ /**
+ * ssssssssss.nnnnnnnnnn s
+ */
+ SECONDS
}
private TimestampType type;
import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
import org.eclipse.linuxtools.tmf.core.trace.TmfTrace;
+/**
+ * @author Matthew Khouzam
+ * A trace type that reads CTF.
+ */
public class CtfTmfTrace extends TmfTrace<CtfTmfEvent> implements ITmfEventParser<CtfTmfEvent>{
* @param path String
* @param eventType Class<CtfTmfEvent>
* @throws TmfTraceException
- * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#initTrace(IResource, String, Class<CtfTmfEvent>)
*/
@Override
public void initTrace(final IResource resource, final String path, final Class<CtfTmfEvent> eventType)
* Method seekEvent.
* @param location ITmfLocation<?>
* @return ITmfContext
- * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#seekEvent(ITmfLocation<?>)
*/
@Override
public ITmfContext seekEvent(final ITmfLocation<?> location) {
// Clocks
//-------------------------------------------
+ /**
+ * gets the clock offset
+ * @return the clock offset in ns
+ */
public long getOffset(){
if( fTrace != null ) {
return fTrace.getOffset();