Added clocks to integer definitions and removed warnings from IOStructGen.java
authorMatthew Khouzam <matthew.khouzam@ericsson.com>
Fri, 16 Mar 2012 21:08:33 +0000 (17:08 -0400)
committerFrancois Chouinard <fchouinard@gmail.com>
Mon, 19 Mar 2012 21:43:55 +0000 (17:43 -0400)
org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/event/CTFEventFieldTest.java
org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/types/ArrayDefinitionTest.java
org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/types/EnumDeclarationTest.java
org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/types/EnumDefinitionTest.java
org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/types/IntegerDeclarationTest.java
org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/types/IntegerDefinitionTest.java
org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/types/SequenceDeclarationTest.java
org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/types/SequenceDefinitionTest.java
org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/types/VariantDefinitionTest.java
org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/metadata/IOStructGen.java
org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/IntegerDeclaration.java

index 1ff12815e083856a3910330d6c533ab8eeab67ec..47a4d8609c1f5cb04d192ac383739620346724a2 100644 (file)
@@ -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');
index 43e6109d6970f2649a2c984a836f066a8d9a6f37..dee799388f7772fd219b1642da1e5ce89f13a03a 100644 (file)
@@ -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);
         }
 
index d0919bc3077e3de76eeda11d5d8ef5904e3e8dc3..e89c39b11406e775cc44bfab5c8f29d90639dc24 100644 (file)
@@ -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);
 
index eaaed33f34e75afba1a01c72c01f913e24564aae..9fdb60e0570721bcbf231cac88e8d4176eb7aa39 100644 (file)
@@ -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);
index 7d04c6effef90691613c30d8c106edac4bcc590f..b75873ffa625e7abb98553399b3022590d9433ea 100644 (file)
@@ -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);
index c00155fcf19c2b0f8fbc491cfe0d8e265e34757d..a06be0ca6377cc56a55ebb31bfba2af202b5943b 100644 (file)
@@ -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
+}
index ff46131b9db80dac48723ab17f0700ddc6c6ed24..5e312b6fd06b92e75405c6d08d8ad00936ee9380 100644 (file)
@@ -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);
index 78594223082182441a474a623867f9bbb8b8efc7..0ca0e137038879e92923a867f4939128d1249f5b 100644 (file)
@@ -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);
index d03bbfdbfe3be5230b0959ce8ba86a7ee1e3590e..d29198f011402bf085b12cf3f8bf41244e7c85e5 100644 (file)
@@ -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);
     }
index 051fb407930bc583b6ea44502a593b7dfd5dad1e..f7b9448b54ef537e5dcb33df0fd392e0d47533ac 100644 (file)
@@ -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();
     }
 
index 42b4e8eaaf8945b2eac33575de5bf4c5bf4c0a55..40ec525a0e6f5919763056d7950fccd4e2f9c21c 100644 (file)
@@ -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;
     }
 
     // ------------------------------------------------------------------------
This page took 0.033446 seconds and 5 git commands to generate.