aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Khouzam2012-04-19 18:17:45 (EDT)
committerMatthew Khouzam2012-05-01 09:47:44 (EDT)
commitf4ecc41d065ccdd894bf815d854836313cb3f0a5 (patch)
treefd28cc4ec34c413a669bd0f98d6b8ed065db44f9
parentebc5d85c23dec4d566758870e6e8b99c42ffb3bf (diff)
downloadorg.eclipse.linuxtools-f4ecc41d065ccdd894bf815d854836313cb3f0a5.zip
org.eclipse.linuxtools-f4ecc41d065ccdd894bf815d854836313cb3f0a5.tar.gz
org.eclipse.linuxtools-f4ecc41d065ccdd894bf815d854836313cb3f0a5.tar.bz2
Fix bug when tracefile is not aligned. Now supports exotic architectures.
Signed-off-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/event/CTFEventFieldTest.java12
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/headless/ReadTrace.java6
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/types/ArrayDefinitionTest.java8
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/types/EnumDeclarationTest.java4
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/types/EnumDefinitionTest.java2
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/types/IntegerDeclarationTest.java52
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/types/IntegerDefinitionTest.java6
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/types/SequenceDeclarationTest.java2
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/types/SequenceDefinitionTest.java6
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/types/VariantDefinitionTest.java16
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/ArrayDeclaration.java5
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/EnumDeclaration.java5
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/FloatDeclaration.java11
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/FloatDefinition.java39
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/IDeclaration.java2
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/IntegerDeclaration.java46
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/SequenceDeclaration.java4
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/StringDeclaration.java4
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/StructDeclaration.java4
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/VariantDeclaration.java6
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/StreamInputPacketReader.java7
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/event/metadata/IOStructGen.java10
22 files changed, 122 insertions, 135 deletions
diff --git a/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/event/CTFEventFieldTest.java b/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/event/CTFEventFieldTest.java
index 7b5e2da..b90a512 100644
--- a/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/event/CTFEventFieldTest.java
+++ b/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/event/CTFEventFieldTest.java
@@ -65,13 +65,13 @@ public class CTFEventFieldTest {
/**
* Run the CTFEventField parseField(Definition,String) method test.
- * @throws CTFReaderException
+ * @throws CTFReaderException
*/
@Test
public void testParseField_complex() throws CTFReaderException {
int len = 32;
IntegerDeclaration id = new IntegerDeclaration(len, false, len,
- ByteOrder.LITTLE_ENDIAN, Encoding.ASCII, null);
+ ByteOrder.LITTLE_ENDIAN, Encoding.ASCII, null, 32);
String lengthName = "LengthName"; //$NON-NLS-1$
StructDeclaration structDec = new StructDeclaration(0);
structDec.addField(lengthName, id);
@@ -93,7 +93,7 @@ public class CTFEventFieldTest {
/**
* Run the CTFEventField parseField(Definition,String) method test.
- * @throws CTFReaderException
+ * @throws CTFReaderException
*/
@Test
public void testParseField_simple() throws CTFReaderException {
@@ -110,7 +110,7 @@ public class CTFEventFieldTest {
public void testParseField_simple2() {
IntegerDefinition fieldDef = new IntegerDefinition(
new IntegerDeclaration(1, true, 1, ByteOrder.BIG_ENDIAN,
- Encoding.ASCII, null), null, fieldName);
+ Encoding.ASCII, null, 8), null, fieldName);
fieldDef.setValue(1L);
assertNotNull(fieldDef);
@@ -136,7 +136,7 @@ public class CTFEventFieldTest {
@Test
public void testParseField_manual() {
Definition fieldDef = new ArrayDefinition(new ArrayDeclaration(20,
- new IntegerDeclaration(8, false, 8, null, Encoding.UTF8, null)),
+ new IntegerDeclaration(8, false, 8, null, Encoding.UTF8, null, 8)),
null, fieldName);
((IntegerDefinition) ((ArrayDefinition) fieldDef).getDefinitions()[0]).setValue('H');
((IntegerDefinition) ((ArrayDefinition) fieldDef).getDefinitions()[1]).setValue('e');
@@ -160,7 +160,7 @@ public class CTFEventFieldTest {
@Test
public void testParseField_manual2() {
Definition fieldDef = new ArrayDefinition(new ArrayDeclaration(12,
- new IntegerDeclaration(32, false, 32, null, null, null)), null,
+ new IntegerDeclaration(32, false, 32, null, null, null, 8)), null,
fieldName);
((IntegerDefinition) ((ArrayDefinition) fieldDef).getDefinitions()[0]).setValue('H');
((IntegerDefinition) ((ArrayDefinition) fieldDef).getDefinitions()[1]).setValue('e');
diff --git a/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/headless/ReadTrace.java b/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/headless/ReadTrace.java
index 6f07886..9f09b81 100644
--- a/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/headless/ReadTrace.java
+++ b/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/headless/ReadTrace.java
@@ -29,10 +29,10 @@ public class ReadTrace {
*/
@SuppressWarnings("nls")
public static void main(String[] args) {
- final String TRACE_PATH = "Tests/traces/trace20m1";
+ final String TRACE_PATH = "/home/ematkho/lttng-traces/lt-hello-4175-20120405-092230";
// Change this to enable text output
- final boolean USE_TEXT = false;
+ final boolean USE_TEXT = true;
final int LOOP_COUNT = 1;
@@ -70,7 +70,7 @@ public class ReadTrace {
+ trace.getOffset());
System.out.println(traceReader.getIndex() + ", "
+ output + ", " + ed.getDeclaration().getName()
- + ", " + ed.getCPU());
+ + ", " + ed.getCPU() + ed.getFields().toString()) ;
}
traceReader.advance();
diff --git a/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/types/ArrayDefinitionTest.java b/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/types/ArrayDefinitionTest.java
index b2bb801..906f1b5 100644
--- a/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/types/ArrayDefinitionTest.java
+++ b/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/types/ArrayDefinitionTest.java
@@ -67,14 +67,14 @@ public class ArrayDefinitionTest {
}
private ArrayDefinition createLongArray() {
- IntegerDeclaration decl = new IntegerDeclaration(32, false, 10, ByteOrder.BIG_ENDIAN, Encoding.NONE, "none"); //$NON-NLS-1$
+ IntegerDeclaration decl = new IntegerDeclaration(32, false, 10, ByteOrder.BIG_ENDIAN, Encoding.NONE, "none",8); //$NON-NLS-1$
IntegerDefinition[] defs = createIntDefs(10, 32);
ArrayDefinition temp = setUpDeclaration(decl, defs);
return temp;
}
private ArrayDefinition createCharArray() {
- IntegerDeclaration decl = new IntegerDeclaration(8, false, 10, ByteOrder.BIG_ENDIAN, Encoding.UTF8, "none"); //$NON-NLS-1$
+ IntegerDeclaration decl = new IntegerDeclaration(8, false, 10, ByteOrder.BIG_ENDIAN, Encoding.UTF8, "none",8); //$NON-NLS-1$
IntegerDefinition[] defs = createIntDefs(4,8);
ArrayDefinition temp = setUpDeclaration(decl, defs);
return temp;
@@ -113,7 +113,7 @@ public class ArrayDefinitionTest {
String content = "test" + i; //$NON-NLS-1$
defs[i] = new IntegerDefinition(new IntegerDeclaration(bits, false,
- 16, ByteOrder.LITTLE_ENDIAN, Encoding.UTF8, content), null, content);
+ 16, ByteOrder.LITTLE_ENDIAN, Encoding.UTF8, content, 24), null, content);
defs[i].setValue(i);
}
return defs;
@@ -226,7 +226,7 @@ public class ArrayDefinitionTest {
@Test
public void testIsString_complex() {
final IntegerDeclaration id = new IntegerDeclaration(8, false, 16,
- ByteOrder.LITTLE_ENDIAN, Encoding.UTF8, null);
+ ByteOrder.LITTLE_ENDIAN, Encoding.UTF8, null, 8);
ArrayDeclaration ad = new ArrayDeclaration(0, id);
ArrayDefinition ownFixture = new ArrayDefinition(ad, this.trace,
"Testx"); //$NON-NLS-1$
diff --git a/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/types/EnumDeclarationTest.java b/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/types/EnumDeclarationTest.java
index e89c39b..89ab4ed 100644
--- a/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/types/EnumDeclarationTest.java
+++ b/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/types/EnumDeclarationTest.java
@@ -43,7 +43,7 @@ public class EnumDeclarationTest {
@Before
public void setUp() {
fixture = new EnumDeclaration(new IntegerDeclaration(1, true, 1,
- ByteOrder.BIG_ENDIAN, Encoding.ASCII, null));
+ ByteOrder.BIG_ENDIAN, Encoding.ASCII, null, 8));
}
/**
@@ -60,7 +60,7 @@ public class EnumDeclarationTest {
@Test
public void testEnumDeclaration() {
IntegerDeclaration containerType = new IntegerDeclaration(1, true, 1,
- ByteOrder.BIG_ENDIAN, Encoding.ASCII, null);
+ ByteOrder.BIG_ENDIAN, Encoding.ASCII, null, 8);
EnumDeclaration result = new EnumDeclaration(containerType);
diff --git a/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/types/EnumDefinitionTest.java b/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/types/EnumDefinitionTest.java
index 15c827c..a7d76d0 100644
--- a/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/types/EnumDefinitionTest.java
+++ b/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/types/EnumDefinitionTest.java
@@ -44,7 +44,7 @@ public class EnumDefinitionTest {
public void setUp() {
EnumDeclaration declaration = new EnumDeclaration(
new IntegerDeclaration(1, true, 1, ByteOrder.BIG_ENDIAN,
- Encoding.ASCII, null));
+ Encoding.ASCII, null, 8));
String fieldName = ""; //$NON-NLS-1$
fixture = new EnumDefinition(declaration, null, fieldName);
diff --git a/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/types/IntegerDeclarationTest.java b/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/types/IntegerDeclarationTest.java
index b75873f..c700365 100644
--- a/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/types/IntegerDeclarationTest.java
+++ b/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/types/IntegerDeclarationTest.java
@@ -38,7 +38,7 @@ public class IntegerDeclarationTest {
@Before
public void setUp() {
fixture = new IntegerDeclaration(1, true, 1, ByteOrder.BIG_ENDIAN,
- Encoding.ASCII, null);
+ Encoding.ASCII, null, 32);
}
/**
@@ -62,7 +62,7 @@ public class IntegerDeclarationTest {
Encoding encoding = Encoding.ASCII;
IntegerDeclaration result = new IntegerDeclaration(len, signed, base,
- byteOrder, encoding, null);
+ byteOrder, encoding, null, 16);
assertNotNull(result);
assertEquals(1, result.getBase());
@@ -129,7 +129,7 @@ public class IntegerDeclarationTest {
@Test
public void testIsCharacter_8bytes() {
IntegerDeclaration fixture8 = new IntegerDeclaration(8, true, 1,
- ByteOrder.BIG_ENDIAN, Encoding.ASCII, null);
+ ByteOrder.BIG_ENDIAN, Encoding.ASCII, null, 8);
boolean result = fixture8.isCharacter();
assertEquals(true, result);
@@ -150,56 +150,12 @@ public class IntegerDeclarationTest {
@Test
public void testIsSigned_unsigned() {
IntegerDeclaration fixture_unsigned = new IntegerDeclaration(1, false,
- 1, ByteOrder.BIG_ENDIAN, Encoding.ASCII, null);
+ 1, ByteOrder.BIG_ENDIAN, Encoding.ASCII, null, 8);
boolean result = fixture_unsigned.isSigned();
assertEquals(false, result);
}
- /**
- * Run the void setBase(int) method test.
- */
- @Test
- public void testSetBase() {
- int base = 1;
- fixture.setBase(base);
- }
-
- /**
- * Run the void setByteOrder(ByteOrder) method test.
- */
- @Test
- public void testSetByteOrder() {
- ByteOrder byteOrder = ByteOrder.BIG_ENDIAN;
- fixture.setByteOrder(byteOrder);
- }
-
- /**
- * Run the void setEncoding(Encoding) method test.
- */
- @Test
- public void testSetEncoding() {
- Encoding encoding = Encoding.ASCII;
- fixture.setEncoding(encoding);
- }
-
- /**
- * Run the void setLength(int) method test.
- */
- @Test
- public void testSetLength() {
- int length = 1;
- fixture.setLength(length);
- }
-
- /**
- * Run the void setSigned(boolean) method test.
- */
- @Test
- public void testSetSigned() {
- boolean signed = true;
- fixture.setSigned(signed);
- }
/**
* Run the String toString() method test.
diff --git a/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/types/IntegerDefinitionTest.java b/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/types/IntegerDefinitionTest.java
index 1d6a8eb..2915e27 100644
--- a/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/types/IntegerDefinitionTest.java
+++ b/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/types/IntegerDefinitionTest.java
@@ -45,8 +45,8 @@ public class IntegerDefinitionTest {
/**
* Perform pre-test initialization. We know the structDef won't be null (or
* else the tests will fail), so we can safely suppress the warning.
- *
- * @throws CTFReaderException
+ *
+ * @throws CTFReaderException
*/
@Before
public void setUp() throws CTFReaderException {
@@ -88,7 +88,7 @@ public class IntegerDefinitionTest {
@Test
public void testIntegerDefinition() {
IntegerDeclaration declaration = new IntegerDeclaration(1, true, 1,
- ByteOrder.BIG_ENDIAN, Encoding.ASCII, null);
+ ByteOrder.BIG_ENDIAN, Encoding.ASCII, null, 8);
IDefinitionScope definitionScope = null;
String fieldName = ""; //$NON-NLS-1$
diff --git a/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/types/SequenceDeclarationTest.java b/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/types/SequenceDeclarationTest.java
index 56c17d5..f6cb96f 100644
--- a/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/types/SequenceDeclarationTest.java
+++ b/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/types/SequenceDeclarationTest.java
@@ -71,7 +71,7 @@ public class SequenceDeclarationTest {
@Test
public void testCreateDefinition() {
IntegerDeclaration id = new IntegerDeclaration(8, false, 8,
- ByteOrder.LITTLE_ENDIAN, Encoding.UTF8, null);
+ ByteOrder.LITTLE_ENDIAN, Encoding.UTF8, null, 32);
StructDeclaration structDec = new StructDeclaration(0);
structDec.addField(fieldName, id);
diff --git a/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/types/SequenceDefinitionTest.java b/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/types/SequenceDefinitionTest.java
index 11745a8..5cf9b92 100644
--- a/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/types/SequenceDefinitionTest.java
+++ b/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/types/SequenceDefinitionTest.java
@@ -43,7 +43,7 @@ public class SequenceDefinitionTest {
/**
* Perform pre-test initialization.
- * @throws CTFReaderException
+ * @throws CTFReaderException
*/
@Before
public void setUp() throws CTFReaderException {
@@ -51,7 +51,7 @@ public class SequenceDefinitionTest {
StructDefinition structDef;
IntegerDeclaration id = new IntegerDeclaration(8, false, 8,
- ByteOrder.LITTLE_ENDIAN, Encoding.UTF8, null);
+ ByteOrder.LITTLE_ENDIAN, Encoding.UTF8, null, 8);
String lengthName = "LengthName"; //$NON-NLS-1$
structDec = new StructDeclaration(0);
structDec.addField(lengthName, id);
@@ -83,7 +83,7 @@ public class SequenceDefinitionTest {
int len = 32;
IntegerDeclaration id = new IntegerDeclaration(len, false, len,
- ByteOrder.LITTLE_ENDIAN, Encoding.UTF8, null);
+ ByteOrder.LITTLE_ENDIAN, Encoding.UTF8, null,8);
String lengthName = "LengthName"; //$NON-NLS-1$
structDec = new StructDeclaration(0);
structDec.addField(lengthName, id);
diff --git a/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/types/VariantDefinitionTest.java b/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/types/VariantDefinitionTest.java
index e670f24..cf2eb5d 100644
--- a/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/types/VariantDefinitionTest.java
+++ b/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/types/VariantDefinitionTest.java
@@ -51,8 +51,8 @@ public class VariantDefinitionTest {
* Perform pre-test initialization.
*
* Not sure it needs to be that complicated, oh well...
- *
- * @throws CTFReaderException
+ *
+ * @throws CTFReaderException
*/
@Before
public void setUp() throws CTFReaderException {
@@ -76,7 +76,7 @@ public class VariantDefinitionTest {
sDef2 = new StructDefinition(new StructDeclaration(1L), vDef2, fName);
eDef = new EnumDefinition(new EnumDeclaration(new IntegerDeclaration(1,
- true, 1, ByteOrder.BIG_ENDIAN, Encoding.ASCII, fName)), sDef2, fName);
+ true, 1, ByteOrder.BIG_ENDIAN, Encoding.ASCII, fName, 8)), sDef2, fName);
fixture = new VariantDefinition(vDecl1, sDef1, fName);
fixture.setTagDefinition(eDef);
@@ -93,8 +93,8 @@ public class VariantDefinitionTest {
/**
* Run the VariantDefinition(VariantDeclaration,DefinitionScope,String)
- *
- * @throws CTFReaderException
+ *
+ * @throws CTFReaderException
*/
@Test
public void testVariantDefinition() throws CTFReaderException {
@@ -276,8 +276,8 @@ public class VariantDefinitionTest {
/**
* Run the void setTagDefinition(EnumDefinition) method test.
- *
- * @throws CTFReaderException
+ *
+ * @throws CTFReaderException
*/
@Test
public void testSetTagDefinition() throws CTFReaderException {
@@ -293,7 +293,7 @@ public class VariantDefinitionTest {
structDef = new StructDefinition(new StructDeclaration(1L), vDef, fName);
tagDefinition = new EnumDefinition(new EnumDeclaration(
new IntegerDeclaration(1, true, 1, ByteOrder.BIG_ENDIAN,
- Encoding.ASCII, fName)), structDef, fName);
+ Encoding.ASCII, fName, 8)), structDef, fName);
fixture.setTagDefinition(tagDefinition);
}
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
index 30730c7..84c5f59 100644
--- 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
@@ -45,6 +45,11 @@ public class ArrayDeclaration implements IDeclaration {
return length;
}
+ @Override
+ public long getAlignment() {
+ long retVal = this.getElementType().getAlignment();
+ return retVal;
+ }
// ------------------------------------------------------------------------
// Operations
// ------------------------------------------------------------------------
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
index 2ae8b29..f1fa82c 100644
--- 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
@@ -43,6 +43,10 @@ public class EnumDeclaration implements IDeclaration {
return containerType;
}
+ @Override
+ public long getAlignment() {
+ return this.getContainerType().getAlignment();
+ }
// ------------------------------------------------------------------------
// Operations
// ------------------------------------------------------------------------
@@ -137,4 +141,5 @@ public class EnumDeclaration implements IDeclaration {
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/FloatDeclaration.java b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/FloatDeclaration.java
index da99c81..89ef7e5 100644
--- 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
@@ -8,6 +8,7 @@
*
* Contributors: Matthew Khouzam - Initial API and implementation
*******************************************************************************/
+
package org.eclipse.linuxtools.ctf.core.event.types;
import java.nio.ByteOrder;
@@ -23,17 +24,19 @@ public class FloatDeclaration implements IDeclaration {
private final int exp;
private final ByteOrder byteOrder;
private final Encoding encoding;
+ private final long alignment;
// ------------------------------------------------------------------------
// Constructors
// ------------------------------------------------------------------------
public FloatDeclaration(int exponent, int mantissa, ByteOrder byteOrder,
- Encoding encoding) {
+ Encoding encoding, long alignment) {
mant = mantissa;
exp = exponent;
this.byteOrder = byteOrder;
this.encoding = encoding;
+ this.alignment = alignment;
}
@@ -41,8 +44,6 @@ public class FloatDeclaration implements IDeclaration {
// Gettters/Setters/Predicates
// ------------------------------------------------------------------------
-
-
/**
* @return the mant
*/
@@ -71,6 +72,10 @@ public class FloatDeclaration implements IDeclaration {
return encoding;
}
+ public long getAlignment() {
+ return alignment;
+ }
+
// ------------------------------------------------------------------------
// Operations
// ------------------------------------------------------------------------
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
index cdb0a52..dfc5508 100644
--- 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
@@ -57,11 +57,11 @@ public class FloatDefinition extends Definition {
int exp = declaration.getExponent();
int mant = declaration.getMantissa();
if( (exp + mant) == 32 ){
- readRawFloat32(input, mant , exp);
+ value = readRawFloat32(input, mant , exp);
}
else if((exp + mant) == 64)
{
- readRawFloat64(input, mant,exp);
+ value = readRawFloat64(input, mant,exp);
}
else
{
@@ -71,15 +71,13 @@ public class FloatDefinition extends Definition {
- private void readRawFloat64(BitBuffer input, final int manBits, final int expBits) {
+ private static double readRawFloat64(BitBuffer input, final int manBits, final int expBits) {
long low = input.getInt(32, false);
low = low & 0x00000000FFFFFFFFL;
long high = input.getInt(32, false);
high = high & 0x00000000FFFFFFFFL;
long temp = (high << 32) | low;
-
-
- value = createFloat(temp, manBits, expBits);
+ return createFloat(temp, manBits-1, expBits);
}
/**
@@ -88,25 +86,24 @@ public class FloatDefinition extends Definition {
* @param expBits
*/
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);
- long man = (rawValue & manMask);
- double expPow = Math.pow(2.0, exp-(1 << (expBits-1)));
- double ret = man * 1.0f;
- ret /= manShift;
- ret += 1.0;
- ret *= expPow;
- return ret;
+ long manShift = 1L << (manBits);
+ long manMask = manShift - 1;
+ long expMask = (1L << expBits) - 1;
+
+ int exp = (int) ((rawValue >> (manBits))&expMask)+1;
+ long man = (rawValue & manMask);
+ double expPow = Math.pow(2.0, exp - (1 << (expBits - 1)));
+ double ret = man * 1.0f;
+ ret /= manShift;
+ ret += 1.0;
+ ret *= expPow;
+ return ret;
}
- private void readRawFloat32(BitBuffer input, final int manBits,
+ private static double readRawFloat32(BitBuffer input, final int manBits,
final int expBits) {
long temp = input.getInt(32, false);
-
- value = createFloat(temp, manBits, expBits);
+ return createFloat(temp, manBits-1, expBits);
}
@Override
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
index 87f86f2..171bad3 100644
--- 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
@@ -19,4 +19,6 @@ public interface IDeclaration {
public Definition createDefinition(IDefinitionScope definitionScope,
String fieldName);
+
+ public long getAlignment();
}
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
index c8b7fbb..32729d8 100644
--- 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
@@ -23,26 +23,27 @@ public class IntegerDeclaration implements IDeclaration {
// Attributes
// ------------------------------------------------------------------------
- private int length;
- private boolean signed;
- private int base;
- private ByteOrder byteOrder;
- private Encoding encoding;
- @SuppressWarnings("unused")
- private final String clock;
+ final private int length;
+ final private boolean signed;
+ final private int base;
+ final private ByteOrder byteOrder;
+ final private Encoding encoding;
+ final private long alignment;
+ final private String clock;
// ------------------------------------------------------------------------
// Constructors
// ------------------------------------------------------------------------
public IntegerDeclaration(int len, boolean signed, int base,
- ByteOrder byteOrder, Encoding encoding, String clock) {
+ ByteOrder byteOrder, Encoding encoding, String clock, long alignment) {
this.length = len;
this.signed = signed;
this.base = base;
this.byteOrder = byteOrder;
this.encoding = encoding;
this.clock = clock;
+ this.alignment = alignment;
}
// ------------------------------------------------------------------------
@@ -53,39 +54,19 @@ public class IntegerDeclaration implements IDeclaration {
return signed;
}
- public void setSigned(boolean signed) {
- this.signed = signed;
- }
-
public int getBase() {
return base;
}
- public void setBase(int base) {
- this.base = base;
- }
-
public ByteOrder getByteOrder() {
return byteOrder;
}
- public void setByteOrder(ByteOrder byteOrder) {
- this.byteOrder = byteOrder;
- }
-
public Encoding getEncoding() {
return encoding;
}
- public void setEncoding(Encoding encoding) {
- this.encoding = encoding;
- }
-
- public void setLength(int length) {
- this.length = length;
- }
-
- public boolean isCharacter() {
+ public boolean isCharacter() {
return (length == 8) && (encoding != Encoding.NONE);
}
@@ -93,6 +74,13 @@ public class IntegerDeclaration implements IDeclaration {
return length;
}
+ public long getAlignment(){
+ return alignment;
+ }
+
+ public String getClock(){
+ return clock;
+ }
// ------------------------------------------------------------------------
// Operations
// ------------------------------------------------------------------------
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
index 8532e6e..2ea5081 100644
--- 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
@@ -47,6 +47,10 @@ public class SequenceDeclaration implements IDeclaration {
return lengthName;
}
+ @Override
+ public long getAlignment() {
+ return getElementType().getAlignment();
+ }
// ------------------------------------------------------------------------
// Operations
// ------------------------------------------------------------------------
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
index 5fc519d..0f62d91 100644
--- 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
@@ -50,6 +50,10 @@ public class StringDeclaration implements IDeclaration {
this.encoding = encoding;
}
+ @Override
+ public long getAlignment() {
+ return 8; //FIXME: should be the elementtype.
+ }
// ------------------------------------------------------------------------
// Operations
// ------------------------------------------------------------------------
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
index 1e43be6..2f0ef53 100644
--- 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
@@ -61,6 +61,10 @@ public class StructDeclaration implements IDeclaration {
return this.fieldsList;
}
+ @Override
+ public long getAlignment() {
+ return getMinAlign();
+ }
// ------------------------------------------------------------------------
// Operations
// ------------------------------------------------------------------------
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
index bad6ba4..c0338cf 100644
--- 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
@@ -24,6 +24,7 @@ public class VariantDeclaration implements IDeclaration {
// ------------------------------------------------------------------------
private String tag = null;
+ private long alignment;
private final HashMap<String, IDeclaration> fields = new HashMap<String, IDeclaration>();
// ------------------------------------------------------------------------
@@ -57,6 +58,10 @@ public class VariantDeclaration implements IDeclaration {
return this.fields;
}
+ @Override
+ public long getAlignment() {
+ return alignment;
+ }
// ------------------------------------------------------------------------
// Operations
// ------------------------------------------------------------------------
@@ -69,6 +74,7 @@ public class VariantDeclaration implements IDeclaration {
public void addField(String fieldTag, IDeclaration declaration) {
fields.put(fieldTag, declaration);
+ alignment = Math.max(alignment, declaration.getAlignment());
}
@Override
diff --git a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/StreamInputPacketReader.java b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/StreamInputPacketReader.java
index 53e4106..9b4b2cb 100644
--- a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/StreamInputPacketReader.java
+++ b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/StreamInputPacketReader.java
@@ -294,7 +294,7 @@ class StreamInputPacketReader implements IDefinitionScope {
long timestamp = 0;
/*
- * Read thestream event header.
+ * Read the stream event header.
*/
if (getStreamEventHeaderDef() != null) {
getStreamEventHeaderDef().read(getBitBuffer());
@@ -367,6 +367,11 @@ class StreamInputPacketReader implements IDefinitionScope {
* Read the event fields.
*/
if (eventDef.fields != null) {
+ int pos = getBitBuffer().position();
+ int minAlign = (int) eventDef.fields.getDeclaration().getMinAlign();
+ int offset = pos % minAlign;
+ pos += (minAlign - offset)%minAlign;
+ getBitBuffer().position(pos);
eventDef.fields.read(getBitBuffer());
}
diff --git a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/event/metadata/IOStructGen.java b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/event/metadata/IOStructGen.java
index 45707a7..7e30719 100644
--- a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/event/metadata/IOStructGen.java
+++ b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/event/metadata/IOStructGen.java
@@ -1256,7 +1256,7 @@ public class IOStructGen {
}
}
- floatDeclaration = new FloatDeclaration(exponent, mantissa, byteOrder, encoding);
+ floatDeclaration = new FloatDeclaration(exponent, mantissa, byteOrder, encoding, alignment);
assert (floatDeclaration != null);
return floatDeclaration;
@@ -1387,7 +1387,7 @@ public class IOStructGen {
}
integerDeclaration = new IntegerDeclaration((int) size, signed, base,
- byteOrder, encoding, clock);
+ byteOrder, encoding, clock, alignment);
assert (integerDeclaration != null);
return integerDeclaration;
@@ -1551,6 +1551,12 @@ public class IOStructGen {
/* Parse the body */
parseStructBody(structBody, structDeclaration);
+ long maxFieldAlign = -1;
+ for( IDeclaration field : structDeclaration.getFields().values())
+ {
+ maxFieldAlign = Math.max(maxFieldAlign, field.getAlignment());
+ }
+ structDeclaration.setMinAlign(maxFieldAlign);
/* If struct has name, add it to the current scope. */
if (hasName) {