Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event')
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/CTFCallsite.java210
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/CTFClock.java133
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/EventDefinition.java299
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/IEventDeclaration.java111
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/io/BitBuffer.java687
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/scope/EventHeaderScope.java67
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/scope/EventHeaderVScope.java60
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/scope/FieldsScope.java61
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/scope/IDefinitionScope.java44
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/scope/LexicalScope.java291
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/scope/PacketHeaderScope.java39
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/scope/RootScope.java65
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/AbstractArrayDefinition.java52
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/ArrayDeclaration.java149
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/ArrayDefinition.java134
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/CompoundDeclaration.java52
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/Declaration.java69
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/Definition.java140
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/Encoding.java32
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/EnumDeclaration.java221
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/EnumDefinition.java108
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/FloatDeclaration.java177
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/FloatDefinition.java84
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/ICompositeDefinition.java42
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/IDeclaration.java81
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/IDefinition.java42
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/IEventHeaderDeclaration.java41
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/ISimpleDatatypeDeclaration.java23
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/IntegerDeclaration.java474
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/IntegerDefinition.java149
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/ScopedDefinition.java185
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/SequenceDeclaration.java145
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/SequenceDefinition.java126
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/SimpleDatatypeDefinition.java61
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/StringDeclaration.java114
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/StringDefinition.java87
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/StructDeclaration.java261
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/StructDefinition.java213
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/VariantDeclaration.java189
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/VariantDefinition.java116
40 files changed, 0 insertions, 5634 deletions
diff --git a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/CTFCallsite.java b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/CTFCallsite.java
deleted file mode 100644
index 79948d5cd6..0000000000
--- a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/CTFCallsite.java
+++ /dev/null
@@ -1,210 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012, 2013 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.linuxtools.ctf.core.event;
-
-/**
- * Callsite information to help with cdt integration
- *
- * @author Matthew Khouzam
- *
- * @since 1.2
- */
-public class CTFCallsite implements Comparable<CTFCallsite> {
-
- private static final long MASK32 = 0x00000000ffffffffL;
-
- /**
- * The event name
- */
- private final String fEventName;
-
- /**
- * the file name of the callsite
- */
- private final String fFileName;
-
- /**
- * the instruction pointer
- */
- private final long fIp;
-
- /**
- * the function name
- */
- private final String fFunctionName;
-
- /**
- * the line number of the callsite
- */
- private final long fLineNumber;
-
- /**
- * The callsite constructor
- *
- * @param en
- * The event name
- * @param func
- * the function name
- * @param ip
- * the instruction pointer of the callsite
- * @param fn
- * the file name of the callsite
- * @param line
- * the line number of the callsite
- */
- public CTFCallsite(String en, String func, long ip, String fn, long line) {
- fEventName = en;
- fFileName = fn;
- fFunctionName = func;
- fIp = ip;
- fLineNumber = line;
- }
-
- /**
- * @return the eventName
- */
- public String getEventName() {
- return fEventName;
- }
-
- /**
- * @return the fileName
- */
- public String getFileName() {
- return fFileName;
- }
-
- /**
- * @return the ip
- */
- public long getIp() {
- return fIp;
- }
-
- /**
- * @return the functionName
- */
- public String getFunctionName() {
- return fFunctionName;
- }
-
- /**
- * @return the lineNumber
- */
- public long getLineNumber() {
- return fLineNumber;
- }
-
- /*
- * The callsites will be sorted by calling addresses. To do this we take IPs
- * (instruction pointers) and compare them. Java only supports signed
- * operation and since memory addresses are unsigned, we will convert the
- * longs into integers that contain the high and low bytes and compare them.
- */
- @Override
- public int compareTo(CTFCallsite o) {
- /*
- * mask32 is 32 zeros followed by 32 ones, when we bitwise and this it
- * will return the lower 32 bits
- */
-
- long other = o.fIp;
- /*
- * To get a high int: we downshift by 32 and bitwise and with the mask
- * to get rid of the sign
- *
- * To get the low int: we bitwise and with the mask.
- */
- long otherHigh = (other >> 32) & MASK32;
- long otherLow = other & MASK32;
- long ownHigh = (fIp >> 32) & MASK32;
- long ownLow = fIp & MASK32;
- /* are the high values different, if so ignore the lower values */
- if (ownHigh > otherHigh) {
- return 1;
- }
- if (ownHigh < otherHigh ) {
- return -1;
- }
- /* the high values are the same, compare the lower values */
- if (ownLow > otherLow) {
- return 1;
- }
- if (ownLow < otherLow) {
- return -1;
- }
- /* the values are identical */
- return 0;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((fEventName == null) ? 0 : fEventName.hashCode());
- result = prime * result + ((fFileName == null) ? 0 : fFileName.hashCode());
- result = prime * result + ((fFunctionName == null) ? 0 : fFunctionName.hashCode());
- result = prime * result + (int) (fIp ^ (fIp >>> 32));
- result = prime * result + (int) (fLineNumber ^ (fLineNumber >>> 32));
- return result;
- }
-
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- CTFCallsite other = (CTFCallsite) obj;
- if (fEventName == null) {
- if (other.fEventName != null) {
- return false;
- }
- } else if (!fEventName.equals(other.fEventName)) {
- return false;
- }
- if (fFileName == null) {
- if (other.fFileName != null) {
- return false;
- }
- } else if (!fFileName.equals(other.fFileName)) {
- return false;
- }
- if (fFunctionName == null) {
- if (other.fFunctionName != null) {
- return false;
- }
- } else if (!fFunctionName.equals(other.fFunctionName)) {
- return false;
- }
- if (fIp != other.fIp) {
- return false;
- }
- if (fLineNumber != other.fLineNumber) {
- return false;
- }
- return true;
- }
-
- @Override
- public String toString() {
- return fFileName + "/" + fFunctionName + ":" + fLineNumber; //$NON-NLS-1$ //$NON-NLS-2$
- }
-}
diff --git a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/CTFClock.java b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/CTFClock.java
deleted file mode 100644
index 7b90cc1421..0000000000
--- a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/CTFClock.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*******************************************************************************
- * 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.linuxtools.ctf.core.event;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Clock description used in CTF traces
- */
-public class CTFClock {
-
- private static final long ONE_BILLION_L = 1000000000L;
- private static final double ONE_BILLION_D = 1000000000.0;
-
- private static final String NAME = "name"; //$NON-NLS-1$
- private static final String FREQ = "freq"; //$NON-NLS-1$
- private static final String OFFSET = "offset"; //$NON-NLS-1$
-
- private long fClockOffset = 0;
- private double fClockScale = 1.0;
- private double fClockAntiScale = 1.0;
-
- /**
- * Field properties.
- */
- private final Map<String, Object> fProperties = new HashMap<>();
- /**
- * Field name.
- */
- private String fName;
- private boolean fIsScaled = false;
-
- /**
- * Default constructor
- */
- public CTFClock() {
- }
-
- /**
- * Method addAttribute.
- *
- * @param key
- * String
- * @param value
- * Object
- */
- public void addAttribute(String key, Object value) {
- fProperties.put(key, value);
- if (key.equals(NAME)) {
- fName = (String) value;
- }
- if (key.equals(FREQ)) {
- /*
- * Long is converted to a double. the double is then dividing
- * another double that double is saved. this is precise as long as
- * the long is under 53 bits long. this is ok as long as we don't
- * have a system with a frequency of > 1 600 000 000 GHz with
- * 200 ppm precision
- */
- fIsScaled = !((Long) getProperty(FREQ)).equals(ONE_BILLION_L);
- fClockScale = ONE_BILLION_D / ((Long) getProperty(FREQ)).doubleValue();
- fClockAntiScale = 1.0 / fClockScale;
-
- }
- if (key.equals(OFFSET)) {
- fClockOffset = (Long) getProperty(OFFSET);
- }
- }
-
- /**
- * Method getName.
- *
- * @return String
- */
- public String getName() {
- return fName;
- }
-
- /**
- * Method getProperty.
- *
- * @param key
- * String
- * @return Object
- */
- public Object getProperty(String key) {
- return fProperties.get(key);
- }
-
- /**
- * @return the clockOffset
- * @since 2.0
- */
- public long getClockOffset() {
- return fClockOffset;
- }
-
- /**
- * @return the clockScale
- * @since 2.0
- */
- public double getClockScale() {
- return fClockScale;
- }
-
- /**
- * @return the clockAntiScale
- * @since 2.0
- */
- public double getClockAntiScale() {
- return fClockAntiScale;
- }
-
- /**
- * @return is the clock in ns or cycles?
- * @since 2.0
- */
- public boolean isClockScaled() {
- return fIsScaled;
- }
-
-}
diff --git a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/EventDefinition.java b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/EventDefinition.java
deleted file mode 100644
index f2fb8ca885..0000000000
--- a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/EventDefinition.java
+++ /dev/null
@@ -1,299 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011-2013 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.linuxtools.ctf.core.event;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.linuxtools.ctf.core.event.scope.IDefinitionScope;
-import org.eclipse.linuxtools.ctf.core.event.scope.LexicalScope;
-import org.eclipse.linuxtools.ctf.core.event.types.Definition;
-import org.eclipse.linuxtools.ctf.core.event.types.StructDeclaration;
-import org.eclipse.linuxtools.ctf.core.event.types.StructDefinition;
-import org.eclipse.linuxtools.ctf.core.trace.CTFStreamInputReader;
-import org.eclipse.linuxtools.internal.ctf.core.event.EventDeclaration;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableList.Builder;
-
-/**
- * Representation of a particular instance of an event.
- */
-public final class EventDefinition implements IDefinitionScope {
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
-
- /**
- * A null event, can be used for testing or poison pilling
- *
- * @since 3.0
- */
- @NonNull
- public static final EventDefinition NULL_EVENT = new EventDefinition(new EventDeclaration(), null, -1L, null, null, null, null);
-
- /**
- * The corresponding event declaration.
- */
- private final IEventDeclaration fDeclaration;
-
- /**
- * The timestamp of the current event.
- */
- private final long fTimestamp;
-
- /**
- * The event context structure definition.
- */
- private final StructDefinition fEventContext;
-
- private final StructDefinition fStreamContext;
-
- private final StructDefinition fPacketContext;
-
- /**
- * The event fields structure definition.
- */
- private final StructDefinition fFields;
-
- /**
- * The StreamInputReader that reads this event definition.
- */
- private final CTFStreamInputReader fStreamInputReader;
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
-
- /**
- * Constructs an event definition.
- *
- * @param declaration
- * The corresponding event declaration
- * @param streamInputReader
- * The SIR from where this EventDef was read
- * @param timestamp
- * event timestamp
- * @param eventContext
- * The event context
- * @param packetContext
- * the packet context
- * @param streamContext
- * the stream context
- * @param fields
- * The event fields
- * @since 3.0
- */
- public EventDefinition(IEventDeclaration declaration,
- CTFStreamInputReader streamInputReader,
- long timestamp,
- StructDefinition streamContext,
- StructDefinition eventContext,
- StructDefinition packetContext,
- StructDefinition fields) {
- fDeclaration = declaration;
- fStreamInputReader = streamInputReader;
- fTimestamp = timestamp;
- fFields = fields;
- fEventContext = eventContext;
- fPacketContext = packetContext;
- fStreamContext = streamContext;
- }
-
- // ------------------------------------------------------------------------
- // Getters/Setters/Predicates
- // ------------------------------------------------------------------------
-
- /**
- * @since 3.0
- */
- @Override
- public LexicalScope getScopePath() {
- String eventName = fDeclaration.getName();
- if (eventName == null) {
- return null;
- }
- LexicalScope myScope = LexicalScope.EVENT.getChild(eventName);
- if (myScope == null) {
- myScope = new LexicalScope(LexicalScope.EVENT, eventName);
- }
- return myScope;
- }
-
- /**
- * Gets the declaration (the form) of the data
- *
- * @return the event declaration
- * @since 2.0
- */
- public IEventDeclaration getDeclaration() {
- return fDeclaration;
- }
-
- /**
- * Gets the fields of a definition
- *
- * @return the fields of a definition in struct form. Can be null.
- */
- public StructDefinition getFields() {
- return fFields;
- }
-
- /**
- * Gets the context of this event without the context of the stream
- *
- * @return the context in struct form
- * @since 1.2
- */
- public StructDefinition getEventContext() {
- return fEventContext;
- }
-
- /**
- * Gets the context of this event within a stream
- *
- * @return the context in struct form
- */
- public StructDefinition 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);
-
- Builder<String> builder = ImmutableList.<String> builder();
- List<Definition> fieldValues = new ArrayList<>();
-
- /* Add fields from the stream */
- for (String fieldName : fStreamContext.getFieldNames()) {
- Definition definition = fStreamContext.getDefinition(fieldName);
- mergedDeclaration.addField(fieldName, definition.getDeclaration());
- builder.add(fieldName);
- fieldValues.add(definition);
- }
-
- ImmutableList<String> fieldNames = builder.build();
- /*
- * 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 {
- builder.add(fieldName);
- fieldValues.add(definition);
- }
- }
- fieldNames = builder.build();
- StructDefinition mergedContext = new StructDefinition(mergedDeclaration, this, "context", //$NON-NLS-1$
- fieldNames,
- fieldValues.toArray(new Definition[fieldValues.size()]));
- return mergedContext;
- }
-
- /**
- * Gets the stream input reader that this event was made by
- *
- * @return the parent
- * @since 3.0
- */
- public CTFStreamInputReader getStreamInputReader() {
- return fStreamInputReader;
- }
-
- /**
- * Gets the context of packet the event is in.
- *
- * @return the packet context
- */
- public StructDefinition 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 fStreamInputReader.getCPU();
- }
-
- /**
- * @return the timestamp
- */
- public long getTimestamp() {
- return fTimestamp;
- }
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
-
- @Override
- public Definition 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: " + fDeclaration.getName() + cr); //$NON-NLS-1$
- retString.append("Timestamp: " + Long.toString(fTimestamp) + cr); //$NON-NLS-1$
-
- if (fEventContext != null) {
- list = fEventContext.getDeclaration().getFieldsList();
-
- for (String field : list) {
- retString.append(field
- + " : " + fEventContext.getDefinition(field).toString() + cr); //$NON-NLS-1$
- }
- }
-
- if (fFields != null) {
- list = fFields.getDeclaration().getFieldsList();
-
- for (String field : list) {
- retString.append(field
- + " : " + fFields.getDefinition(field).toString() + cr); //$NON-NLS-1$
- }
- }
-
- return retString.toString();
- }
-
-}
diff --git a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/IEventDeclaration.java b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/IEventDeclaration.java
deleted file mode 100644
index 6107114716..0000000000
--- a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/IEventDeclaration.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011-2013 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
- *******************************************************************************/
-
-package org.eclipse.linuxtools.ctf.core.event;
-
-import java.util.Set;
-
-import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.linuxtools.ctf.core.event.io.BitBuffer;
-import org.eclipse.linuxtools.ctf.core.event.types.StructDeclaration;
-import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException;
-import org.eclipse.linuxtools.ctf.core.trace.CTFStream;
-import org.eclipse.linuxtools.ctf.core.trace.CTFStreamInputReader;
-
-/**
- * Representation of one type of event. A bit like "int" or "long" but for trace
- * events.
- *
- * @author Matthew Khouzam
- * @since 2.0
- */
-public interface IEventDeclaration {
-
- /**
- * Creates an instance of EventDefinition corresponding to this declaration.
- *
- * @param streamInputReader
- * The StreamInputReader for which this definition is created.
- * @param input
- * the bitbuffer input source
- * @param timestamp
- * The timestamp when the event was taken
- * @return A new EventDefinition.
- * @throws CTFReaderException
- * As a bitbuffer is used to read, it could have wrapped
- * IOExceptions.
- * @since 3.0
- */
- EventDefinition createDefinition(CTFStreamInputReader streamInputReader, @NonNull BitBuffer input, long timestamp) throws CTFReaderException;
-
- /**
- * Gets the name of an event declaration
- *
- * @return the name
- */
- String getName();
-
- /**
- * Gets the fields of an event declaration
- *
- * @return fields the fields in {@link StructDeclaration} format
- */
- StructDeclaration getFields();
-
- /**
- * Gets the context of an event declaration
- *
- * @return context the fields in {@link StructDeclaration} format
- */
- StructDeclaration getContext();
-
- /**
- * Gets the id of an event declaration
- *
- * @return The EventDeclaration ID
- */
- Long getId();
-
- /**
- * Gets the {@link CTFStream} of an event declaration
- *
- * @return the stream
- * @since 3.0
- */
- CTFStream getStream();
-
- /**
- * What is the log level of this event?
- *
- * @return the log level.
- * @since 2.0
- */
- long getLogLevel();
-
- /**
- * Get the {@link Set} of names of the custom CTF attributes.
- *
- * @return The set of custom attributes
- * @since 2.0
- */
- Set<String> getCustomAttributes();
-
- /**
- * Get the value of a given CTF attribute.
- *
- * @param key
- * The CTF attribute name
- * @return the CTF attribute
- * @since 2.0
- */
- String getCustomAttribute(String key);
-
-}
diff --git a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/io/BitBuffer.java b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/io/BitBuffer.java
deleted file mode 100644
index 0556371273..0000000000
--- a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/io/BitBuffer.java
+++ /dev/null
@@ -1,687 +0,0 @@
-/*******************************************************************************.
- * 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 Design and implementation + overhaul
- * Francis Giraldeau - Initial API and implementation
- * Philippe Proulx - Some refinement and optimization
- * Etienne Bergeron <Etienne.Bergeron@gmail.com> - fix zero size read + cleanup
- *******************************************************************************/
-
-package org.eclipse.linuxtools.ctf.core.event.io;
-
-import java.nio.BufferUnderflowException;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-
-import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException;
-
-/**
- * <b><u>BitBuffer</u></b>
- * <p>
- * A bitwise buffer capable of accessing fields with bit offsets.
- *
- * @since 2.0
- */
-public final class BitBuffer {
-
- // ------------------------------------------------------------------------
- // Constants
- // ------------------------------------------------------------------------
-
- /* 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;
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
-
- private final @NonNull ByteBuffer fBuffer;
- private final long fBitCapacity;
-
- /**
- * Bit-buffer's position, maximum value = Integer.MAX_VALUE * 8
- */
- private long fPosition;
- private ByteOrder fByteOrder;
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
- /**
- * Default constructor, makes a big-endian buffer
- */
- @SuppressWarnings("null")
- public BitBuffer() {
- this(ByteBuffer.allocateDirect(0), ByteOrder.BIG_ENDIAN);
- }
-
- /**
- * Constructor, makes a big-endian buffer
- *
- * @param buf
- * the bytebuffer to read
- */
- public BitBuffer(@NonNull ByteBuffer buf) {
- this(buf, ByteOrder.BIG_ENDIAN);
- }
-
- /**
- * Constructor that is fully parameterizable
- *
- * @param buf
- * the buffer to read
- * @param order
- * the byte order (big-endian, little-endian, network?)
- */
- public BitBuffer(@NonNull ByteBuffer buf, ByteOrder order) {
- fBuffer = buf;
- setByteOrder(order);
- resetPosition();
- fBitCapacity = fBuffer.capacity() * BIT_CHAR;
- }
-
- private void resetPosition() {
- fPosition = 0;
- }
-
- // ------------------------------------------------------------------------
- // 'Get' operations on buffer
- // ------------------------------------------------------------------------
-
- /**
- * Relative <i>get</i> method for reading 32-bit integer.
- *
- * Reads next four bytes from the current bit position according to current
- * byte order.
- *
- * @return The int value (signed) read from the buffer
- * @throws CTFReaderException
- * An error occurred reading the long. This exception can be
- * raised if the buffer tries to read out of bounds
- */
- public int getInt() throws CTFReaderException {
- return getInt(BIT_INT, true);
- }
-
- /**
- * Relative <i>get</i> method for reading 64-bit integer.
- *
- * Reads next eight bytes from the current bit position according to current
- * byte order.
- *
- * @return The long value (signed) read from the buffer
- * @throws CTFReaderException
- * An error occurred reading the long. This exception can be
- * raised if the buffer tries to read out of bounds
- * @since 3.0
- */
- public long getLong() throws CTFReaderException {
- return get(BIT_LONG, true);
- }
-
- /**
- * Relative <i>get</i> method for reading long of <i>length</i> bits.
- *
- * Reads <i>length</i> bits starting at the current position. The result is
- * signed extended if <i>signed</i> is true. The current position is
- * increased of <i>length</i> bits.
- *
- * @param length
- * The length in bits of this integer
- * @param signed
- * The sign extended flag
- * @return The long value read from the buffer
- * @throws CTFReaderException
- * An error occurred reading the data. If more than 64 bits at a
- * time are read, or the buffer is read beyond its end, this
- * exception will be raised.
- * @since 3.0
- */
- public long get(int length, boolean signed) throws CTFReaderException {
- if (length > BIT_LONG) {
- throw new CTFReaderException("Cannot read a long longer than 64 bits. Rquested: " + length); //$NON-NLS-1$
- }
- if (length > BIT_INT) {
- final int highShift = length - BIT_INT;
- long a = getInt();
- long b = getInt(highShift, false);
- long retVal;
- /* Cast the signed-extended int into a unsigned int. */
- a &= 0xFFFFFFFFL;
- b &= (1L << highShift) - 1L;
-
- retVal = (fByteOrder == ByteOrder.BIG_ENDIAN) ? ((a << highShift) | b) : ((b << BIT_INT) | a);
- /* sign extend */
- if (signed) {
- int signExtendBits = BIT_LONG - length;
- retVal = (retVal << signExtendBits) >> signExtendBits;
- }
- return retVal;
- }
- long retVal = getInt(length, signed);
- return (signed ? retVal : (retVal & 0xFFFFFFFFL));
- }
-
- /**
- * Relative bulk <i>get</i> method.
- *
- * <p>
- * This method transfers <strong>bytes</strong> from this buffer into the
- * given destination array. This method currently only supports reads
- * aligned to 8 bytes. It is up to the developer to shift the bits in
- * post-processing to do unaligned reads.
- *
- * @param dst
- * the bytes to write to
- * @throws BufferUnderflowException
- * - If there are fewer than length bytes remaining in this
- * buffer
- * @since 3.1
- */
- public void get(@NonNull byte[] dst) {
- fBuffer.position((int) (fPosition / 8));
- fBuffer.get(dst);
- fPosition += dst.length * 8;
- }
-
- /**
- * Relative <i>get</i> method for reading integer of <i>length</i> bits.
- *
- * Reads <i>length</i> bits starting at the current position. The result is
- * signed extended if <i>signed</i> is true. The current position is
- * increased of <i>length</i> bits.
- *
- * @param length
- * The length in bits of this integer
- * @param signed
- * The sign extended flag
- * @return The int value read from the buffer
- * @throws CTFReaderException
- * An error occurred reading the data. When the buffer is read
- * beyond its end, this exception will be raised.
- */
- private int getInt(int length, boolean signed) throws CTFReaderException {
-
- /* Nothing to read. */
- if (length == 0) {
- return 0;
- }
-
- /* Validate that the buffer has enough bits. */
- if (!canRead(length)) {
- throw new CTFReaderException("Cannot read the integer, " + //$NON-NLS-1$
- "the buffer does not have enough remaining space. " + //$NON-NLS-1$
- "Requested:" + length); //$NON-NLS-1$
- }
-
- /* Get the value from the byte buffer. */
- int val = 0;
- boolean gotIt = false;
-
- /*
- * Try a fast read when the position is byte-aligned by using
- * java.nio.ByteBuffer's native methods
- */
- /*
- * A faster alignment detection as the compiler cannot guaranty that pos
- * is always positive.
- */
- if ((fPosition & (BitBuffer.BIT_CHAR - 1)) == 0) {
- switch (length) {
- case BitBuffer.BIT_CHAR:
- // Byte
- val = fBuffer.get((int) (fPosition / 8));
- if (!signed) {
- val = val & 0xff;
- }
- gotIt = true;
- break;
-
- case BitBuffer.BIT_SHORT:
- // Word
- val = fBuffer.getShort((int) (fPosition / 8));
- if (!signed) {
- val = val & 0xffff;
- }
- gotIt = true;
- break;
-
- case BitBuffer.BIT_INT:
- // Double word
- val = fBuffer.getInt((int) (fPosition / 8));
- gotIt = true;
- break;
-
- default:
- break;
- }
- }
-
- /* When not byte-aligned, fall-back to a general decoder. */
- if (!gotIt) {
- // Nothing read yet: use longer methods
- if (fByteOrder == ByteOrder.LITTLE_ENDIAN) {
- val = getIntLE(fPosition, length, signed);
- } else {
- val = getIntBE(fPosition, length, signed);
- }
- }
- fPosition += length;
-
- return val;
- }
-
- private int getIntBE(long index, int length, boolean signed) {
- if ((length <= 0) || (length > BIT_INT)) {
- throw new IllegalArgumentException("Length must be between 1-32 bits"); //$NON-NLS-1$
- }
- long end = index + length;
- int startByte = (int) (index / BIT_CHAR);
- int endByte = (int) ((end + (BIT_CHAR - 1)) / BIT_CHAR);
- int currByte, lshift, cshift, mask, cmask, cache;
- int value = 0;
-
- currByte = startByte;
- cache = fBuffer.get(currByte) & 0xFF;
- boolean isNeg = (cache & (1 << (BIT_CHAR - (index % BIT_CHAR) - 1))) != 0;
- if (signed && isNeg) {
- value = ~0;
- }
- if (startByte == (endByte - 1)) {
- cmask = cache >>> ((BIT_CHAR - (end % BIT_CHAR)) % BIT_CHAR);
- if (((length) % BIT_CHAR) > 0) {
- mask = ~((~0) << length);
- cmask &= mask;
- }
- value <<= length;
- value |= cmask;
- return value;
- }
- cshift = (int) (index % BIT_CHAR);
- if (cshift > 0) {
- mask = ~((~0) << (BIT_CHAR - cshift));
- cmask = cache & mask;
- lshift = BIT_CHAR - cshift;
- value <<= lshift;
- value |= cmask;
- currByte++;
- }
- for (; currByte < (endByte - 1); currByte++) {
- value <<= BIT_CHAR;
- value |= fBuffer.get(currByte) & 0xFF;
- }
- lshift = (int) (end % BIT_CHAR);
- if (lshift > 0) {
- mask = ~((~0) << lshift);
- cmask = fBuffer.get(currByte) & 0xFF;
- cmask >>>= BIT_CHAR - lshift;
- cmask &= mask;
- value <<= lshift;
- value |= cmask;
- } else {
- value <<= BIT_CHAR;
- value |= fBuffer.get(currByte) & 0xFF;
- }
- return value;
- }
-
- private int getIntLE(long index, int length, boolean signed) {
- if ((length <= 0) || (length > BIT_INT)) {
- throw new IllegalArgumentException("Length must be between 1-32 bits"); //$NON-NLS-1$
- }
- long end = index + length;
- int startByte = (int) (index / BIT_CHAR);
- int endByte = (int) ((end + (BIT_CHAR - 1)) / BIT_CHAR);
- int currByte, lshift, cshift, mask, cmask, cache, mod;
- int value = 0;
-
- currByte = endByte - 1;
- cache = fBuffer.get(currByte) & 0xFF;
- mod = (int) (end % BIT_CHAR);
- lshift = (mod > 0) ? mod : BIT_CHAR;
- boolean isNeg = (cache & (1 << (lshift - 1))) != 0;
- if (signed && isNeg) {
- value = ~0;
- }
- if (startByte == (endByte - 1)) {
- cmask = cache >>> (index % BIT_CHAR);
- if (((length) % BIT_CHAR) > 0) {
- mask = ~((~0) << length);
- cmask &= mask;
- }
- value <<= length;
- value |= cmask;
- return value;
- }
- cshift = (int) (end % BIT_CHAR);
- if (cshift > 0) {
- mask = ~((~0) << cshift);
- cmask = cache & mask;
- value <<= cshift;
- value |= cmask;
- currByte--;
- }
- for (; currByte >= (startByte + 1); currByte--) {
- value <<= BIT_CHAR;
- value |= fBuffer.get(currByte) & 0xFF;
- }
- lshift = (int) (index % BIT_CHAR);
- if (lshift > 0) {
- mask = ~((~0) << (BIT_CHAR - lshift));
- cmask = fBuffer.get(currByte) & 0xFF;
- cmask >>>= lshift;
- cmask &= mask;
- value <<= (BIT_CHAR - lshift);
- value |= cmask;
- } else {
- value <<= BIT_CHAR;
- value |= fBuffer.get(currByte) & 0xFF;
- }
- return value;
- }
-
- // ------------------------------------------------------------------------
- // 'Put' operations on buffer
- // ------------------------------------------------------------------------
-
- /**
- * Relative <i>put</i> method to write signed 32-bit integer.
- *
- * Write four bytes starting from current bit position in the buffer
- * according to the current byte order. The current position is increased of
- * <i>length</i> bits.
- *
- * @param value
- * The int value to write
- * @throws CTFReaderException
- * An error occurred writing the data. If the buffer is written
- * beyond its end, this exception will be raised.
- */
- public void putInt(int value) throws CTFReaderException {
- putInt(BIT_INT, value);
- }
-
- /**
- * Relative <i>put</i> method to write <i>length</i> bits integer.
- *
- * Writes <i>length</i> lower-order bits from the provided <i>value</i>,
- * starting from current bit position in the buffer. Sequential bytes are
- * written according to the current byte order. The sign bit is carried to
- * the MSB if signed is true. The sign bit is included in <i>length</i>. The
- * current position is increased of <i>length</i>.
- *
- * @param length
- * The number of bits to write
- * @param value
- * The value to write
- * @throws CTFReaderException
- * An error occurred writing the data. If the buffer is written
- * beyond its end, this exception will be raised.
- */
- public void putInt(int length, int value) throws CTFReaderException {
- final long curPos = fPosition;
-
- if (!canRead(length)) {
- throw new CTFReaderException("Cannot write to bitbuffer, " //$NON-NLS-1$
- + "insufficient space. Requested: " + length); //$NON-NLS-1$
- }
- if (length == 0) {
- return;
- }
- if (fByteOrder == ByteOrder.LITTLE_ENDIAN) {
- putIntLE(curPos, length, value);
- } else {
- putIntBE(curPos, length, value);
- }
- fPosition += length;
- }
-
- private void putIntBE(long index, int length, int value) {
- if ((length <= 0) || (length > BIT_INT)) {
- throw new IllegalArgumentException("Length must be between 1-32 bits"); //$NON-NLS-1$
- }
- long end = index + length;
- int startByte = (int) (index / BIT_CHAR);
- int endByte = (int) ((end + (BIT_CHAR - 1)) / BIT_CHAR);
- int currByte, lshift, cshift, mask, cmask;
- int correctedValue = value;
-
- /*
- * mask v high bits. Works for unsigned and two complement signed
- * numbers which value do not overflow on length bits.
- */
-
- if (length < BIT_INT) {
- correctedValue &= ~(~0 << length);
- }
-
- /* sub byte */
- if (startByte == (endByte - 1)) {
- lshift = (int) ((BIT_CHAR - (end % BIT_CHAR)) % BIT_CHAR);
- mask = ~((~0) << lshift);
- if ((index % BIT_CHAR) > 0) {
- mask |= (~(0)) << (BIT_CHAR - (index % BIT_CHAR));
- }
- cmask = correctedValue << lshift;
- /*
- * low bits are cleared because of left-shift and high bits are
- * already cleared
- */
- cmask &= ~mask;
- int b = fBuffer.get(startByte) & 0xFF;
- fBuffer.put(startByte, (byte) ((b & mask) | cmask));
- return;
- }
-
- /* head byte contains MSB */
- currByte = endByte - 1;
- cshift = (int) (end % BIT_CHAR);
- if (cshift > 0) {
- lshift = BIT_CHAR - cshift;
- mask = ~((~0) << lshift);
- cmask = correctedValue << lshift;
- cmask &= ~mask;
- int b = fBuffer.get(currByte) & 0xFF;
- fBuffer.put(currByte, (byte) ((b & mask) | cmask));
- correctedValue >>>= cshift;
- currByte--;
- }
-
- /* middle byte(s) */
- for (; currByte >= (startByte + 1); currByte--) {
- fBuffer.put(currByte, (byte) correctedValue);
- correctedValue >>>= BIT_CHAR;
- }
- /* end byte contains LSB */
- if ((index % BIT_CHAR) > 0) {
- mask = (~0) << (BIT_CHAR - (index % BIT_CHAR));
- cmask = correctedValue & ~mask;
- int b = fBuffer.get(currByte) & 0xFF;
- fBuffer.put(currByte, (byte) ((b & mask) | cmask));
- } else {
- fBuffer.put(currByte, (byte) correctedValue);
- }
- }
-
- private void putIntLE(long index, int length, int value) {
- if ((length <= 0) || (length > BIT_INT)) {
- throw new IllegalArgumentException("Length must be between 1-32 bits"); //$NON-NLS-1$
- }
- long end = index + length;
- int startByte = (int) (index / BIT_CHAR);
- int endByte = (int) ((end + (BIT_CHAR - 1)) / BIT_CHAR);
- int currByte, lshift, cshift, mask, cmask;
- int correctedValue = value;
-
- /*
- * mask v high bits. Works for unsigned and two complement signed
- * numbers which value do not overflow on length bits.
- */
-
- if (length < BIT_INT) {
- correctedValue &= ~(~0 << length);
- }
-
- /* sub byte */
- if (startByte == (endByte - 1)) {
- lshift = (int) (index % BIT_CHAR);
- mask = ~((~0) << lshift);
- if ((end % BIT_CHAR) > 0) {
- mask |= (~(0)) << (end % BIT_CHAR);
- }
- cmask = correctedValue << lshift;
- /*
- * low bits are cleared because of left-shift and high bits are
- * already cleared
- */
- cmask &= ~mask;
- int b = fBuffer.get(startByte) & 0xFF;
- fBuffer.put(startByte, (byte) ((b & mask) | cmask));
- return;
- }
-
- /* head byte */
- currByte = startByte;
- cshift = (int) (index % BIT_CHAR);
- if (cshift > 0) {
- mask = ~((~0) << cshift);
- cmask = correctedValue << cshift;
- cmask &= ~mask;
- int b = fBuffer.get(currByte) & 0xFF;
- fBuffer.put(currByte, (byte) ((b & mask) | cmask));
- correctedValue >>>= BIT_CHAR - cshift;
- currByte++;
- }
-
- /* middle byte(s) */
- for (; currByte < (endByte - 1); currByte++) {
- fBuffer.put(currByte, (byte) correctedValue);
- correctedValue >>>= BIT_CHAR;
- }
- /* end byte */
- if ((end % BIT_CHAR) > 0) {
- mask = (~0) << (end % BIT_CHAR);
- cmask = correctedValue & ~mask;
- int b = fBuffer.get(currByte) & 0xFF;
- fBuffer.put(currByte, (byte) ((b & mask) | cmask));
- } else {
- fBuffer.put(currByte, (byte) correctedValue);
- }
- }
-
- // ------------------------------------------------------------------------
- // 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 ((fPosition + length) <= fBitCapacity);
- }
-
- /**
- * Sets the order of the buffer.
- *
- * @param order
- * The order of the buffer.
- */
- public void setByteOrder(ByteOrder order) {
- fByteOrder = order;
- fBuffer.order(order);
- }
-
- /**
- * Sets the order of the buffer.
- *
- * @return The order of the buffer.
- */
- public ByteOrder getByteOrder() {
- return fByteOrder;
- }
-
- /**
- * Sets the position in the buffer.
- *
- * @param newPosition
- * The new position of the buffer.
- * @throws CTFReaderException
- * Thrown on out of bounds exceptions
- * @since 3.0
- */
- public void position(long newPosition) throws CTFReaderException {
-
-
- if (newPosition > fBitCapacity) {
- throw new CTFReaderException("Out of bounds exception on a position move, attempting to access position: " + newPosition); //$NON-NLS-1$
- }
- fPosition = newPosition;
- }
-
- /**
- *
- * Sets the position in the buffer.
- *
- * @return order The position of the buffer.
- * @since 3.0
- */
- public long position() {
- return fPosition;
- }
-
- /**
- * Sets the byte buffer
- *
- * @param buf
- * the byte buffer
- */
- @Deprecated
- public void setByteBuffer(ByteBuffer buf) {
- /*
- * to avoid "The method setByteBuffer(ByteBuffer) from the type
- * BitBuffer can be declared as static"
- */
- long data = fPosition;
- fPosition = data;
- throw new UnsupportedOperationException("Bytebuffers are now final"); //$NON-NLS-1$
-
- }
-
- /**
- * Gets the byte buffer
- *
- * @return The byte buffer
- */
- public ByteBuffer getByteBuffer() {
- return fBuffer;
- }
-
- /**
- * Resets the bitbuffer.
- */
- public void clear() {
- resetPosition();
- fBuffer.clear();
- }
-
-}
diff --git a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/scope/EventHeaderScope.java b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/scope/EventHeaderScope.java
deleted file mode 100644
index e5d3d89855..0000000000
--- a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/scope/EventHeaderScope.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2014 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.linuxtools.ctf.core.event.scope;
-
-import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.eclipse.jdt.annotation.Nullable;
-
-/**
- * A lttng specific speedup node (the packet header with ID and V) of a lexical
- * scope
- *
- * @author Matthew Khouzam
- * @since 3.1
- */
-@NonNullByDefault
-public class EventHeaderScope extends LexicalScope {
-
- /**
- * Event header id string
- */
- public static final LexicalScope EVENT_HEADER_ID = new LexicalScope(EVENT_HEADER, "id"); //$NON-NLS-1$
-
- /**
- * Event header v as in variant string
- */
- public static final LexicalScope EVENT_HEADER_V = new EventHeaderVScope(EVENT_HEADER, "v"); //$NON-NLS-1$
-
- /**
- * The scope constructor
- *
- * @param parent
- * The parent node, can be null, but shouldn't
- * @param name
- * the name of the field
- */
- public EventHeaderScope(LexicalScope parent, String name) {
- super(parent, name);
- }
-
- @Override
- @Nullable
- public LexicalScope getChild(String name) {
- if (name.equals(EVENT_HEADER_ID.getName())) {
- return EVENT_HEADER_ID;
- }
- if (name.equals(EVENT_HEADER_V.getName())) {
- return EVENT_HEADER_V;
- }
- return super.getChild(name);
- }
-
- @Override
- public String toString() {
- return "event.header"; //$NON-NLS-1$
- }
-
-}
diff --git a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/scope/EventHeaderVScope.java b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/scope/EventHeaderVScope.java
deleted file mode 100644
index 7b213c2caa..0000000000
--- a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/scope/EventHeaderVScope.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2014 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.linuxtools.ctf.core.event.scope;
-
-import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.eclipse.jdt.annotation.Nullable;
-
-/**
- * A lttng specific speedup node (v variant for event headers) of a lexical
- * scope they normally contain a timestamp
- *
- * @author Matthew Khouzam
- * @since 3.1
- */
-@NonNullByDefault
-public class EventHeaderVScope extends LexicalScope {
-
- /**
- * Packet header v id string
- */
- public static final LexicalScope PACKET_HEADER_V_ID = new LexicalScope(PACKET_HEADER, "id"); //$NON-NLS-1$
- /**
- * Packet header v timestamp string
- */
- public static final LexicalScope PACKET_HEADER_V_TIMESTAMP = new LexicalScope(PACKET_HEADER, "timestamp"); //$NON-NLS-1$
-
- /**
- * The scope constructor
- *
- * @param parent
- * The parent node, can be null, but shouldn't
- * @param name
- * the name of the field
- */
- public EventHeaderVScope(LexicalScope parent, String name) {
- super(parent, name);
- }
-
- @Override
- @Nullable
- public LexicalScope getChild(String name) {
- if (name.equals(PACKET_HEADER_V_TIMESTAMP.getName())) {
- return PACKET_HEADER_V_TIMESTAMP;
- }
- if (name.equals(PACKET_HEADER_V_ID.getName())) {
- return PACKET_HEADER_V_ID;
- }
- return super.getChild(name);
- }
-}
diff --git a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/scope/FieldsScope.java b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/scope/FieldsScope.java
deleted file mode 100644
index 1740cd7bc8..0000000000
--- a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/scope/FieldsScope.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2014 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.linuxtools.ctf.core.event.scope;
-
-import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.eclipse.jdt.annotation.Nullable;
-
-/**
- * A lttng specific speedup node field scope of a lexical scope
- *
- * @author Matthew Khouzam
- * @since 3.1
- */
-@NonNullByDefault
-public class FieldsScope extends LexicalScope {
-
- /**
- * ret field
- */
- public static final LexicalScope FIELDS_RET = new LexicalScope(FIELDS, "_ret"); //$NON-NLS-1$
-
- /**
- * tid field
- */
- public static final LexicalScope FIELDS_TID = new LexicalScope(FIELDS, "_tid"); //$NON-NLS-1$
-
- /**
- * The scope constructor
- *
- * @param parent
- * The parent node, can be null, but shouldn't
- * @param name
- * the name of the field
- */
- public FieldsScope(LexicalScope parent, String name) {
- super(parent, name);
- }
-
- @Override
- @Nullable
- public LexicalScope getChild(String name) {
- if (name.equals(FIELDS_RET.getName())) {
- return FIELDS_RET;
- }
- if (name.equals(FIELDS_TID.getName())) {
- return FIELDS_TID;
- }
- return super.getChild(name);
- }
-
-}
diff --git a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/scope/IDefinitionScope.java b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/scope/IDefinitionScope.java
deleted file mode 100644
index 864a574a1e..0000000000
--- a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/scope/IDefinitionScope.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2013 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.linuxtools.ctf.core.event.scope;
-
-import org.eclipse.linuxtools.ctf.core.event.types.Definition;
-
-/**
- * The scope of a CTF definition. Used for compound types.
- *
- * @version 1.0
- * @author Matthew Khouzam
- * @author Simon Marchi
- * @since 3.0
- */
-public interface IDefinitionScope {
-
- /**
- * Gets the path in a C style for the scope.
- *
- * @return the path
- * @since 3.0
- */
- LexicalScope getScopePath();
-
- /**
- * Looks up in this definition scope.
- *
- * @param lookupPath
- * The path to look up
- * @return The Definition that was read
- */
- // TODO: change to IDefintion
- Definition lookupDefinition(String lookupPath);
-}
diff --git a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/scope/LexicalScope.java b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/scope/LexicalScope.java
deleted file mode 100644
index 6eb9422de5..0000000000
--- a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/scope/LexicalScope.java
+++ /dev/null
@@ -1,291 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2014 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.linuxtools.ctf.core.event.scope;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.eclipse.jdt.annotation.Nullable;
-
-import com.google.common.base.Joiner;
-
-/**
- * A node of a lexical scope
- *
- * @author Matthew Khouzam
- * @since 3.0
- */
-@NonNullByDefault
-public class LexicalScope implements Comparable<LexicalScope> {
- /**
- * Empty string
- *
- * @since 3.0
- */
- public static final LexicalScope ROOT = new RootScope();
-
- /**
- * Trace string
- *
- * @since 3.0
- */
- public static final LexicalScope TRACE = new LexicalScope(ROOT, "trace"); //$NON-NLS-1$
-
- /**
- * Env string
- *
- * @since 3.0
- */
- public static final LexicalScope ENV = new LexicalScope(ROOT, "env"); //$NON-NLS-1$
-
- /**
- * Stream string
- *
- * @since 3.0
- */
- public static final LexicalScope STREAM = new LexicalScope(ROOT, "stream"); //$NON-NLS-1$
-
- /**
- * Event string
- *
- * @since 3.0
- */
- public static final LexicalScope EVENT = new LexicalScope(ROOT, "event"); //$NON-NLS-1$
-
- /**
- * Variant string
- *
- * @since 3.0
- */
- public static final LexicalScope VARIANT = new LexicalScope(ROOT, "variant"); //$NON-NLS-1$
-
- /**
- * packet string
- *
- * @since 3.0
- */
- public static final LexicalScope PACKET = new LexicalScope(ROOT, "packet"); //$NON-NLS-1$
-
- /**
- * Packet header string
- *
- * @since 3.0
- *
- */
- public static final LexicalScope PACKET_HEADER = new PacketHeaderScope();
-
- /**
- * Stream packet scope
- *
- * @since 3.0
- */
- public static final LexicalScope STREAM_PACKET = new LexicalScope(STREAM, "packet"); //$NON-NLS-1$
-
- /**
- * Stream Packet header string
- *
- * @since 3.0
- */
- public static final LexicalScope STREAM_PACKET_CONTEXT = new LexicalScope(STREAM_PACKET, "context"); //$NON-NLS-1$
-
- /**
- * Trace packet scope
- *
- * @since 3.0
- */
- public static final LexicalScope TRACE_PACKET = new LexicalScope(TRACE, "packet"); //$NON-NLS-1$
-
- /**
- * Stream event scope
- *
- * @since 3.0
- */
- public static final LexicalScope STREAM_EVENT = new LexicalScope(STREAM, "event"); //$NON-NLS-1$
-
- /**
- * Trace packet header string
- *
- * @since 3.0
- */
- public static final LexicalScope TRACE_PACKET_HEADER = new LexicalScope(TRACE_PACKET, "header"); //$NON-NLS-1$
-
- /**
- * Stream event context
- *
- * @since 3.0
- */
- public static final LexicalScope STREAM_EVENT_CONTEXT = new LexicalScope(STREAM_EVENT, "context"); //$NON-NLS-1$
-
- /**
- * Stream event header
- *
- * @since 3.0
- */
- public static final LexicalScope STREAM_EVENT_HEADER = new LexicalScope(STREAM_EVENT, "header"); //$NON-NLS-1$
-
- /**
- * Event header
- *
- * @since 3.1
- */
- public static final LexicalScope EVENT_HEADER = new EventHeaderScope(EVENT, "header"); //$NON-NLS-1$
-
- /**
- * Fields in an event
- *
- * @since 3.0
- */
- public static final LexicalScope FIELDS = new FieldsScope(ROOT, "fields"); //$NON-NLS-1$
-
- /**
- * Context of an event
- *
- * @since 3.0
- */
- public static final LexicalScope CONTEXT = new LexicalScope(ROOT, "context"); //$NON-NLS-1$
-
- /**
- * Sorted list of parent paths
- *
- * @since 3.0
- */
- public static final LexicalScope[] PARENT_PATHS = {
- ROOT,
- CONTEXT,
- FIELDS,
- PACKET_HEADER,
- STREAM_EVENT_CONTEXT,
- STREAM_EVENT_HEADER,
- STREAM_PACKET_CONTEXT,
- TRACE_PACKET_HEADER
- };
-
- private int hash = 0;
- private final String fName;
- private final String fPath;
- private final Map<String, LexicalScope> fChildren;
-
- /**
- * The scope constructor
- *
- * @param parent
- * The parent node, can be null, but shouldn't
- * @param name
- * the name of the field
- */
- @SuppressWarnings("null")
- public LexicalScope(@Nullable LexicalScope parent, String name) {
- fName = name;
- if (parent != null) {
- String pathString = Joiner.on('.').skipNulls().join(parent.fPath, parent.getName());
- /*
- * if joiner return null, we get an NPE... so we won't assign fPath
- * to null
- */
- if (pathString.startsWith(".")) { //$NON-NLS-1$
- /*
- * substring throws an exception or returns a string, it won't
- * return null
- */
- pathString = pathString.substring(1);
- }
- fPath = pathString;
- parent.addChild(fName, this);
- } else {
- fPath = ""; //$NON-NLS-1$
- }
- @NonNull
- Map<String, LexicalScope> children =
- Collections.synchronizedMap(new HashMap<String, LexicalScope>());
- fChildren = children;
- }
-
- /**
- * Adds a child lexical scope
- *
- * @param name
- * the name of the child
- * @param child
- * the child
- */
- private void addChild(String name, LexicalScope child) {
- fChildren.put(name, child);
- }
-
- /**
- * Get the name
- *
- * @return the name
- */
- public String getName() {
- return fName;
- }
-
- /**
- * Gets a child of a given name
- *
- * @param name
- * the child
- * @return the scope, can be null
- */
- @Nullable
- public LexicalScope getChild(String name) {
- return fChildren.get(name);
- }
-
- @Override
- public String toString() {
- return (fPath.isEmpty() ? fName : fPath + '.' + fName);
- }
-
- @Override
- public int compareTo(@Nullable LexicalScope other) {
- if (other == null) {
- throw new IllegalArgumentException();
- }
- int comp = fPath.compareTo(other.fPath);
- if (comp == 0) {
- return fName.compareTo(other.fName);
- }
- return comp;
- }
-
- @Override
- public synchronized int hashCode() {
- if (hash == 0) {
- final int prime = 31;
- hash = prime * (prime + fName.hashCode()) + fPath.hashCode();
- }
- return hash;
- }
-
- @Override
- public boolean equals(@Nullable Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- LexicalScope other = (LexicalScope) obj;
- if (!fName.equals(other.fName)) {
- return false;
- }
- return fPath.equals(other.fPath);
- }
-}
diff --git a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/scope/PacketHeaderScope.java b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/scope/PacketHeaderScope.java
deleted file mode 100644
index a47101c6fb..0000000000
--- a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/scope/PacketHeaderScope.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2014 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.linuxtools.ctf.core.event.scope;
-
-import org.eclipse.jdt.annotation.NonNullByDefault;
-
-/**
- * A lttng specific speedup node (the packet header with magic, uuid and stream
- * id ) of a lexical scope the sole reason to have this is to accelerate tostring()
- *
- * @author Matthew Khouzam
- * @since 3.1
- */
-@NonNullByDefault
-public class PacketHeaderScope extends LexicalScope {
-
- /**
- * Constructor
- */
- public PacketHeaderScope() {
- super(PACKET, "header"); //$NON-NLS-1$
- }
-
- @Override
- public String toString() {
- return "packet.header"; //$NON-NLS-1$
- }
-
-}
diff --git a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/scope/RootScope.java b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/scope/RootScope.java
deleted file mode 100644
index ab187df2b7..0000000000
--- a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/scope/RootScope.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2014 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.linuxtools.ctf.core.event.scope;
-
-import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.eclipse.jdt.annotation.Nullable;
-
-/**
- * A lttng specific speedup node a root with accelerated returns for some scopes
- * of a lexical scope
- *
- * @author Matthew Khouzam
- * @since 3.1
- */
-@NonNullByDefault
-public class RootScope extends LexicalScope {
-
- /**
- * The scope constructor
- */
- public RootScope() {
- super(null, ""); //$NON-NLS-1$
- }
-
- @Override
- @Nullable
- public LexicalScope getChild(String name) {
- /*
- * This happens ~40 % of the time
- */
- if (name.equals(EVENT_HEADER.toString())) {
- return EVENT_HEADER;
- }
- /*
- * This happens ~30 % of the time
- */
- if (name.equals(FIELDS.toString())) {
- return FIELDS;
- }
- /*
- * This happens ~30 % of the time
- */
- if (name.equals(CONTEXT.toString())) {
- return CONTEXT;
- }
- /*
- * This happens ~1 % of the time
- */
- if (name.equals(PACKET_HEADER.toString())) {
- return PACKET_HEADER;
- }
- return super.getChild(name);
- }
-
-}
diff --git a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/AbstractArrayDefinition.java b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/AbstractArrayDefinition.java
deleted file mode 100644
index f724f25c97..0000000000
--- a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/AbstractArrayDefinition.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2014 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.linuxtools.ctf.core.event.types;
-
-import java.util.List;
-
-import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.eclipse.jdt.annotation.Nullable;
-import org.eclipse.linuxtools.ctf.core.event.scope.IDefinitionScope;
-
-/**
- * Array definition, used for compound definitions and fixed length strings
- *
- * @author Matthew Khouzam
- * @since 3.1
- */
-@NonNullByDefault
-public abstract class AbstractArrayDefinition extends Definition {
-
- /**
- * Constructor
- *
- * @param declaration
- * the event declaration
- *
- * @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 AbstractArrayDefinition(IDeclaration declaration, @Nullable IDefinitionScope definitionScope, String fieldName) {
- super(declaration, definitionScope, fieldName);
- }
-
- /**
- * Get the defintions, an array is a collection of definitions
- *
- * @return the definitions
- */
- public abstract List<Definition> getDefinitions();
-
-} \ No newline at end of file
diff --git a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/ArrayDeclaration.java b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/ArrayDeclaration.java
deleted file mode 100644
index fcbc3f3c76..0000000000
--- a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/ArrayDeclaration.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2013 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.linuxtools.ctf.core.event.types;
-
-import java.util.List;
-
-import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.linuxtools.ctf.core.event.io.BitBuffer;
-import org.eclipse.linuxtools.ctf.core.event.scope.IDefinitionScope;
-import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException;
-
-import com.google.common.collect.ArrayListMultimap;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableList.Builder;
-import com.google.common.collect.Multimap;
-
-/**
- * A CTF array declaration
- *
- * Arrays are fixed-length. Their length is declared in the type declaration
- * within the meta-data. They contain an array of "inner type" elements, which
- * can refer to any type not containing the type of the array being declared (no
- * circular dependency). The length is the number of elements in an array.
- *
- * @deprecated use
- * {@link org.eclipse.linuxtools.internal.ctf.core.event.types.ArrayDeclaration}
- * @version 1.0
- * @author Matthew Khouzam
- * @author Simon Marchi
- */
-@Deprecated
-public class ArrayDeclaration extends CompoundDeclaration {
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
-
- private final int fLength;
- private final IDeclaration fElemType;
-
- /**
- * <pre>
- * Cache where we can pre-generate the children names
- * Key&colon; parent name
- * Value&colon; children names
- * ex: field &#8594; &lbrace;field&lbrack;0&rbrack;, field&lbrack;1&rbrack;, &hellip; field&lbrack;n&rbrack;&rbrace;
- * </pre>
- *
- * TODO: investigate performance
- */
- private final Multimap<String, String> fChildrenNames = ArrayListMultimap.<String, String> create();
-
- // ------------------------------------------------------------------------
- // 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) {
- fLength = length;
- fElemType = elemType;
- }
-
- // ------------------------------------------------------------------------
- // Getters/Setters/Predicates
- // ------------------------------------------------------------------------
-
- @Override
- public IDeclaration getElementType() {
- return fElemType;
- }
-
- /**
- *
- * @return how many elements in the array
- */
- public int getLength() {
- return fLength;
- }
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
-
- /**
- * @since 3.0
- */
- @Deprecated
- @Override
- public ArrayDefinition createDefinition(IDefinitionScope definitionScope,
- @NonNull String fieldName, BitBuffer input) throws CTFReaderException {
- alignRead(input);
- List<Definition> definitions = read(input, definitionScope, fieldName);
- return new ArrayDefinition(this, definitionScope, fieldName, definitions);
- }
-
- @Override
- public String toString() {
- /* Only used for debugging */
- return "[declaration] array[" + Integer.toHexString(hashCode()) + ']'; //$NON-NLS-1$
- }
-
- @NonNull
- private List<Definition> read(@NonNull BitBuffer input, IDefinitionScope definitionScope, String fieldName) throws CTFReaderException {
- Builder<Definition> definitions = new ImmutableList.Builder<>();
- if (!fChildrenNames.containsKey(fieldName)) {
- for (int i = 0; i < fLength; i++) {
- fChildrenNames.put(fieldName, fieldName + '[' + i + ']');
- }
- }
- List<String> elemNames = (List<String>) fChildrenNames.get(fieldName);
- for (int i = 0; i < fLength; i++) {
- String name = elemNames.get(i);
- if (name == null) {
- throw new IllegalStateException();
- }
- definitions.add(fElemType.createDefinition(definitionScope, name, input));
- }
- @SuppressWarnings("null")
- @NonNull ImmutableList<Definition> ret = definitions.build();
- return ret;
- }
-
- /**
- * @since 3.0
- */
- @Override
- public int getMaximumSize() {
- long val = (long) fLength * fElemType.getMaximumSize();
- return (int) Math.min(Integer.MAX_VALUE, val);
- }
-
-}
diff --git a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/ArrayDefinition.java b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/ArrayDefinition.java
deleted file mode 100644
index 3c0ca255fe..0000000000
--- a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/ArrayDefinition.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2013 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.linuxtools.ctf.core.event.types;
-
-import java.util.List;
-
-import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.eclipse.jdt.annotation.Nullable;
-import org.eclipse.linuxtools.ctf.core.event.scope.IDefinitionScope;
-
-import com.google.common.base.Joiner;
-import com.google.common.collect.ImmutableList;
-
-/**
- * A CTF array definition
- *
- * Arrays are fixed-length. Their length is declared in the type declaration
- * within the meta-data. They contain an array of "inner type" elements, which
- * can refer to any type not containing the type of the array being declared (no
- * circular dependency). The length is the number of elements in an array.
- *
- * @deprecated use {@link AbstractArrayDefinition}
- * @version 1.0
- * @author Matthew Khouzam
- * @author Simon Marchi
- */
-@NonNullByDefault
-@Deprecated
-public final class ArrayDefinition extends AbstractArrayDefinition{
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
-
- private final ImmutableList<Definition> fDefinitions;
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
-
- /**
- * Constructor
- *
- * @param declaration
- * the parent declaration
- * @param definitionScope
- * the parent scope
- * @param fieldName
- * the field name
- * @param definitions
- * the content of the array
- * @since 3.0
- */
- public ArrayDefinition(ArrayDeclaration declaration,
- @Nullable IDefinitionScope definitionScope,
- String fieldName,
- List<Definition> definitions) {
- super(declaration, definitionScope, fieldName);
- @SuppressWarnings("null")
- @NonNull ImmutableList<Definition> list = ImmutableList.copyOf(definitions);
- fDefinitions = list;
-
- }
-
- // ------------------------------------------------------------------------
- // Getters/Setters/Predicates
- // ------------------------------------------------------------------------
-
- @Override
- public List<Definition> getDefinitions() {
- return fDefinitions;
- }
-
- /**
- * Get the element at i
- *
- * @param i the index (cannot be negative)
- * @return The element at I, if I &gt; length, null, if I &lt; 0, the method throws an out of bounds exception
- */
- @Nullable
- public Definition getElem(int i) {
- if (i > fDefinitions.size()) {
- return null;
- }
-
- return fDefinitions.get(i);
- }
-
- @Override
- public ArrayDeclaration getDeclaration() {
- return (ArrayDeclaration) super.getDeclaration();
- }
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
-
- @Override
- public String toString() {
- StringBuilder b = new StringBuilder();
-
- if (getDeclaration().isString()) {
- for (Definition def : fDefinitions) {
- IntegerDefinition character = (IntegerDefinition) def;
-
- if (character.getValue() == 0) {
- break;
- }
-
- b.append(character.toString());
- }
- } else {
- b.append('[');
- Joiner joiner = Joiner.on(", ").skipNulls(); //$NON-NLS-1$
- b.append(joiner.join(fDefinitions));
- b.append(']');
- }
-
- @SuppressWarnings("null")
- @NonNull String ret = b.toString();
- return ret;
- }
-}
diff --git a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/CompoundDeclaration.java b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/CompoundDeclaration.java
deleted file mode 100644
index fc4c0c02c9..0000000000
--- a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/CompoundDeclaration.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2014 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.linuxtools.ctf.core.event.types;
-
-
-/**
- * Parent of sequences and arrays
- *
- * @author Matthew Khouzam
- * @since 3.1
- */
-public abstract class CompoundDeclaration extends Declaration {
-
- /**
- * Get the element type
- *
- * @return the type of element in the array
- */
- public abstract IDeclaration getElementType();
-
- @Override
- public long getAlignment() {
- return getElementType().getAlignment();
- }
-
- /**
- * Sometimes, strings are encoded as an array of 1-byte integers (each one
- * being an UTF-8 byte).
- *
- * @return true if this array is in fact an UTF-8 string. false if it's a
- * "normal" array of generic Definition's.
- */
- public boolean isString(){
- IDeclaration elementType = getElementType();
- if (elementType instanceof IntegerDeclaration) {
- IntegerDeclaration elemInt = (IntegerDeclaration) elementType;
- return elemInt.isCharacter();
- }
- return false;
- }
-
-}
diff --git a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/Declaration.java b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/Declaration.java
deleted file mode 100644
index df30eaf4dc..0000000000
--- a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/Declaration.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2014 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.linuxtools.ctf.core.event.types;
-
-import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.linuxtools.ctf.core.event.io.BitBuffer;
-import org.eclipse.linuxtools.ctf.core.event.scope.IDefinitionScope;
-import org.eclipse.linuxtools.ctf.core.event.scope.LexicalScope;
-import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException;
-
-/**
- * Declaration base, it helps for basic functionality that is often called, so
- * performance is often a high priority in this class
- *
- * @author Matthew Khouzam
- * @since 3.0
- */
-public abstract class Declaration implements IDeclaration {
-
- @Override
- public LexicalScope getPath(IDefinitionScope definitionScope, @NonNull String fieldName) {
- if (definitionScope != null) {
- final LexicalScope parentPath = definitionScope.getScopePath();
- if (parentPath != null) {
- LexicalScope myScope = parentPath.getChild(fieldName);
- if (myScope == null) {
- myScope = new LexicalScope(parentPath, fieldName);
- }
- return myScope;
- }
- }
- LexicalScope child = LexicalScope.ROOT.getChild(fieldName);
- if (child != null) {
- return child;
- }
- return new LexicalScope(LexicalScope.ROOT, fieldName);
- }
-
- /**
- * Offset the buffer position wrt the current alignment.
- *
- * @param input
- * The bitbuffer that is being read
- * @throws CTFReaderException
- * Happens when there is an out of bounds exception
- * @since 3.0
- */
- protected final void alignRead(BitBuffer input) throws CTFReaderException {
- long mask = getAlignment() - 1;
- /*
- * The alignment is a power of 2
- */
- long pos = input.position();
- if ((pos & mask) == 0) {
- return;
- }
- pos = (pos + mask) & ~mask;
- input.position(pos);
- }
-}
diff --git a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/Definition.java b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/Definition.java
deleted file mode 100644
index 46c64d0452..0000000000
--- a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/Definition.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2013 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.linuxtools.ctf.core.event.types;
-
-import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.linuxtools.ctf.core.event.scope.IDefinitionScope;
-import org.eclipse.linuxtools.ctf.core.event.scope.LexicalScope;
-
-/**
- * A CTF definition
- *
- * 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>
- *
- * @version 1.0
- * @author Matthew Khouzam
- * @author Simon Marchi
- */
-public abstract class Definition implements IDefinition {
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
-
- private final String fFieldName;
-
- /** The complete path of this field */
- private final @NonNull LexicalScope fPath;
-
- private final IDefinitionScope fDefinitionScope;
-
- @NonNull
- private final IDeclaration fDeclaration;
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
-
- /**
- * Constructor
- *
- * @param declaration
- * the event declaration
- * @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)
- * @since 3.0
- */
- public Definition(@NonNull IDeclaration declaration, IDefinitionScope definitionScope, @NonNull String fieldName) {
- this(declaration, definitionScope, fieldName, declaration.getPath(definitionScope, fieldName));
- }
-
- /**
- * Constructor This one takes the scope and thus speeds up definition
- * creation
- *
- *
- * @param declaration
- * the event declaration
- *
- * @param definitionScope
- * the definition is in a scope, (normally a struct) what is it?
- *
- * @param fieldName
- * the name of the defintions. it is a field in the parent scope.
- *
- * @param scope
- * the scope
- * @since 3.1
- */
- public Definition(@NonNull IDeclaration declaration, IDefinitionScope definitionScope, @NonNull String fieldName, @NonNull LexicalScope scope) {
- fDeclaration = declaration;
- fDefinitionScope = definitionScope;
- fFieldName = fieldName;
- fPath = scope;
- }
-
- // ------------------------------------------------------------------------
- // Getters
- // ------------------------------------------------------------------------
-
- /**
- * Get the field name in its container.
- *
- * @return The field name
- * @since 2.0
- */
- protected String getFieldName() {
- return fFieldName;
- }
-
- @Override
- public LexicalScope getScopePath() {
- return fPath;
- }
-
- /**
- * Get the definition scope in which this definition is found.
- *
- * The complete path of a definition is thus the path of the definition
- * scope DOT the name of the definition (name of the field in its container)
- *
- * @return The definition scope
- * @since 3.0
- */
- protected IDefinitionScope getDefinitionScope() {
- return fDefinitionScope;
- }
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
-
- @Override
- public IDeclaration getDeclaration() {
- return fDeclaration;
- }
-
- @Override
- public String toString() {
- return fPath.toString() + '[' + Integer.toHexString(hashCode()) + ']';
- }
-}
diff --git a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/Encoding.java b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/Encoding.java
deleted file mode 100644
index a529d1ee6d..0000000000
--- a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/Encoding.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011-2012 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.linuxtools.ctf.core.event.types;
-
-import org.eclipse.jdt.annotation.NonNullByDefault;
-
-/**
- * CTF encoding types
- *
- * @version 1.0
- * @author Matthew Khouzam
- * @author Simon Marchi
- */
-@NonNullByDefault
-public enum Encoding {
- /** UTF-8 encoding */
- UTF8,
- /** Ascii encoding */
- ASCII,
- /** No encoding, maybe not even text */
- NONE
-}
diff --git a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/EnumDeclaration.java b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/EnumDeclaration.java
deleted file mode 100644
index 304cb9ad2f..0000000000
--- a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/EnumDeclaration.java
+++ /dev/null
@@ -1,221 +0,0 @@
-/*******************************************************************************
- * 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.linuxtools.ctf.core.event.types;
-
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.linuxtools.ctf.core.event.io.BitBuffer;
-import org.eclipse.linuxtools.ctf.core.event.scope.IDefinitionScope;
-import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException;
-
-/**
- * A CTF enum declaration.
- *
- * The definition of a enum point basic data type. It will take the data from a
- * trace and store it (and make it fit) as an integer and a string.
- *
- * @version 1.0
- * @author Matthew Khouzam
- * @author Simon Marchi
- */
-public final class EnumDeclaration extends Declaration implements ISimpleDatatypeDeclaration {
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
-
- private final EnumTable fTable = new EnumTable();
- private final IntegerDeclaration fContainerType;
- private final Set<String> fLabels = new HashSet<>();
-
- // ------------------------------------------------------------------------
- // 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) {
- fContainerType = containerType;
- }
-
- // ------------------------------------------------------------------------
- // Getters/Setters/Predicates
- // ------------------------------------------------------------------------
-
- /**
- *
- * @return The container type
- */
- public IntegerDeclaration getContainerType() {
- return fContainerType;
- }
-
- @Override
- public long getAlignment() {
- return this.getContainerType().getAlignment();
- }
-
- /**
- * @since 3.0
- */
- @Override
- public int getMaximumSize() {
- return fContainerType.getMaximumSize();
- }
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
-
- /**
- * @since 3.0
- */
- @Override
- public EnumDefinition createDefinition(IDefinitionScope definitionScope, String fieldName, BitBuffer input) throws CTFReaderException {
- alignRead(input);
- IntegerDefinition value = getContainerType().createDefinition(definitionScope, fieldName, input);
- return new EnumDefinition(this, definitionScope, fieldName, value);
- }
-
- /**
- * Add a value. Do not overlap, this is <em><strong>not</strong></em> 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) {
- fLabels.add(label);
- return fTable.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 fTable.query(value);
- }
-
- /**
- * Gets a set of labels of the enum
- *
- * @return A set of labels of the enum, can be empty but not null
- * @since 3.0
- */
- public Set<String> getLabels() {
- return Collections.unmodifiableSet(fLabels);
- }
-
- /*
- * Maps integer range -> string. A simple list for now, but feel free to
- * optimize it. Babeltrace suggests an interval tree.
- */
- private class EnumTable {
-
- private final List<LabelAndRange> ranges = new LinkedList<>();
-
- public EnumTable() {
- }
-
- public boolean add(long low, long high, String label) {
- LabelAndRange newRange = new LabelAndRange(low, high, label);
-
- for (LabelAndRange r : ranges) {
- if (r.intersects(newRange)) {
- return false;
- }
- }
-
- ranges.add(newRange);
-
- 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 (LabelAndRange r : ranges) {
- if (r.intersects(value)) {
- return r.getLabel();
- }
- }
- return null;
- }
-
- }
-
- private static class LabelAndRange {
-
- private final long low, high;
- private final String fLabel;
-
- /**
- * Get the label
- *
- * @return the label
- */
- public String getLabel() {
- return fLabel;
- }
-
- public LabelAndRange(long low, long high, String str) {
- this.low = low;
- this.high = high;
- this.fLabel = str;
- }
-
- public boolean intersects(long i) {
- return (i >= this.low) && (i <= this.high);
- }
-
- public boolean intersects(LabelAndRange other) {
- return this.intersects(other.low)
- || this.intersects(other.high);
- }
- }
-
- @Override
- public String toString() {
- /* Only used for debugging */
- return "[declaration] enum[" + Integer.toHexString(hashCode()) + ']'; //$NON-NLS-1$
- }
-
-}
diff --git a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/EnumDefinition.java b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/EnumDefinition.java
deleted file mode 100644
index 09f6927f50..0000000000
--- a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/EnumDefinition.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2013 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.linuxtools.ctf.core.event.types;
-
-import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.linuxtools.ctf.core.event.scope.IDefinitionScope;
-
-/**
- * A CTF enum definition.
- *
- * The definition of a enum point basic data type. It will take the data from a
- * trace and store it (and make it fit) as an integer and a string.
- *
- * @version 1.0
- * @author Matthew Khouzam
- * @author Simon Marchi
- */
-public final class EnumDefinition extends SimpleDatatypeDefinition {
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
-
- private final long fIntegerValue;
-
- private final String fValue;
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
-
- /**
- * Constructor
- *
- * @param declaration
- * the parent declaration
- * @param definitionScope
- * the parent scope
- * @param fieldName
- * the field name
- * @param intValue
- * the value of the enum
- * @since 3.0
- */
- public EnumDefinition(@NonNull EnumDeclaration declaration,
- IDefinitionScope definitionScope, @NonNull String fieldName, IntegerDefinition intValue) {
- super(declaration, definitionScope, fieldName);
-
- fIntegerValue = intValue.getValue();
- fValue = declaration.query(fIntegerValue);
- }
-
- // ------------------------------------------------------------------------
- // 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 fValue;
- }
-
- @Override
- public String getStringValue() {
- return getValue();
- }
-
- /**
- * 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.
- */
- @Override
- public Long getIntegerValue() {
- return fIntegerValue;
- }
-
- @Override
- public EnumDeclaration getDeclaration() {
- return (EnumDeclaration) super.getDeclaration();
- }
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
-
- @Override
- public String toString() {
- return "{ value = " + getValue() + //$NON-NLS-1$
- ", container = " + fIntegerValue + //$NON-NLS-1$
- " }"; //$NON-NLS-1$
- }
-}
diff --git a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/FloatDeclaration.java b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/FloatDeclaration.java
deleted file mode 100644
index 084cae691f..0000000000
--- a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/FloatDeclaration.java
+++ /dev/null
@@ -1,177 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2013 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
- *******************************************************************************/
-
-package org.eclipse.linuxtools.ctf.core.event.types;
-
-import java.nio.ByteOrder;
-
-import org.eclipse.linuxtools.ctf.core.event.io.BitBuffer;
-import org.eclipse.linuxtools.ctf.core.event.scope.IDefinitionScope;
-import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException;
-
-/**
- * A CTF float declaration.
- *
- * The declaration of a floating point basic data type.
- *
- * @version 1.0
- * @author Matthew Khouzam
- */
-public final class FloatDeclaration extends Declaration implements ISimpleDatatypeDeclaration {
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
-
- private final int fMantissa;
- private final int fExponent;
- private final ByteOrder fByteOrder;
- private final long fAlignement;
-
- // ------------------------------------------------------------------------
- // 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. Should be &ge; 1
- */
- public FloatDeclaration(int exponent, int mantissa, ByteOrder byteOrder,
- long alignment) {
- fMantissa = mantissa;
- fExponent = exponent;
- fByteOrder = byteOrder;
- fAlignement = Math.max(alignment, 1);
-
- }
-
- // ------------------------------------------------------------------------
- // Getters/Setters/Predicates
- // ------------------------------------------------------------------------
-
- /**
- * @return the mant
- */
- public int getMantissa() {
- return fMantissa;
- }
-
- /**
- * @return the exp
- */
- public int getExponent() {
- return fExponent;
- }
-
- /**
- * @return the byteOrder
- */
- public ByteOrder getByteOrder() {
- return fByteOrder;
- }
-
- @Override
- public long getAlignment() {
- return fAlignement;
- }
-
- /**
- * @since 3.0
- */
- @Override
- public int getMaximumSize() {
- return fMantissa + fExponent + 1;
- }
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
-
- /**
- * @since 3.0
- */
- @Override
- public FloatDefinition createDefinition(IDefinitionScope definitionScope,
- String fieldName, BitBuffer input) throws CTFReaderException {
- ByteOrder byteOrder = input.getByteOrder();
- input.setByteOrder(fByteOrder);
- double value = read(input);
- input.setByteOrder(byteOrder);
- return new FloatDefinition(this, definitionScope, fieldName, value);
- }
-
- @Override
- public String toString() {
- /* Only used for debugging */
- return "[declaration] float[" + Integer.toHexString(hashCode()) + ']'; //$NON-NLS-1$
- }
-
- private double read(BitBuffer input) throws CTFReaderException {
- /* Offset the buffer position wrt the current alignment */
- alignRead(input);
- final int exp = getExponent();
- final int mant = getMantissa();
- double value = Double.NaN;
- if ((exp + mant) == 32) {
- value = readRawFloat32(input, mant, exp);
- } else if ((exp + mant) == 64) {
- value = readRawFloat64(input, mant, exp);
- }
- return value;
- }
-
- private static double readRawFloat32(BitBuffer input, final int manBits,
- final int expBits) throws CTFReaderException {
- long temp = input.get(32, false);
- return createFloat(temp, manBits - 1, expBits);
- }
-
- private static double readRawFloat64(BitBuffer input, final int manBits,
- final int expBits) throws CTFReaderException {
- long temp = input.get(64, false);
- return createFloat(temp, manBits - 1, expBits);
- }
-
- /**
- * Create a float from the raw value, Mathematicians beware.
- *
- * @param rawValue
- * The raw value( up to 64 bits)
- * @param manBits
- * number of bits in the mantissa
- * @param expBits
- * number of bits in the exponent
- */
- private static double createFloat(long rawValue, final int manBits,
- final int expBits) {
- long manShift = 1L << (manBits);
- long manMask = manShift - 1;
- long expMask = (1L << expBits) - 1;
-
- int exp = (int) ((rawValue >> (manBits)) & expMask) + 1;
- long man = (rawValue & manMask);
- final int offsetExponent = exp - (1 << (expBits - 1));
- double expPow = Math.pow(2.0, offsetExponent);
- double ret = man * 1.0f;
- ret /= manShift;
- ret += 1.0;
- ret *= expPow;
- return ret;
- }
-}
diff --git a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/FloatDefinition.java b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/FloatDefinition.java
deleted file mode 100644
index aa6d6db27d..0000000000
--- a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/FloatDefinition.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2013 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
- *******************************************************************************/
-
-package org.eclipse.linuxtools.ctf.core.event.types;
-
-import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.linuxtools.ctf.core.event.scope.IDefinitionScope;
-
-/**
- * A CTF float definition.
- *
- * The definition of a floating point basic data type. It will take the data
- * from a trace and store it (and make it fit) as a double.
- *
- * @version 1.0
- * @author Matthew Khouzam
- * @author Simon Marchi
- */
-public final class FloatDefinition extends Definition {
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
-
- private final double fValue;
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
-
- /**
- * Constructor
- *
- * @param declaration
- * the parent declaration
- * @param definitionScope
- * the parent scope
- * @param fieldName
- * the field name
- * @param value
- * field value
- * @since 3.0
- */
- public FloatDefinition(@NonNull FloatDeclaration declaration,
- IDefinitionScope definitionScope, @NonNull String fieldName, double value) {
- super(declaration, definitionScope, fieldName);
- fValue = value;
- }
-
- // ------------------------------------------------------------------------
- // Getters/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 fValue;
- }
-
- @Override
- public FloatDeclaration getDeclaration() {
- return (FloatDeclaration) super.getDeclaration();
- }
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
-
- @Override
- public String toString() {
- return String.valueOf(fValue);
- }
-}
diff --git a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/ICompositeDefinition.java b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/ICompositeDefinition.java
deleted file mode 100644
index df27c9a067..0000000000
--- a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/ICompositeDefinition.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2014 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.linuxtools.ctf.core.event.types;
-
-import java.util.List;
-
-/**
- * Interface for data definitions containing heterogenous definitions
- * (subfields)
- *
- * @author Matthew Khouzam
- * @since 3.1
- */
-public interface ICompositeDefinition extends IDefinition {
-
- /**
- * Gets the definition of the field
- *
- * @param fieldName
- * the fieldname
- * @return The definitions of all the fields
- */
- Definition getDefinition(String fieldName);
-
- /**
- * Gets an array of the field names
- *
- * @return the field names array
- */
- List<String> getFieldNames();
-
-}
diff --git a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/IDeclaration.java b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/IDeclaration.java
deleted file mode 100644
index 6f0f50712b..0000000000
--- a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/IDeclaration.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2013 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.linuxtools.ctf.core.event.types;
-
-import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.linuxtools.ctf.core.event.io.BitBuffer;
-import org.eclipse.linuxtools.ctf.core.event.scope.IDefinitionScope;
-import org.eclipse.linuxtools.ctf.core.event.scope.LexicalScope;
-import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException;
-
-/**
- * A CTF data type declaration.
- *
- * 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>
- *
- * @version 1.0
- * @author Matthew Khouzam
- * @author Simon Marchi
- */
-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
- * @param input
- * a bitbuffer to read from
- * @return a reference to the definition
- * @throws CTFReaderException
- * error in reading
- * @since 3.0
- */
- Definition createDefinition(IDefinitionScope definitionScope, @NonNull String fieldName, @NonNull BitBuffer input) throws CTFReaderException;
-
- /**
- * Get the path of a definition
- *
- * @param definitionScope
- * the scope of the definition
- * @param fieldName
- * the name of the definition
- * @return the path of the definition
- * @since 3.0
- */
- public @NonNull LexicalScope getPath(IDefinitionScope definitionScope, @NonNull 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
- */
- long getAlignment();
-
- /**
- * The MAXIMUM size of this declaration
- *
- * @return the maximum size
- * @since 3.0
- */
- int getMaximumSize();
-
-}
diff --git a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/IDefinition.java b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/IDefinition.java
deleted file mode 100644
index ef6d2294b2..0000000000
--- a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/IDefinition.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2014 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.linuxtools.ctf.core.event.types;
-
-import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.eclipse.linuxtools.ctf.core.event.scope.LexicalScope;
-
-/**
- * Interface for data definitions. A definition is when a value is given to a
- * declaration
- *
- * @author Matthew Khouzam
- * @since 3.1
- */
-@NonNullByDefault
-public interface IDefinition {
-
- /**
- * Get the complete path of this field.
- *
- * @return The path
- */
- LexicalScope getScopePath();
-
- /**
- * Get the declaration of this definition
- *
- * @return the declaration of a datatype
- */
- IDeclaration getDeclaration();
-
-} \ No newline at end of file
diff --git a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/IEventHeaderDeclaration.java b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/IEventHeaderDeclaration.java
deleted file mode 100644
index f9de437fd7..0000000000
--- a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/IEventHeaderDeclaration.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2014 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.linuxtools.ctf.core.event.types;
-
-import org.eclipse.jdt.annotation.NonNullByDefault;
-
-/**
- * Event header declaration abstract class
- *
- * @author Matthew Khouzam
- * @since 3.1
- */
-@NonNullByDefault
-public interface IEventHeaderDeclaration extends IDeclaration {
- /**
- * The id of an event
- */
- String ID = "id"; //$NON-NLS-1$
- /**
- * The name of a timestamp field
- */
- String TIMESTAMP = "timestamp"; //$NON-NLS-1$
- /**
- * Extended header
- */
- String EXTENDED = "extended"; //$NON-NLS-1$
- /**
- * Compact header (not to be confused with compact vs large)
- */
- String COMPACT = "compact"; //$NON-NLS-1$
-}
diff --git a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/ISimpleDatatypeDeclaration.java b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/ISimpleDatatypeDeclaration.java
deleted file mode 100644
index a67556a696..0000000000
--- a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/ISimpleDatatypeDeclaration.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2014 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.linuxtools.ctf.core.event.types;
-
-/**
- * Common interface for simple CTF data types (which do not contain sub-fields).
- *
- * @author Matthew Khouzam
- * @since 3.1
- */
-public interface ISimpleDatatypeDeclaration {
-
-}
diff --git a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/IntegerDeclaration.java b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/IntegerDeclaration.java
deleted file mode 100644
index 486553f2cb..0000000000
--- a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/IntegerDeclaration.java
+++ /dev/null
@@ -1,474 +0,0 @@
-/*******************************************************************************
- * 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
- * Simon Marchi - Initial API and implementation
- * Marc-Andre Laperle - Add min/maximum for validation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.ctf.core.event.types;
-
-import java.math.BigInteger;
-import java.nio.ByteOrder;
-
-import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.eclipse.jdt.annotation.Nullable;
-import org.eclipse.linuxtools.ctf.core.event.io.BitBuffer;
-import org.eclipse.linuxtools.ctf.core.event.scope.IDefinitionScope;
-import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException;
-
-/**
- * A CTF integer declaration.
- *
- * The declaration of a integer basic data type.
- *
- * @version 1.0
- * @author Matthew Khouzam
- * @author Simon Marchi
- */
-@NonNullByDefault
-public class IntegerDeclaration extends Declaration implements ISimpleDatatypeDeclaration {
-
- // ------------------------------------------------------------------------
- // Helpers
- // ------------------------------------------------------------------------
-
- /**
- * unsigned int 32 bits big endian
- *
- * @since 3.0
- */
- public static final IntegerDeclaration UINT_32B_DECL = new IntegerDeclaration(32, false, ByteOrder.BIG_ENDIAN);
- /**
- * unsigned int 32 bits little endian
- *
- * @since 3.0
- */
- public static final IntegerDeclaration UINT_32L_DECL = new IntegerDeclaration(32, false, ByteOrder.LITTLE_ENDIAN);
- /**
- * signed int 32 bits big endian
- *
- * @since 3.0
- */
- public static final IntegerDeclaration INT_32B_DECL = new IntegerDeclaration(32, true, ByteOrder.BIG_ENDIAN);
- /**
- * signed int 32 bits little endian
- *
- * @since 3.0
- */
- public static final IntegerDeclaration INT_32L_DECL = new IntegerDeclaration(32, true, ByteOrder.LITTLE_ENDIAN);
- /**
- * unsigned int 32 bits big endian
- *
- * @since 3.0
- */
- public static final IntegerDeclaration UINT_64B_DECL = new IntegerDeclaration(64, false, ByteOrder.BIG_ENDIAN);
- /**
- * unsigned int 64 bits little endian
- *
- * @since 3.0
- */
- public static final IntegerDeclaration UINT_64L_DECL = new IntegerDeclaration(64, false, ByteOrder.LITTLE_ENDIAN);
- /**
- * signed int 64 bits big endian
- *
- * @since 3.0
- */
- public static final IntegerDeclaration INT_64B_DECL = new IntegerDeclaration(64, true, ByteOrder.BIG_ENDIAN);
- /**
- * signed int 64 bits little endian
- *
- * @since 3.0
- */
- public static final IntegerDeclaration INT_64L_DECL = new IntegerDeclaration(64, true, ByteOrder.LITTLE_ENDIAN);
- /**
- * unsigned 8 bit int endianness doesn't matter since it's 8 bits (byte)
- *
- * @since 3.0
- */
- public static final IntegerDeclaration UINT_8_DECL = new IntegerDeclaration(8, false, ByteOrder.BIG_ENDIAN);
- /**
- * signed 8 bit int endianness doesn't matter since it's 8 bits (char)
- *
- * @since 3.0
- */
- public static final IntegerDeclaration INT_8_DECL = new IntegerDeclaration(8, true, ByteOrder.BIG_ENDIAN);
- /**
- * Unsigned 5 bit int, used for event headers
- *
- * @since 3.1
- */
- public static final IntegerDeclaration UINT_5B_DECL = new IntegerDeclaration(5, false, ByteOrder.BIG_ENDIAN);
- /**
- * Unsigned 5 bit int, used for event headers
- *
- * @since 3.1
- */
- public static final IntegerDeclaration UINT_5L_DECL = new IntegerDeclaration(5, false, ByteOrder.LITTLE_ENDIAN);
- /**
- * Unsigned 5 bit int, used for event headers
- *
- * @since 3.1
- */
- public static final IntegerDeclaration UINT_27B_DECL = new IntegerDeclaration(27, false, ByteOrder.BIG_ENDIAN);
- /**
- * Unsigned 5 bit int, used for event headers
- *
- * @since 3.1
- */
- public static final IntegerDeclaration UINT_27L_DECL = new IntegerDeclaration(27, false, ByteOrder.LITTLE_ENDIAN);
- /**
- * Unsigned 16 bit int, used for event headers
- *
- * @since 3.1
- */
- public static final IntegerDeclaration UINT_16B_DECL = new IntegerDeclaration(16, false, ByteOrder.BIG_ENDIAN);
- /**
- * Unsigned 16 bit int, used for event headers
- *
- * @since 3.1
- */
- public static final IntegerDeclaration UINT_16L_DECL = new IntegerDeclaration(16, false, ByteOrder.LITTLE_ENDIAN);
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
-
- private final int fLength;
- private final boolean fSigned;
- private final int fBase;
- private final ByteOrder fByteOrder;
- private final Encoding fEncoding;
- private final long fAlignment;
- private final String fClock;
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
-
- /**
- * Factory, some common types cached
- *
- * @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. Should be >= 1
- * @return the integer declaration
- * @since 3.0
- */
- public static IntegerDeclaration createDeclaration(int len, boolean signed, int base,
- @Nullable ByteOrder byteOrder, Encoding encoding, String clock, long alignment) {
- if (encoding.equals(Encoding.NONE) && (alignment == 8) && (clock.equals("")) && base == 10) { //$NON-NLS-1$
- switch (len) {
- case 5:
- if (!signed) {
- if (byteOrder != null && byteOrder.equals(ByteOrder.BIG_ENDIAN)) {
- return UINT_5B_DECL;
- }
- return UINT_5L_DECL;
- }
- break;
- case 8:
- return signed ? INT_8_DECL : UINT_8_DECL;
- case 16:
- if (!signed) {
- if (byteOrder != null && byteOrder.equals(ByteOrder.BIG_ENDIAN)) {
- return UINT_16B_DECL;
- }
- return UINT_16L_DECL;
- }
- break;
- case 27:
- if (!signed) {
- if (byteOrder != null && byteOrder.equals(ByteOrder.BIG_ENDIAN)) {
- return UINT_27B_DECL;
- }
- return UINT_27L_DECL;
- }
- break;
- case 32:
- if (signed) {
- if (byteOrder != null && byteOrder.equals(ByteOrder.BIG_ENDIAN)) {
- return INT_32B_DECL;
- }
- return INT_32L_DECL;
- }
- if (byteOrder != null && byteOrder.equals(ByteOrder.BIG_ENDIAN)) {
- return UINT_32B_DECL;
- }
- return UINT_32L_DECL;
- case 64:
- if (signed) {
- if (byteOrder != null && byteOrder.equals(ByteOrder.BIG_ENDIAN)) {
- return INT_64B_DECL;
- }
- return INT_64L_DECL;
- }
- if (byteOrder != null && byteOrder.equals(ByteOrder.BIG_ENDIAN)) {
- return UINT_64B_DECL;
- }
- return UINT_64L_DECL;
- default:
- }
- }
- return new IntegerDeclaration(len, signed, base, byteOrder, encoding, clock, alignment);
- }
-
- /**
- * Constructor
- *
- * @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. Should be &ge; 1
- */
- private IntegerDeclaration(int len, boolean signed, int base,
- @Nullable ByteOrder byteOrder, Encoding encoding, String clock, long alignment) {
- if (len <= 0 || len == 1 && signed) {
- throw new IllegalArgumentException();
- }
-
- fLength = len;
- fSigned = signed;
- fBase = base;
-
- @SuppressWarnings("null")
- @NonNull
- ByteOrder actualByteOrder = (byteOrder == null ? ByteOrder.nativeOrder() : byteOrder);
- fByteOrder = actualByteOrder;
-
- fEncoding = encoding;
- fClock = clock;
- fAlignment = Math.max(alignment, 1);
- }
-
- private IntegerDeclaration(int len, boolean signed, @Nullable ByteOrder byteOrder) {
- this(len, signed, 10, byteOrder, Encoding.NONE, "", 8); //$NON-NLS-1$
- }
-
- // ------------------------------------------------------------------------
- // Getters/Setters/Predicates
- // ------------------------------------------------------------------------
-
- /**
- * Is the integer signed?
- *
- * @return the is the integer signed
- */
- public boolean isSigned() {
- return fSigned;
- }
-
- /**
- * Get the integer base commonly decimal or hex
- *
- * @return the integer base
- */
- public int getBase() {
- return fBase;
- }
-
- /**
- * Get the byte order
- *
- * @return the byte order
- */
- public ByteOrder getByteOrder() {
- return fByteOrder;
- }
-
- /**
- * Get encoding, chars are 8 bit ints
- *
- * @return the encoding
- */
- public Encoding getEncoding() {
- return fEncoding;
- }
-
- /**
- * Is the integer a character (8 bits and encoded?)
- *
- * @return is the integer a char
- */
- public boolean isCharacter() {
- return (fLength == 8) && (fEncoding != Encoding.NONE);
- }
-
- /**
- * Is the integer an unsigned byte (8 bits and no sign)?
- *
- * @return is the integer an unsigned byte
- * @since 3.1
- */
- public boolean isUnsignedByte() {
- return (fLength == 8) && (!fSigned);
- }
-
- /**
- * Get the length in bits for this integer
- *
- * @return the length of the integer
- */
- public int getLength() {
- return fLength;
- }
-
- @Override
- public long getAlignment() {
- return fAlignment;
- }
-
- /**
- * 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 fClock;
- }
-
- /**
- * @since 3.0
- */
- @Override
- public int getMaximumSize() {
- return fLength;
- }
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
-
- /**
- * @since 3.0
- */
- @Override
- public IntegerDefinition createDefinition(@Nullable IDefinitionScope definitionScope,
- String fieldName, BitBuffer input) throws CTFReaderException {
- ByteOrder byteOrder = input.getByteOrder();
- input.setByteOrder(fByteOrder);
- long value = read(input);
- input.setByteOrder(byteOrder);
- return new IntegerDefinition(this, definitionScope, fieldName, value);
- }
-
- @Override
- public String toString() {
- /* Only used for debugging */
- return "[declaration] integer[" + Integer.toHexString(hashCode()) + ']'; //$NON-NLS-1$
- }
-
- /**
- * Get the maximum value for this integer declaration.
- *
- * @return The maximum value for this integer declaration
- * @since 2.0
- */
- public BigInteger getMaxValue() {
- /*
- * Compute the number of bits able to represent an unsigned number,
- * ignoring sign bit.
- */
- int significantBits = fLength - (fSigned ? 1 : 0);
- /*
- * For a given N significant bits, compute the maximal value which is (1
- * << N) - 1.
- */
-
- @SuppressWarnings("null")
- @NonNull
- BigInteger ret = BigInteger.ONE.shiftLeft(significantBits).subtract(BigInteger.ONE);
- return ret;
- }
-
- /**
- * Get the minimum value for this integer declaration.
- *
- * @return The minimum value for this integer declaration
- * @since 2.0
- */
- public BigInteger getMinValue() {
- if (!fSigned) {
- @SuppressWarnings("null")
- @NonNull
- BigInteger ret = BigInteger.ZERO;
- return ret;
- }
-
- /*
- * Compute the number of bits able to represent an unsigned number,
- * without the sign bit.
- */
- int significantBits = fLength - 1;
- /*
- * For a given N significant bits, compute the minimal value which is -
- * (1 << N).
- */
- @SuppressWarnings("null")
- @NonNull
- BigInteger ret = BigInteger.ONE.shiftLeft(significantBits).negate();
- return ret;
- }
-
- private long read(BitBuffer input) throws CTFReaderException {
- /* Offset the buffer position wrt the current alignment */
- alignRead(input);
-
- boolean signed = isSigned();
- int length = getLength();
- long bits = 0;
-
- /*
- * Is the endianness of this field the same as the endianness of the
- * input buffer? If not, then temporarily set the buffer's endianness to
- * this field's just to read the data
- */
- ByteOrder previousByteOrder = input.getByteOrder();
- if ((getByteOrder() != input.getByteOrder())) {
- input.setByteOrder(getByteOrder());
- }
-
- if (length > 64) {
- throw new CTFReaderException("Cannot read an integer with over 64 bits. Length given: " + length); //$NON-NLS-1$
- }
-
- bits = input.get(length, signed);
-
- /*
- * Put the input buffer's endianness back to original if it was changed
- */
- if (previousByteOrder != input.getByteOrder()) {
- input.setByteOrder(previousByteOrder);
- }
-
- return bits;
- }
-
-}
diff --git a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/IntegerDefinition.java b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/IntegerDefinition.java
deleted file mode 100644
index 15486c7c7e..0000000000
--- a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/IntegerDefinition.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2013 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.linuxtools.ctf.core.event.types;
-
-import java.math.BigInteger;
-
-import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.linuxtools.ctf.core.event.scope.IDefinitionScope;
-
-/**
- * A CTF integer definition.
- *
- * The definition of a integer basic data type. It will take the data from a
- * trace and store it (and make it fit) as a long.
- *
- * @version 1.0
- * @author Matthew Khouzam
- * @author Simon Marchi
- */
-public final class IntegerDefinition extends SimpleDatatypeDefinition {
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
-
- private final long fValue;
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
-
- /**
- * Constructor
- *
- * @param declaration
- * the parent declaration
- * @param definitionScope
- * the parent scope
- * @param fieldName
- * the field name
- * @param value
- * integer value
- * @since 3.0
- */
- public IntegerDefinition(@NonNull IntegerDeclaration declaration,
- IDefinitionScope definitionScope, @NonNull String fieldName, long value) {
- super(declaration, definitionScope, fieldName);
- fValue = value;
- }
-
- // ------------------------------------------------------------------------
- // Getters/Setters/Predicates
- // ------------------------------------------------------------------------
-
- /**
- * Gets the value of the integer
- *
- * @return the value of the integer (in long)
- */
- public long getValue() {
- return fValue;
- }
-
- @Override
- public IntegerDeclaration getDeclaration() {
- return (IntegerDeclaration) super.getDeclaration();
- }
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
-
- @Override
- public Long getIntegerValue() {
- return getValue();
- }
-
- @Override
- public String getStringValue() {
- return this.toString();
- }
-
- @Override
- public String toString() {
- if (getDeclaration().isCharacter()) {
- char c = (char) fValue;
- return Character.toString(c);
- }
- return formatNumber(fValue, getDeclaration().getBase(), getDeclaration().isSigned());
- }
-
- /**
- * Print a numeric value as a string in a given base
- *
- * @param value
- * The value to print as string
- * @param base
- * The base for this value
- * @param signed
- * Is the value signed or not
- * @return formatted number string
- * @since 3.0
- */
- public static final String formatNumber(long value, int base, boolean signed) {
- String s;
- /* Format the number correctly according to the integer's base */
- switch (base) {
- case 2:
- s = "0b" + Long.toBinaryString(value); //$NON-NLS-1$
- break;
- case 8:
- s = "0" + Long.toOctalString(value); //$NON-NLS-1$
- break;
- case 16:
- s = "0x" + Long.toHexString(value); //$NON-NLS-1$
- break;
- case 10:
- default:
- /* For non-standard base, we'll just print it as a decimal number */
- if (!signed && value < 0) {
- /*
- * Since there are no 'unsigned long', handle this case with
- * BigInteger
- */
- BigInteger bigInteger = BigInteger.valueOf(value);
- /*
- * we add 2^64 to the negative number to get the real unsigned
- * value
- */
- bigInteger = bigInteger.add(BigInteger.valueOf(1).shiftLeft(64));
- s = bigInteger.toString();
- } else {
- s = Long.toString(value);
- }
- break;
- }
- return s;
- }
-}
diff --git a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/ScopedDefinition.java b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/ScopedDefinition.java
deleted file mode 100644
index 4519831463..0000000000
--- a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/ScopedDefinition.java
+++ /dev/null
@@ -1,185 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2014 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.linuxtools.ctf.core.event.types;
-
-import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.eclipse.jdt.annotation.Nullable;
-import org.eclipse.linuxtools.ctf.core.event.scope.IDefinitionScope;
-import org.eclipse.linuxtools.ctf.core.event.scope.LexicalScope;
-
-/**
- * Scoped defintion. a defintion where you can lookup various datatypes
- *
- * TODO: replace by default methods and an interface when java 8 is upon us
- *
- * @author Matthew Khouzam
- * @since 3.1
- */
-@NonNullByDefault
-public abstract class ScopedDefinition extends Definition implements IDefinitionScope {
-
- /**
- * Constructor
- *
- * @param declaration
- * the event declaration
- * @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 ScopedDefinition(IDeclaration declaration, @Nullable IDefinitionScope definitionScope, String fieldName) {
- super(declaration, definitionScope, fieldName);
- }
-
- /**
- * Constructor This one takes the scope and thus speeds up definition
- * creation
- *
- * @param declaration
- * the parent declaration
- * @param definitionScope
- * the parent scope
- * @param fieldName
- * the field name
- * @param scope
- * the lexical scope
- * @since 3.1
- */
- public ScopedDefinition(StructDeclaration declaration, @Nullable IDefinitionScope definitionScope, String fieldName, LexicalScope scope) {
- super(declaration, definitionScope, fieldName, scope);
- }
-
- /**
- * Lookup an array in a struct. If the name returns a non-array (like an
- * int) then the method returns null
- *
- * @param name
- * the name of the array
- * @return the array or null.
- */
- public @Nullable AbstractArrayDefinition lookupArrayDefinition(String name) {
- Definition def = lookupDefinition(name);
- return (AbstractArrayDefinition) ((def instanceof AbstractArrayDefinition) ? def : null);
- }
-
- /**
- * Lookup an array in a struct. If the name returns a non-array (like an
- * int) then the method returns null
- *
- * @param name
- * the name of the array
- * @return the array or null.
- * @deprecated use {@link ScopedDefinition#lookupArrayDefinition(String)}
- */
- @Deprecated
- @Nullable
- 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)
- * then the method returns null
- *
- * @param name
- * the name of the enum
- * @return the enum or null if a definition is not found or it does not
- * match the desired datatype.
- */
- @Nullable
- 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) then the method returns null
- *
- * @param name
- * the name of the integer
- * @return the integer or null if a definition is not found or it does not
- * match the desired datatype.
- */
- @Nullable
- 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) then the method returns null
- *
- * @param name
- * the name of the sequence
- * @return the sequence or null if a definition is not found or it does not
- * match the desired datatype.
- * @since 3.0
- * @deprecated use {@link ScopedDefinition#lookupArrayDefinition(String)}
- */
- @Deprecated
- @Nullable
- 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) then the method returns null
- *
- * @param name
- * the name of the string
- * @return the string or null if a definition is not found or it does not
- * match the desired datatype.
- */
- @Nullable
- 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) then the method returns null
- *
- * @param name
- * the name of the struct
- * @return the struct or null if a definition is not found or it does not
- * match the desired datatype.
- */
- @Nullable
- 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) then the method returns null
- *
- * @param name
- * the name of the variant
- * @return the variant or null if a definition is not found or it does not
- * match the desired datatype.
- */
- @Nullable
- public VariantDefinition lookupVariant(String name) {
- Definition def = lookupDefinition(name);
- return (VariantDefinition) ((def instanceof VariantDefinition) ? def : null);
- }
-} \ No newline at end of file
diff --git a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/SequenceDeclaration.java b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/SequenceDeclaration.java
deleted file mode 100644
index 68e0ff7a6c..0000000000
--- a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/SequenceDeclaration.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011-2012 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.linuxtools.ctf.core.event.types;
-
-import java.util.Collection;
-import java.util.List;
-
-import org.eclipse.linuxtools.ctf.core.event.io.BitBuffer;
-import org.eclipse.linuxtools.ctf.core.event.scope.IDefinitionScope;
-import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException;
-
-import com.google.common.collect.ArrayListMultimap;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableList.Builder;
-import com.google.common.collect.Multimap;
-
-/**
- * A CTF sequence declaration.
- *
- * An array where the size is fixed but declared in the trace, unlike array
- * where it is declared with a literal
- * @deprecated use {@link org.eclipse.linuxtools.internal.ctf.core.event.types.SequenceDeclaration}
- * @version 1.0
- * @author Matthew Khouzam
- * @author Simon Marchi
- */
-@Deprecated
-public class SequenceDeclaration extends CompoundDeclaration {
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
-
- private final IDeclaration fElemType;
- private final String fLengthName;
- private final Multimap<String, String> fPaths = ArrayListMultimap.<String, String>create();
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
-
- /**
- * Constructor
- *
- * @param lengthName
- * the name of the field describing the length
- * @param elemType
- * The element type
- */
- public SequenceDeclaration(String lengthName, IDeclaration elemType) {
- fElemType = elemType;
- fLengthName = lengthName;
- }
-
- // ------------------------------------------------------------------------
- // Getters/Setters/Predicates
- // ------------------------------------------------------------------------
-
- @Override
- public IDeclaration getElementType() {
- return fElemType;
- }
-
- /**
- * Gets the name of the length field
- *
- * @return the name of the length field
- */
- public String getLengthName() {
- return fLengthName;
- }
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
-
- /**
- * @since 3.0
- */
- @SuppressWarnings("null") // immutablelist
- @Override
- public SequenceDefinition createDefinition(
- IDefinitionScope definitionScope, String fieldName, BitBuffer input) throws CTFReaderException {
- IDefinition lenDef = null;
-
- if (definitionScope != null) {
- lenDef = definitionScope.lookupDefinition(getLengthName());
- }
-
- 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$
- }
-
- IntegerDefinition lengthDefinition = (IntegerDefinition) lenDef;
-
- if (lengthDefinition.getDeclaration().isSigned()) {
- throw new CTFReaderException("Sequence length must not be signed"); //$NON-NLS-1$
- }
-
- long length = lengthDefinition.getValue();
- if ((length > Integer.MAX_VALUE) || (!input.canRead((int) length * fElemType.getMaximumSize()))) {
- throw new CTFReaderException("Sequence length too long " + length); //$NON-NLS-1$
- }
-
- Collection<String> collection = fPaths.get(fieldName);
- while (collection.size() < length) {
- fPaths.put(fieldName, fieldName + '[' + collection.size() + ']');
- }
- List<String> paths = (List<String>) fPaths.get(fieldName);
- Builder<Definition> definitions = new ImmutableList.Builder<>();
- for (int i = 0; i < length; i++) {
- definitions.add(fElemType.createDefinition(definitionScope, paths.get(i), input));
- }
- return new SequenceDefinition(this, definitionScope, fieldName, definitions.build());
- }
-
- @Override
- public String toString() {
- /* Only used for debugging */
- return "[declaration] sequence[" + Integer.toHexString(hashCode()) + ']'; //$NON-NLS-1$
- }
-
- /**
- * @since 3.0
- */
- @Override
- public int getMaximumSize() {
- return Integer.MAX_VALUE;
- }
-
-}
diff --git a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/SequenceDefinition.java b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/SequenceDefinition.java
deleted file mode 100644
index 3f0a290048..0000000000
--- a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/SequenceDefinition.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2013 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.linuxtools.ctf.core.event.types;
-
-import java.util.List;
-
-import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.linuxtools.ctf.core.event.scope.IDefinitionScope;
-
-import com.google.common.base.Joiner;
-import com.google.common.collect.ImmutableList;
-
-/**
- * A CTF sequence definition (a fixed-size array).
- *
- * An array where the size is fixed but declared in the trace, unlike array
- * where it is declared with a literal
- *
- * @deprecated use {@link AbstractArrayDefinition}
- * @version 1.0
- * @author Matthew Khouzam
- * @author Simon Marchi
- */
-@Deprecated
-public final class SequenceDefinition extends Definition {
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
-
- private final ImmutableList<Definition> fDefinitions;
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
-
- /**
- * Constructor
- *
- * @param declaration
- * the parent declaration
- * @param definitionScope
- * the parent scope
- * @param fieldName
- * the field name
- * @param definitions
- * Definitions
- * @since 3.0
- */
- public SequenceDefinition(@NonNull SequenceDeclaration declaration, IDefinitionScope definitionScope, @NonNull String fieldName, List<Definition> definitions) {
- super(declaration, definitionScope, fieldName);
- fDefinitions = ImmutableList.copyOf(definitions);
- }
-
- // ------------------------------------------------------------------------
- // Getters/Setters/Predicates
- // ------------------------------------------------------------------------
-
- @Override
- public SequenceDeclaration getDeclaration() {
- return (SequenceDeclaration) super.getDeclaration();
- }
-
- /**
- * 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 fDefinitions.size();
- }
-
- /**
- * Get the element at i
- *
- * @param i
- * the index (cannot be negative)
- * @return The element at I, if I &gt; length, null, if I &lt; 0, the method
- * throws an out of bounds exception
- */
- public Definition getElem(int i) {
- if (i > fDefinitions.size()) {
- return null;
- }
- return fDefinitions.get(i);
- }
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
-
- @Override
- public String toString() {
- StringBuilder b = new StringBuilder();
-
- if (getDeclaration().isString()) {
- for (Definition def : fDefinitions) {
- IntegerDefinition character = (IntegerDefinition) def;
-
- if (character.getValue() == 0) {
- break;
- }
-
- b.append(character.toString());
- }
- } else {
- b.append('[');
- Joiner joiner = Joiner.on(", ").skipNulls(); //$NON-NLS-1$
- b.append(joiner.join(fDefinitions));
- b.append(']');
- }
-
- return b.toString();
- }
-}
diff --git a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/SimpleDatatypeDefinition.java b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/SimpleDatatypeDefinition.java
deleted file mode 100644
index 492d19f20c..0000000000
--- a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/SimpleDatatypeDefinition.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2013 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
- *******************************************************************************/
-
-package org.eclipse.linuxtools.ctf.core.event.types;
-
-import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.linuxtools.ctf.core.event.scope.IDefinitionScope;
-
-/**
- * Simple Datatype definition is a datatype that allows the addition of
- * getIntegerValue and getStringValue to a class.
- *
- * @author Matthew Khouzam
- * @since 1.2
- */
-public abstract class SimpleDatatypeDefinition extends Definition {
-
- /**
- * Create a new SimpleDatatypeDefinition
- *
- * @param declaration
- * definition's declaration
- * @param definitionScope
- * The scope of this definition
- * @param fieldName
- * The name of the field matching this definition in the parent
- * scope
- * @since 3.0
- */
- public SimpleDatatypeDefinition(@NonNull IDeclaration declaration, IDefinitionScope definitionScope,
- @NonNull String fieldName) {
- super(declaration, definitionScope, fieldName);
- }
-
- /**
- * Gets the value in integer form
- *
- * @return the integer in a Long, can be null
- */
- public Long getIntegerValue() {
- return null;
- }
-
- /**
- * Gets the value in string form
- *
- * @return the integer in a String, can be null
- */
- public String getStringValue() {
- return null;
- }
-
-}
diff --git a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/StringDeclaration.java b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/StringDeclaration.java
deleted file mode 100644
index 710f75aa4e..0000000000
--- a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/StringDeclaration.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2013 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.linuxtools.ctf.core.event.types;
-
-import org.eclipse.linuxtools.ctf.core.event.io.BitBuffer;
-import org.eclipse.linuxtools.ctf.core.event.scope.IDefinitionScope;
-import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException;
-
-/**
- * A CTF string declaration.
- *
- * Strings are an array of bytes of variable size and are terminated by a '\0'
- * "NULL" character. Their encoding is described in the TSDL meta-data. In
- * absence of encoding attribute information, the default encoding is UTF-8.
- *
- * @version 1.0
- * @author Matthew Khouzam
- * @author Simon Marchi
- */
-public class StringDeclaration extends Declaration {
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
-
- private final Encoding fEncoding;
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
-
- /**
- * Generate a UTF8 string declaration
- */
- public StringDeclaration() {
- fEncoding = Encoding.UTF8;
- }
-
- /**
- * Generate an encoded string declaration
- * @param encoding the encoding, utf8 or ascii
- */
- public StringDeclaration(Encoding encoding) {
- fEncoding = encoding;
- }
-
- // ------------------------------------------------------------------------
- // Getters/Setters/Predicates
- // ------------------------------------------------------------------------
-
- /**
- *
- * @return the character encoding.
- */
- public Encoding getEncoding() {
- return fEncoding;
- }
-
- @Override
- public long getAlignment() {
- // See ctf 4.2.5: Strings are always aligned on byte size.
- return 8;
- }
-
- /**
- * @since 3.0
- */
- @Override
- public int getMaximumSize() {
- return Integer.MAX_VALUE;
- }
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
-
- /**
- * @since 3.0
- */
- @Override
- public StringDefinition createDefinition(IDefinitionScope definitionScope,
- String fieldName, BitBuffer input) throws CTFReaderException {
- String value = read(input);
- return new StringDefinition(this, definitionScope, fieldName, value);
- }
-
- private String read(BitBuffer input) throws CTFReaderException {
- /* Offset the buffer position wrt the current alignment */
- alignRead(input);
-
- StringBuilder sb = new StringBuilder();
- char c = (char) input.get(8, false);
- while (c != 0) {
- sb.append(c);
- c = (char) input.get(8, false);
- }
- return sb.toString();
- }
- @Override
- public String toString() {
- /* Only used for debugging */
- return "[declaration] string[" + Integer.toHexString(hashCode()) + ']'; //$NON-NLS-1$
- }
-
-}
diff --git a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/StringDefinition.java b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/StringDefinition.java
deleted file mode 100644
index 853605248c..0000000000
--- a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/StringDefinition.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2013 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.linuxtools.ctf.core.event.types;
-
-import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.linuxtools.ctf.core.event.scope.IDefinitionScope;
-
-/**
- * A CTF string definition (similar to a C null-terminated byte array).
- *
- * Strings are an array of bytes of variable size and are terminated by a '\0'
- * "NULL" character. Their encoding is described in the TSDL meta-data. In
- * absence of encoding attribute information, the default encoding is UTF-8.
- *
- * @version 1.0
- * @author Matthew Khouzam
- * @author Simon Marchi
- */
-public final class StringDefinition extends Definition {
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
-
- private final String fString;
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
-
- /**
- * Constructor
- *
- * @param declaration
- * the parent declaration
- * @param definitionScope
- * the parent scope
- * @param fieldName
- * the field name
- * @param value
- * The String value
- * @since 3.0
- */
- public StringDefinition(@NonNull StringDeclaration declaration,
- IDefinitionScope definitionScope, @NonNull String fieldName, String value) {
- super(declaration, definitionScope, fieldName);
- fString = value;
- }
-
- // ------------------------------------------------------------------------
- // Getters/Setters/Predicates
- // ------------------------------------------------------------------------
-
- @Override
- public StringDeclaration getDeclaration() {
- return (StringDeclaration) super.getDeclaration();
- }
-
- /**
- * Gets the string (value)
- *
- * @return the string
- */
- public String getValue() {
- return fString;
- }
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
-
- @Override
- public String toString() {
- return '\"' + getValue() + '\"';
- }
-
-}
diff --git a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/StructDeclaration.java b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/StructDeclaration.java
deleted file mode 100644
index a356e8650a..0000000000
--- a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/StructDeclaration.java
+++ /dev/null
@@ -1,261 +0,0 @@
-/*******************************************************************************
- * 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.linuxtools.ctf.core.event.types;
-
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.jdt.annotation.Nullable;
-import org.eclipse.linuxtools.ctf.core.event.io.BitBuffer;
-import org.eclipse.linuxtools.ctf.core.event.scope.IDefinitionScope;
-import org.eclipse.linuxtools.ctf.core.event.scope.LexicalScope;
-import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException;
-
-/**
- * A CTF structure declaration.
- *
- * A structure is similar to a C structure, it is a compound data type that
- * contains other datatypes in fields. they are stored in an hashmap and indexed
- * by names which are strings.
- *
- * @version 1.0
- * @author Matthew Khouzam
- * @author Simon Marchi
- */
-public class StructDeclaration extends Declaration {
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
-
- /** linked list of field names. So fieldName->fieldValue */
- private final @NonNull Map<String, IDeclaration> fFieldMap = new LinkedHashMap<>();
-
- /** maximum bit alignment */
- private long fMaxAlign;
-
- // ------------------------------------------------------------------------
- // 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) {
- fMaxAlign = Math.max(align, 1);
- }
-
- /**
- * Struct declaration constructor
- *
- * @param names
- * the names of all the fields
- * @param declarations
- * all the fields
- * @since 3.0
- */
- public StructDeclaration(String[] names, Declaration[] declarations) {
- fMaxAlign = 1;
-
- for (int i = 0; i < names.length; i++) {
- addField(names[i], declarations[i]);
- }
- }
-
- // ------------------------------------------------------------------------
- // Getters/Setters/Predicates
- // ------------------------------------------------------------------------
-
- /**
- * Get current alignment
- *
- * @return the alignment of the struct and all its fields
- */
- public long getMaxAlign() {
- return fMaxAlign;
- }
-
- /**
- * 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 fFieldMap.containsKey(name);
- }
-
- /**
- * Get the fields of the struct as a map.
- *
- * @return a Map of the fields (key is the name)
- * @since 2.0
- */
- public Map<String, IDeclaration> getFields() {
- return fFieldMap;
- }
-
- /**
- * Get the field declaration corresponding to a field name.
- *
- * @param fieldName
- * The field name
- * @return The declaration of the field, or null if there is no such field.
- * @since 3.1
- */
- @Nullable
- public IDeclaration getField(String fieldName) {
- return fFieldMap.get(fieldName);
- }
-
- /**
- * Gets the field list. Very important since the map of fields does not
- * retain the order of the fields.
- *
- * @return the field list.
- * @since 3.0
- */
- public Iterable<String> getFieldsList() {
- return fFieldMap.keySet();
- }
-
- @Override
- public long getAlignment() {
- return this.fMaxAlign;
- }
-
- /**
- * @since 3.0
- */
- @Override
- public int getMaximumSize() {
- int maxSize = 0;
- for (IDeclaration field : fFieldMap.values()) {
- maxSize += field.getMaximumSize();
- }
- return Math.min(maxSize, Integer.MAX_VALUE);
- }
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
-
- /**
- * @since 3.0
- */
- @Override
- public StructDefinition createDefinition(IDefinitionScope definitionScope,
- String fieldName, BitBuffer input) throws CTFReaderException {
- alignRead(input);
- final Definition[] myFields = new Definition[fFieldMap.size()];
- StructDefinition structDefinition = new StructDefinition(this, definitionScope, fieldName, fFieldMap.keySet(), myFields);
- fillStruct(input, myFields, structDefinition);
- return structDefinition;
- }
-
- /**
- * Create a definition from this declaration. This is a faster constructor
- * as it has a lexical scope and this does not need to look it up.
- *
- * @param definitionScope
- * the definition scope, the parent where the definition will be
- * placed
- * @param fieldScope
- * the scope of the definition
- * @param input
- * a bitbuffer to read from
- * @return a reference to the definition
- * @throws CTFReaderException
- * error in reading
- * @since 3.1
- */
- public StructDefinition createDefinition(IDefinitionScope definitionScope,
- LexicalScope fieldScope, @NonNull BitBuffer input) throws CTFReaderException {
- alignRead(input);
- final Definition[] myFields = new Definition[fFieldMap.size()];
- /*
- * Key set is NOT null
- */
- @SuppressWarnings("null")
- StructDefinition structDefinition = new StructDefinition(this, definitionScope, fieldScope, fieldScope.getName(), fFieldMap.keySet(), myFields);
- fillStruct(input, myFields, structDefinition);
- return structDefinition;
- }
-
- /**
- * 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) {
- fFieldMap.put(name, declaration);
- fMaxAlign = Math.max(fMaxAlign, declaration.getAlignment());
- }
-
- @SuppressWarnings("null")
- private void fillStruct(@NonNull BitBuffer input, final Definition[] myFields, StructDefinition structDefinition) throws CTFReaderException {
- Iterator<Map.Entry<String, IDeclaration>> iter = fFieldMap.entrySet().iterator();
- for (int i = 0; i < fFieldMap.size(); i++) {
- Map.Entry<String, IDeclaration> entry = iter.next();
- myFields[i] = entry.getValue().createDefinition(structDefinition, entry.getKey(), input);
- }
- }
-
- @Override
- public String toString() {
- /* Only used for debugging */
- return "[declaration] struct[" + Integer.toHexString(hashCode()) + ']'; //$NON-NLS-1$
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = (prime * result) + fFieldMap.entrySet().hashCode();
- result = (prime * result) + (int) (fMaxAlign ^ (fMaxAlign >>> 32));
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (!(obj instanceof StructDeclaration)) {
- return false;
- }
- StructDeclaration other = (StructDeclaration) obj;
- if (!fFieldMap.entrySet().equals(other.fFieldMap.entrySet())) {
- return false;
- }
- if (fMaxAlign != other.fMaxAlign) {
- return false;
- }
- return true;
- }
-
-}
diff --git a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/StructDefinition.java b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/StructDefinition.java
deleted file mode 100644
index c3962e8bdf..0000000000
--- a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/StructDefinition.java
+++ /dev/null
@@ -1,213 +0,0 @@
-/*******************************************************************************
- * 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.linuxtools.ctf.core.event.types;
-
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.linuxtools.ctf.core.event.scope.IDefinitionScope;
-import org.eclipse.linuxtools.ctf.core.event.scope.LexicalScope;
-
-import com.google.common.base.Joiner;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableMap.Builder;
-
-/**
- * A CTF structure definition (similar to a C structure).
- *
- * A structure is similar to a C structure, it is a compound data type that
- * contains other datatypes in fields. they are stored in an hashmap and indexed
- * by names which are strings.
- *
- * TODO: move me to internal
- *
- * @version 1.0
- * @author Matthew Khouzam
- * @author Simon Marchi
- */
-public final class StructDefinition extends ScopedDefinition implements ICompositeDefinition {
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
-
- private final ImmutableList<String> fFieldNames;
- private final Definition[] fDefinitions;
- private Map<String, Definition> fDefinitionsMap = null;
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
-
- /**
- * *DEPRECATED* TODO: To remove once we break the API...
- *
- * Not marked with the annotation to not annoy callers using a List, which
- * is still as valid with the new constructor. But the compiler gives an
- * error even though a Iterable is a List too...
- *
- * @param declaration
- * the parent declaration
- * @param definitionScope
- * the parent scope
- * @param structFieldName
- * the field name
- * @param fieldNames
- * the list of fields
- * @param definitions
- * the definitions
- * @since 3.1
- */
- public StructDefinition(@NonNull StructDeclaration declaration,
- IDefinitionScope definitionScope,
- @NonNull String structFieldName,
- List<String> fieldNames,
- Definition[] definitions) {
- this(declaration, definitionScope, structFieldName, (Iterable<String>) fieldNames, definitions);
- }
-
- /**
- * Constructor
- *
- * @param declaration
- * the parent declaration
- * @param definitionScope
- * the parent scope
- * @param structFieldName
- * the field name
- * @param fieldNames
- * the list of fields
- * @param definitions
- * the definitions
- * @since 3.1
- */
- public StructDefinition(@NonNull StructDeclaration declaration,
- IDefinitionScope definitionScope,
- @NonNull String structFieldName,
- Iterable<String> fieldNames,
- Definition[] definitions) {
- super(declaration, definitionScope, structFieldName);
- fFieldNames = ImmutableList.copyOf(fieldNames);
- fDefinitions = definitions;
- if (fFieldNames.isEmpty()) {
- fDefinitionsMap = Collections.EMPTY_MAP;
- }
- }
-
- /**
- * Constructor This one takes the scope and thus speeds up definition
- * creation
- *
- * @param declaration
- * the parent declaration
- * @param definitionScope
- * the parent scope
- * @param scope
- * the scope of this variable
- * @param structFieldName
- * the field name
- * @param fieldNames
- * the list of fields
- * @param definitions
- * the definitions
- * @since 3.1
- */
- public StructDefinition(@NonNull StructDeclaration declaration,
- IDefinitionScope definitionScope, @NonNull LexicalScope scope,
- @NonNull String structFieldName, @NonNull Iterable<String> fieldNames, Definition[] definitions) {
- super(declaration, definitionScope, structFieldName, scope);
- fFieldNames = ImmutableList.copyOf(fieldNames);
- fDefinitions = definitions;
- if (fFieldNames.isEmpty()) {
- fDefinitionsMap = Collections.EMPTY_MAP;
- }
- }
-
- // ------------------------------------------------------------------------
- // Getters/Setters/Predicates
- // ------------------------------------------------------------------------
-
- @Override
- public Definition getDefinition(String fieldName) {
- if (fDefinitionsMap == null) {
- /* Build the definitions map */
- Builder<String, Definition> mapBuilder = new ImmutableMap.Builder<>();
- for (int i = 0; i < fFieldNames.size(); i++) {
- if (fDefinitions[i] != null) {
- mapBuilder.put(fFieldNames.get(i), fDefinitions[i]);
- }
- }
- fDefinitionsMap = mapBuilder.build();
- }
- return fDefinitionsMap.get(fieldName);
- }
-
- @Override
- public List<String> getFieldNames() {
- return fFieldNames;
- }
-
- @Override
- public StructDeclaration getDeclaration() {
- return (StructDeclaration) super.getDeclaration();
- }
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
-
- @Override
- public Definition lookupDefinition(String lookupPath) {
- /*
- * The fields are created in order of appearance, so if a variant or
- * sequence refers to a field that is after it, the field's definition
- * will not be there yet in the hashmap.
- */
- int val = fFieldNames.indexOf(lookupPath);
- if (val != -1) {
- return fDefinitions[val];
- }
- String lookupUnderscored = "_" + lookupPath; //$NON-NLS-1$
- val = fFieldNames.indexOf(lookupUnderscored);
- if (val != -1) {
- return fDefinitions[val];
- }
- return null;
- }
-
- @Override
- public String toString() {
- StringBuilder builder = new StringBuilder();
-
- builder.append("{ "); //$NON-NLS-1$
-
- if (fFieldNames != null) {
- List<String> fields = new LinkedList<>();
- for (String field : fFieldNames) {
- String appendee = field + " = " + lookupDefinition(field).toString(); //$NON-NLS-1$
- fields.add(appendee);
- }
- Joiner joiner = Joiner.on(", ").skipNulls(); //$NON-NLS-1$
- builder.append(joiner.join(fields));
- }
-
- builder.append(" }"); //$NON-NLS-1$
-
- return builder.toString();
- }
-
-}
diff --git a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/VariantDeclaration.java b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/VariantDeclaration.java
deleted file mode 100644
index b32572ca92..0000000000
--- a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/VariantDeclaration.java
+++ /dev/null
@@ -1,189 +0,0 @@
-/*******************************************************************************
- * 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.linuxtools.ctf.core.event.types;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.linuxtools.ctf.core.event.io.BitBuffer;
-import org.eclipse.linuxtools.ctf.core.event.scope.IDefinitionScope;
-import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException;
-
-/**
- * A CTFC variant declaration.
- *
- * A variant is similar to a C union, only taking the minimum size of the types,
- * it is a compound data type that contains other datatypes in fields. they are
- * stored in an hashmap and indexed by names which are strings.
- *
- * @version 1.0
- * @author Matthew Khouzam
- * @author Simon Marchi
- */
-public class VariantDeclaration extends Declaration {
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
-
- private String fTag = null;
- private static final long ALIGNMENT = 1;
- private final Map<String, IDeclaration> fFields = Collections.synchronizedMap(new HashMap<String, IDeclaration>());
- private EnumDefinition fTagDef;
- private IDeclaration fDeclarationToPopulate;
- private IDefinitionScope fPrevDefinitionScope;
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
-
- /**
- * Constructor
- */
- public VariantDeclaration() {
- }
-
- // ------------------------------------------------------------------------
- // Getters/Setters/Predicates
- // ------------------------------------------------------------------------
-
- /**
- * @return Does the variant have a tag
- */
- public boolean isTagged() {
- return fTag != 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 fFields.containsKey(fieldTag);
- }
-
- /**
- * Sets the tag in a variant
- *
- * @param tag
- * the tag
- */
- public void setTag(String tag) {
- fTag = tag;
- fTagDef = null;
- }
-
- /**
- * Gets current variant tag
- *
- * @return the variant tag.
- */
- public String getTag() {
- return fTag;
- }
-
- /**
- * Gets the fields of the variant
- *
- * @return the fields of the variant
- * @since 2.0
- */
- public Map<String, IDeclaration> getFields() {
- return this.fFields;
- }
-
- @Override
- public long getAlignment() {
- return ALIGNMENT;
- }
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
-
- /**
- * @since 3.0
- */
- @Override
- public VariantDefinition createDefinition(IDefinitionScope definitionScope,
- String fieldName, BitBuffer input) throws CTFReaderException {
- alignRead(input);
- if (fPrevDefinitionScope != definitionScope) {
- fTagDef = null;
- fPrevDefinitionScope = definitionScope;
- }
- EnumDefinition tagDef = fTagDef;
- if (tagDef == null) {
- Definition def = definitionScope.lookupDefinition(fTag);
- tagDef = (EnumDefinition) ((def instanceof EnumDefinition) ? def : null);
- }
- if (tagDef == null) {
- throw new CTFReaderException("Tag is not defined " + fTag); //$NON-NLS-1$
- }
- String varFieldName = tagDef.getStringValue();
- fDeclarationToPopulate = fFields.get(varFieldName);
- if (fDeclarationToPopulate == null) {
- throw new CTFReaderException("Unknown enum selector for variant " + //$NON-NLS-1$
- definitionScope.getScopePath().toString());
- }
- Definition fieldValue = fDeclarationToPopulate.createDefinition(definitionScope, fieldName, input);
- return new VariantDefinition(this, definitionScope, varFieldName, fieldName, fieldValue);
- }
-
- /**
- * Add a field to this CTF Variant
- *
- * @param fieldTag
- * The tag of the new field
- * @param declaration
- * The Declaration of this new field
- */
- public void addField(String fieldTag, IDeclaration declaration) {
- fFields.put(fieldTag, declaration);
- }
-
- /**
- * gets the tag definition
- *
- * @return the fTagDef
- * @since 3.0
- */
- public EnumDefinition getTagDef() {
- return fTagDef;
- }
-
- /**
- * @since 3.0
- */
- @Override
- public int getMaximumSize() {
- Collection<IDeclaration> values = fFields.values();
- int maxSize = 0;
- for (IDeclaration field : values) {
- maxSize = Math.max(maxSize, field.getMaximumSize());
- }
- return maxSize;
- }
-
- @Override
- public String toString() {
- /* Only used for debugging */
- return "[declaration] variant[" + Integer.toHexString(hashCode()) + ']'; //$NON-NLS-1$
- }
-
-}
diff --git a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/VariantDefinition.java b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/VariantDefinition.java
deleted file mode 100644
index 6302f863f6..0000000000
--- a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/VariantDefinition.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*******************************************************************************
- * 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.linuxtools.ctf.core.event.types;
-
-import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.linuxtools.ctf.core.event.scope.IDefinitionScope;
-
-/**
- * A CTF variant definition (similar to a C union).
- *
- * A variant is similar to a C union, only taking the minimum size of the types,
- * it is a compound data type that contains other datatypes in fields. they are
- * stored in an hashmap and indexed by names which are strings.
- *
- * @version 1.0
- * @author Matthew Khouzam
- * @author Simon Marchi
- */
-public final class VariantDefinition extends ScopedDefinition {
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
-
- private final Definition fDefinition;
- private final String fCurrentField;
- private final String fFieldName;
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
-
- /**
- * Constructor
- *
- * @param declaration
- * the parent declaration
- * @param definitionScope
- * the parent scope
- * @param selectedField
- * the selected field
- * @param fieldName
- * the field name
- * @param fieldValue
- * the field value
- * @since 3.0
- */
- public VariantDefinition(@NonNull VariantDeclaration declaration,
- IDefinitionScope definitionScope, String selectedField, @NonNull String fieldName, Definition fieldValue) {
- super(declaration, definitionScope, fieldName);
-
- fFieldName = fieldName;
- fCurrentField = selectedField;
- fDefinition = fieldValue;
-
- }
-
- // ------------------------------------------------------------------------
- // Getters/Setters/Predicates
- // ------------------------------------------------------------------------
-
- @Override
- public VariantDeclaration getDeclaration() {
- return (VariantDeclaration) super.getDeclaration();
- }
-
- /**
- * Get the current field name
- *
- * @return the current field name
- */
- public String getCurrentFieldName() {
- return fCurrentField;
- }
-
- /**
- * Get the current field
- *
- * @return the current field
- */
- public Definition getCurrentField() {
- return fDefinition;
- }
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
-
- @Override
- public Definition lookupDefinition(String lookupPath) {
- if (lookupPath == null) {
- return null;
- }
- if (lookupPath.equals(fFieldName)) {
- return fDefinition;
- }
- return getDefinitionScope().lookupDefinition(lookupPath);
- }
-
- @Override
- public String toString() {
- return "{ " + getCurrentFieldName() + //$NON-NLS-1$
- " = " + getCurrentField() + //$NON-NLS-1$
- " }"; //$NON-NLS-1$
- }
-}

Back to the top