| author | Matthew Khouzam | 2012-03-16 17:08:33 (EDT) |
|---|---|---|
| committer | Francois Chouinard | 2012-03-19 17:43:55 (EDT) |
| commit | d98555f4d955e1838171372f54907c26b4c4033d (patch) (side-by-side diff) | |
| tree | 6a505beee97366b14cd602a971a025f8fbcbe58e | |
| parent | d0bf7c0ef35d7f04fd7f07848d8a8a90d78ff515 (diff) | |
| download | org.eclipse.linuxtools-d98555f4d955e1838171372f54907c26b4c4033d.zip org.eclipse.linuxtools-d98555f4d955e1838171372f54907c26b4c4033d.tar.gz org.eclipse.linuxtools-d98555f4d955e1838171372f54907c26b4c4033d.tar.bz2 | |
Added clocks to integer definitions and removed warnings from IOStructGen.java
11 files changed, 62 insertions, 55 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 1ff1281..47a4d86 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 @@ -27,16 +27,16 @@ import org.junit.Test; /** * The class <code>CTFEventFieldTest</code> contains tests for the class * <code>{@link CTFEventField}</code>. - * + * * @author ematkho * @version $Revision: 1.0 $ * @param <CTFIntegerArrayField> */ public class CTFEventFieldTest { - + private static final String fieldName = "id"; //$NON-NLS-1$ - - + + /** * Perform pre-test initialization. */ @@ -55,7 +55,7 @@ public class CTFEventFieldTest { /** * Launch the test. - * + * * @param args * the command line arguments */ @@ -71,7 +71,7 @@ public class CTFEventFieldTest { public void testParseField_complex() throws CTFReaderException { int len = 32; IntegerDeclaration id = new IntegerDeclaration(len, false, len, - ByteOrder.LITTLE_ENDIAN, Encoding.ASCII); + ByteOrder.LITTLE_ENDIAN, Encoding.ASCII, null); String lengthName = "LengthName"; //$NON-NLS-1$ StructDeclaration structDec = new StructDeclaration(0); structDec.addField(lengthName, id); @@ -102,7 +102,7 @@ public class CTFEventFieldTest { assertNotNull(fieldDef); } - + /** * Run the CTFEventField parseField(Definition,String) method test. */ @@ -110,14 +110,14 @@ public class CTFEventFieldTest { public void testParseField_simple2() { IntegerDefinition fieldDef = new IntegerDefinition( new IntegerDeclaration(1, true, 1, ByteOrder.BIG_ENDIAN, - Encoding.ASCII), null, fieldName); + Encoding.ASCII, null), null, fieldName); fieldDef.setValue(1L); assertNotNull(fieldDef); } - + /** - * + * */ @Test public void testParseField_simple3() { @@ -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)), + new IntegerDeclaration(8, false, 8, null, Encoding.UTF8, null)), 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, + new IntegerDeclaration(32, false, 32, null, null, null)), 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/types/ArrayDefinitionTest.java b/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/types/ArrayDefinitionTest.java index 43e6109..dee7993 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 @@ -30,7 +30,7 @@ import org.junit.Test; /** * The class <code>ArrayDefinitionTest</code> contains tests for the class * <code>{@link ArrayDefinition}</code>. - * + * * @author ematkho * @version $Revision: 1.0 $ */ @@ -41,7 +41,7 @@ public class ArrayDefinitionTest { /** * Launch the test. - * + * * @param args * the command line arguments */ @@ -51,7 +51,7 @@ public class ArrayDefinitionTest { /** * Perform pre-test initialization. - * + * * structDef shouldn't be null after parsing the CTFTraceReader object, so * we can ignore the warning. * @@ -191,7 +191,7 @@ public class ArrayDefinitionTest { @Test public void testIsString_complex() { final IntegerDeclaration id = new IntegerDeclaration(8, false, 16, - ByteOrder.LITTLE_ENDIAN, Encoding.UTF8); + ByteOrder.LITTLE_ENDIAN, Encoding.UTF8, null); ArrayDeclaration ad = new ArrayDeclaration(0, id); ArrayDefinition ownFixture = new ArrayDefinition(ad, this.trace, "Testx"); //$NON-NLS-1$ @@ -202,7 +202,7 @@ public class ArrayDefinitionTest { String content = "test" + i; //$NON-NLS-1$ defs[i] = new IntegerDefinition(new IntegerDeclaration(8, false, - 16, ByteOrder.LITTLE_ENDIAN, Encoding.UTF8), null, content); + 16, ByteOrder.LITTLE_ENDIAN, Encoding.UTF8, content), null, content); defs[i].setValue(i); } 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 d0919bc..e89c39b 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 @@ -19,7 +19,7 @@ import org.junit.Test; /** * The class <code>EnumDeclarationTest</code> contains tests for the class * <code>{@link EnumDeclaration}</code>. - * + * * @author ematkho * @version $Revision: 1.0 $ */ @@ -29,7 +29,7 @@ public class EnumDeclarationTest { /** * Launch the test. - * + * * @param args * the command line arguments */ @@ -43,7 +43,7 @@ public class EnumDeclarationTest { @Before public void setUp() { fixture = new EnumDeclaration(new IntegerDeclaration(1, true, 1, - ByteOrder.BIG_ENDIAN, Encoding.ASCII)); + ByteOrder.BIG_ENDIAN, Encoding.ASCII, null)); } /** @@ -60,7 +60,7 @@ public class EnumDeclarationTest { @Test public void testEnumDeclaration() { IntegerDeclaration containerType = new IntegerDeclaration(1, true, 1, - ByteOrder.BIG_ENDIAN, Encoding.ASCII); + ByteOrder.BIG_ENDIAN, Encoding.ASCII, null); 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 eaaed33..9fdb60e 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 @@ -19,7 +19,7 @@ import org.junit.Test; /** * The class <code>EnumDefinitionTest</code> contains tests for the class * <code>{@link EnumDefinition}</code>. - * + * * @author ematkho * @version $Revision: 1.0 $ */ @@ -29,7 +29,7 @@ public class EnumDefinitionTest { /** * Launch the test. - * + * * @param args * the command line arguments */ @@ -44,7 +44,7 @@ public class EnumDefinitionTest { public void setUp() { EnumDeclaration declaration = new EnumDeclaration( new IntegerDeclaration(1, true, 1, ByteOrder.BIG_ENDIAN, - Encoding.ASCII)); + Encoding.ASCII, null)); 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 7d04c6e..b75873f 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 @@ -14,7 +14,7 @@ import org.junit.Test; /** * The class <code>IntegerDeclarationTest</code> contains tests for the class * <code>{@link IntegerDeclaration}</code>. - * + * * @author ematkho * @version $Revision: 1.0 $ */ @@ -24,7 +24,7 @@ public class IntegerDeclarationTest { /** * Launch the test. - * + * * @param args * the command line arguments */ @@ -38,7 +38,7 @@ public class IntegerDeclarationTest { @Before public void setUp() { fixture = new IntegerDeclaration(1, true, 1, ByteOrder.BIG_ENDIAN, - Encoding.ASCII); + Encoding.ASCII, null); } /** @@ -62,7 +62,7 @@ public class IntegerDeclarationTest { Encoding encoding = Encoding.ASCII; IntegerDeclaration result = new IntegerDeclaration(len, signed, base, - byteOrder, encoding); + byteOrder, encoding, null); 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); + ByteOrder.BIG_ENDIAN, Encoding.ASCII, null); boolean result = fixture8.isCharacter(); assertEquals(true, result); @@ -150,7 +150,7 @@ public class IntegerDeclarationTest { @Test public void testIsSigned_unsigned() { IntegerDeclaration fixture_unsigned = new IntegerDeclaration(1, false, - 1, ByteOrder.BIG_ENDIAN, Encoding.ASCII); + 1, ByteOrder.BIG_ENDIAN, Encoding.ASCII, null); boolean result = fixture_unsigned.isSigned(); assertEquals(false, result); 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 c00155f..a06be0c 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 @@ -24,7 +24,7 @@ import org.junit.Test; /** * The class <code>IntegerDefinitionTest</code> contains tests for the class * <code>{@link IntegerDefinition}</code>. - * + * * @author ematkho * @version $Revision: 1.0 $ */ @@ -34,7 +34,7 @@ public class IntegerDefinitionTest { /** * Launch the test. - * + * * @param args * the command line arguments */ @@ -88,7 +88,7 @@ public class IntegerDefinitionTest { @Test public void testIntegerDefinition() { IntegerDeclaration declaration = new IntegerDeclaration(1, true, 1, - ByteOrder.BIG_ENDIAN, Encoding.ASCII); + ByteOrder.BIG_ENDIAN, Encoding.ASCII, null); IDefinitionScope definitionScope = null; String fieldName = ""; //$NON-NLS-1$ @@ -140,4 +140,4 @@ public class IntegerDefinitionTest { String result = fixture.toString(); assertNotNull(result); } -}
\ No newline at end of file +} 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 ff46131..5e312b6 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 @@ -20,7 +20,7 @@ import org.junit.Test; /** * The class <code>SequenceDeclarationTest</code> contains tests for the class * <code>{@link SequenceDeclaration}</code>. - * + * * @author ematkho * @version $Revision: 1.0 $ */ @@ -30,7 +30,7 @@ public class SequenceDeclarationTest { /** * Launch the test. - * + * * @param args * the command line arguments */ @@ -70,7 +70,7 @@ public class SequenceDeclarationTest { @Test public void testCreateDefinition() { IntegerDeclaration id = new IntegerDeclaration(8, false, 8, - ByteOrder.LITTLE_ENDIAN, Encoding.UTF8); + ByteOrder.LITTLE_ENDIAN, Encoding.UTF8, null); String fieldName = "LengthName"; //$NON-NLS-1$ 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 7859422..0ca0e13 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 @@ -22,7 +22,7 @@ import org.junit.Test; /** * The class <code>SequenceDefinitionTest</code> contains tests for the class * <code>{@link SequenceDefinition}</code>. - * + * * @author ematkho * @version $Revision: 1.0 $ */ @@ -33,7 +33,7 @@ public class SequenceDefinitionTest { /** * Launch the test. - * + * * @param args * the command line arguments */ @@ -51,7 +51,7 @@ public class SequenceDefinitionTest { StructDefinition structDef; IntegerDeclaration id = new IntegerDeclaration(8, false, 8, - ByteOrder.LITTLE_ENDIAN, Encoding.UTF8); + ByteOrder.LITTLE_ENDIAN, Encoding.UTF8, null); 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); + ByteOrder.LITTLE_ENDIAN, Encoding.UTF8, null); 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 d03bbfd..d29198f 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 @@ -29,7 +29,7 @@ import org.junit.Test; /** * The class <code>VariantDefinitionTest</code> contains tests for the class * <code>{@link VariantDefinition}</code>. - * + * * @author ematkho * @version $Revision: 1.0 $ */ @@ -39,7 +39,7 @@ public class VariantDefinitionTest { /** * Launch the test. - * + * * @param args * the command line arguments */ @@ -49,7 +49,7 @@ public class VariantDefinitionTest { /** * Perform pre-test initialization. - * + * * Not sure it needs to be that complicated, oh well... * * @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)), sDef2, fName); + true, 1, ByteOrder.BIG_ENDIAN, Encoding.ASCII, fName)), sDef2, fName); fixture = new VariantDefinition(vDecl1, sDef1, fName); fixture.setTagDefinition(eDef); @@ -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)), structDef, fName); + Encoding.ASCII, fName)), structDef, fName); fixture.setTagDefinition(tagDefinition); } diff --git a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/metadata/IOStructGen.java b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/metadata/IOStructGen.java index 051fb40..f7b9448 100644 --- a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/metadata/IOStructGen.java +++ b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/metadata/IOStructGen.java @@ -258,9 +258,15 @@ public class IOStructGen { switch (type) { case CTFParser.INTEGER: case CTFParser.DECIMAL_LITERAL: - //FIXME - //HACK - //EVIL + /* + * Not a pretty hack, this is to make sure that there is no number + * overflow due to 63 bit integers. The offset should only really + * be an issue in the year 2262. the tracer in C/ASM can write an offset in + * an unsigned 64 bit long. In java, the last bit, being set to 1 will + * be read as a negative number, but since it is too big a positive it will + * throw an exception. this will happen in 2^63 ns from 1970. + * Therefore 293 years from 1970 + */ Long numValue; try{ numValue = Long.parseLong(value.getText()); @@ -1057,7 +1063,7 @@ public class IOStructGen { * sequence. For example, int a[3][len] means that we have an array of 3 * (sequences of length 'len' of (int)). */ - if (lengths != null) { + if (lengths.size() > 0 ) { /* We begin at the end */ Collections.reverse(lengths); @@ -1227,8 +1233,7 @@ public class IOStructGen { long size = 0; long alignment = 0; int base = 10; - @SuppressWarnings("unused") - String clock; + String clock = null; Encoding encoding = Encoding.NONE; @@ -1293,13 +1298,13 @@ public class IOStructGen { } integerDeclaration = new IntegerDeclaration((int) size, signed, base, - byteOrder, encoding); + byteOrder, encoding, clock); assert (integerDeclaration != null); return integerDeclaration; } - private String getClock(CommonTree rightNode) { + private static String getClock(CommonTree rightNode) { return rightNode.getChild(1).getChild(0).getChild(0).getText(); } 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 42b4e8e..40ec525 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 @@ -28,18 +28,20 @@ public class IntegerDeclaration implements IDeclaration { private int base; private ByteOrder byteOrder; private Encoding encoding; + private final String clock; // ------------------------------------------------------------------------ // Constructors // ------------------------------------------------------------------------ public IntegerDeclaration(int len, boolean signed, int base, - ByteOrder byteOrder, Encoding encoding) { + ByteOrder byteOrder, Encoding encoding, String clock) { this.length = len; this.signed = signed; this.base = base; this.byteOrder = byteOrder; this.encoding = encoding; + this.clock = clock; } // ------------------------------------------------------------------------ |

