Merge branch 'master' into lttng-kepler
authorAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Thu, 13 Sep 2012 20:07:40 +0000 (16:07 -0400)
committerAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Thu, 13 Sep 2012 20:07:40 +0000 (16:07 -0400)
Conflicts:
lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventsTable.java

Change-Id: I553c88f56037dc35b9f646887b12d83e623d3543

org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/IntegerDefinition.java
org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/event/metadata/DeclarationScope.java
org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/event/metadata/IOStructGen.java
org.eclipse.linuxtools.ctf/feature.xml
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventsTable.java

index e72d6ac37658e41e853cd5017b79a1caee299756..194959faa4b11307dd7421d86784c1ee1457cddc 100644 (file)
@@ -12,6 +12,8 @@
 
 package org.eclipse.linuxtools.ctf.core.event.types;
 
+import java.nio.ByteOrder;
+
 import org.eclipse.linuxtools.internal.ctf.core.event.io.BitBuffer;
 
 /**
@@ -116,8 +118,11 @@ public class IntegerDefinition extends SimpleDatatypeDefinition {
             low = low & 0x00000000FFFFFFFFL;
             long high = input.getInt(32, false);
             high = high & 0x00000000FFFFFFFFL;
-
-            bits = (high << 32) | low;
+            if (this.declaration.getByteOrder() != ByteOrder.BIG_ENDIAN) {
+                bits = (high << 32) | low;
+            } else {
+                bits = (low << 32) | high;
+            }
         } else {
             bits = input.getInt(length, signed);
             bits = bits & 0x00000000FFFFFFFFL;
index 82ed90b630ba26ee5850a60760852583b439d167..81b25969055a34f9caf586d383f941b92fe2b5da 100644 (file)
@@ -308,4 +308,33 @@ public class DeclarationScope {
         }
     }
 
+
+    /**
+     * Get all the type names of this scope.
+     *
+     * @return The type names
+     */
+    public String[] getTypeNames() {
+        String[] keys = new String[types.keySet().size()];
+        return types.keySet().toArray(keys);
+    }
+
+    /**
+     * Replace a type with a new one.
+     *
+     * @param name
+     *            The name of the type
+     * @param newType
+     *            The type
+     * @throws ParseException
+     *             If the type does not exist.
+     */
+    public void replaceType(String name, IDeclaration newType) throws ParseException{
+        if (types.containsKey(name)) {
+            types.put(name, newType);
+        } else {
+            throw new ParseException("Trace does not contain type: " + name); //$NON-NLS-1$
+        }
+    }
+
 }
index a84a467d20d879f6bf65ecbb7e26d95ecbd9d2e6..2b300762971d934e29feae7b83452636dad2a548 100644 (file)
@@ -170,19 +170,6 @@ public class IOStructGen {
                     childTypeError(child);
                 }
             }
-
-            if (DEBUG_) {
-                out.write("Environments\n"); //$NON-NLS-1$
-            }
-            for (CommonTree environment : environments) {
-                parseEnvironment(environment);
-            }
-            if (DEBUG_) {
-                out.write("Clocks\n"); //$NON-NLS-1$
-            }
-            for (CommonTree clock : clocks) {
-                parseClock(clock);
-            }
             if (DEBUG_) {
                 out.write("Declarations\n"); //$NON-NLS-1$
             }
@@ -192,13 +179,25 @@ public class IOStructGen {
                 }
                 parseRootDeclaration(decl);
             }
-
             if (traceNode == null) {
                 throw new ParseException("Missing trace block"); //$NON-NLS-1$
             }
 
             parseTrace(traceNode);
 
+            if (DEBUG_) {
+                out.write("Environments\n"); //$NON-NLS-1$
+            }
+            for (CommonTree environment : environments) {
+                parseEnvironment(environment);
+            }
+            if (DEBUG_) {
+                out.write("Clocks\n"); //$NON-NLS-1$
+            }
+            for (CommonTree clock : clocks) {
+                parseClock(clock);
+            }
+
             if (DEBUG_) {
                 out.write("Streams\n"); //$NON-NLS-1$
             }
@@ -255,8 +254,7 @@ public class IOStructGen {
         List<CommonTree> children = clock.getChildren();
         CTFClock ctfClock = new CTFClock();
         for (CommonTree child : children) {
-            final String key = child.getChild(0).getChild(0).getChild(0)
-                    .getText();
+            final String key = child.getChild(0).getChild(0).getChild(0).getText();
             final CommonTree value = (CommonTree) child.getChild(1).getChild(0).getChild(0);
             final int type = value.getType();
             switch (type) {
@@ -330,8 +328,8 @@ public class IOStructGen {
 
     private void parseTraceDeclaration(CommonTree traceDecl)
             throws ParseException {
-        assert ((traceDecl.getType() == CTFParser.CTF_EXPRESSION_TYPE) || (traceDecl
-                .getType() == CTFParser.CTF_EXPRESSION_VAL));
+        assert ((traceDecl.getType() == CTFParser.CTF_EXPRESSION_TYPE) ||
+                (traceDecl.getType() == CTFParser.CTF_EXPRESSION_VAL));
 
         /* There should be a left and right */
         assert (traceDecl.getChildCount() == 2);
@@ -395,6 +393,17 @@ public class IOStructGen {
                 }
             } else {
                 trace.setByteOrder(byteOrder);
+                final DeclarationScope parentScope = scope.getParentScope();
+                String types[] = parentScope.getTypeNames();
+
+                for (String type : types) {
+                    IDeclaration d = parentScope.lookupType(type);
+                    if (d instanceof IntegerDeclaration) {
+                        addByteOrder(byteOrder, parentScope, type, (IntegerDeclaration) d);
+                    } else if (d instanceof StructDeclaration) {
+                        setAlign(parentScope, (StructDeclaration) d, byteOrder);
+                    }
+                }
             }
         } else if (left.equals(CTFStrings.PACKET_HEADER)) {
             if (trace.packetHeaderIsSet()) {
@@ -421,6 +430,66 @@ public class IOStructGen {
         }
     }
 
+    private static void addByteOrder(ByteOrder byteOrder,
+            final DeclarationScope parentScope, String name,
+            IntegerDeclaration decl) throws ParseException {
+
+        if (decl.getByteOrder() == null) {
+            IntegerDeclaration newI;
+            newI = new IntegerDeclaration(decl.getLength(), decl.isSigned(),
+                    decl.getBase(), byteOrder, decl.getEncoding(),
+                    decl.getClock(), decl.getAlignment());
+            parentScope.replaceType(name, newI);
+        }
+    }
+
+    private void setAlign(DeclarationScope parentScope, StructDeclaration sd,
+            ByteOrder byteOrder) throws ParseException {
+
+        for (String s : sd.getFieldsList()) {
+            IDeclaration d = sd.getFields().get(s);
+
+            if (d instanceof StructDeclaration) {
+                setAlign(parentScope, (StructDeclaration) d, byteOrder);
+
+            } else if (d instanceof VariantDeclaration) {
+                setAlign(parentScope, (VariantDeclaration) d, byteOrder);
+
+            } else if (d instanceof IntegerDeclaration) {
+                IntegerDeclaration decl = (IntegerDeclaration) d;
+                if (decl.getByteOrder() == null) {
+                    IntegerDeclaration newI;
+                    newI = new IntegerDeclaration(decl.getLength(),
+                            decl.isSigned(), decl.getBase(), byteOrder,
+                            decl.getEncoding(), decl.getClock(),
+                            decl.getAlignment());
+                    sd.getFields().put(s, newI);
+                }
+            }
+        }
+    }
+
+    private void setAlign(DeclarationScope parentScope, VariantDeclaration vd,
+            ByteOrder byteOrder) throws ParseException {
+
+        for (String s : vd.getFields().keySet()) {
+            IDeclaration d = vd.getFields().get(s);
+
+            if (d instanceof StructDeclaration) {
+                setAlign(parentScope, (StructDeclaration) d, byteOrder);
+
+            } else if (d instanceof IntegerDeclaration) {
+                IntegerDeclaration decl = (IntegerDeclaration) d;
+                IntegerDeclaration newI;
+                newI = new IntegerDeclaration(decl.getLength(),
+                        decl.isSigned(), decl.getBase(), byteOrder,
+                        decl.getEncoding(), decl.getClock(),
+                        decl.getAlignment());
+                vd.getFields().put(s, newI);
+            }
+        }
+    }
+
     private void parseStream(CommonTree streamNode) throws ParseException {
         assert (streamNode.getType() == CTFParser.STREAM);
 
@@ -466,8 +535,7 @@ public class IOStructGen {
 
     private void parseStreamDeclaration(CommonTree streamDecl, Stream stream)
             throws ParseException {
-        assert ((streamDecl.getType() == CTFParser.CTF_EXPRESSION_TYPE) || (streamDecl
-                .getType() == CTFParser.CTF_EXPRESSION_VAL));
+        assert ((streamDecl.getType() == CTFParser.CTF_EXPRESSION_TYPE) || (streamDecl.getType() == CTFParser.CTF_EXPRESSION_VAL));
 
         /* There should be a left and right */
         assert (streamDecl.getChildCount() == 2);
@@ -630,8 +698,7 @@ public class IOStructGen {
 
     private void parseEventDeclaration(CommonTree eventDecl,
             EventDeclaration event) throws ParseException {
-        assert ((eventDecl.getType() == CTFParser.CTF_EXPRESSION_TYPE) || (eventDecl
-                .getType() == CTFParser.CTF_EXPRESSION_VAL));
+        assert ((eventDecl.getType() == CTFParser.CTF_EXPRESSION_TYPE) || (eventDecl.getType() == CTFParser.CTF_EXPRESSION_VAL));
 
         /* There should be a left and right */
         assert (eventDecl.getChildCount() == 2);
@@ -937,8 +1004,7 @@ public class IOStructGen {
 
             typeDeclarator = (CommonTree) typeDeclaratorList.getChild(0);
 
-            List<CommonTree> typeDeclaratorChildren = typeDeclarator
-                    .getChildren();
+            List<CommonTree> typeDeclaratorChildren = typeDeclarator.getChildren();
             assert (typeDeclaratorChildren != null);
 
             for (CommonTree child : typeDeclaratorChildren) {
@@ -972,16 +1038,13 @@ public class IOStructGen {
     private void parseTypedef(CommonTree typedef) throws ParseException {
         assert (typedef.getType() == CTFParser.TYPEDEF);
 
-        CommonTree typeDeclaratorListNode = (CommonTree) typedef
-                .getFirstChildWithType(CTFParser.TYPE_DECLARATOR_LIST);
+        CommonTree typeDeclaratorListNode = (CommonTree) typedef.getFirstChildWithType(CTFParser.TYPE_DECLARATOR_LIST);
         assert (typeDeclaratorListNode != null);
 
-        CommonTree typeSpecifierListNode = (CommonTree) typedef
-                .getFirstChildWithType(CTFParser.TYPE_SPECIFIER_LIST);
+        CommonTree typeSpecifierListNode = (CommonTree) typedef.getFirstChildWithType(CTFParser.TYPE_SPECIFIER_LIST);
         assert (typeSpecifierListNode != null);
 
-        List<CommonTree> typeDeclaratorList = typeDeclaratorListNode
-                .getChildren();
+        List<CommonTree> typeDeclaratorList = typeDeclaratorListNode.getChildren();
         assert (typeDeclaratorList != null);
 
         for (CommonTree typeDeclaratorNode : typeDeclaratorList) {
@@ -1478,8 +1541,7 @@ public class IOStructGen {
                 hasName = true;
 
                 assert (child.getChildCount() == 1);
-                CommonTree structNameIdentifier = (CommonTree) child
-                        .getChild(0);
+                CommonTree structNameIdentifier = (CommonTree) child.getChild(0);
 
                 assert (structNameIdentifier.getType() == CTFParser.IDENTIFIER);
                 structName = structNameIdentifier.getText();
@@ -1495,8 +1557,7 @@ public class IOStructGen {
             }
             case CTFParser.ALIGN: {
                 assert (child.getChildCount() == 1);
-                CommonTree structAlignExpression = (CommonTree) child
-                        .getChild(0);
+                CommonTree structAlignExpression = (CommonTree) child.getChild(0);
 
                 structAlign = getAlignment(structAlignExpression);
 
@@ -1633,18 +1694,15 @@ public class IOStructGen {
         assert (children != null);
 
         /* Get the type specifier list node */
-        CommonTree typeSpecifierListNode = (CommonTree) declaration
-                .getFirstChildWithType(CTFParser.TYPE_SPECIFIER_LIST);
+        CommonTree typeSpecifierListNode = (CommonTree) declaration.getFirstChildWithType(CTFParser.TYPE_SPECIFIER_LIST);
         assert (typeSpecifierListNode != null);
 
         /* Get the type declarator list node */
-        CommonTree typeDeclaratorListNode = (CommonTree) declaration
-                .getFirstChildWithType(CTFParser.TYPE_DECLARATOR_LIST);
+        CommonTree typeDeclaratorListNode = (CommonTree) declaration.getFirstChildWithType(CTFParser.TYPE_DECLARATOR_LIST);
         assert (typeDeclaratorListNode != null);
 
         /* Get the type declarator list */
-        List<CommonTree> typeDeclaratorList = typeDeclaratorListNode
-                .getChildren();
+        List<CommonTree> typeDeclaratorList = typeDeclaratorListNode.getChildren();
         assert (typeDeclaratorList != null);
 
         /*
@@ -1933,8 +1991,7 @@ public class IOStructGen {
 
         /* Get the child, which should be a type specifier list */
         assert (enumContainerType.getChildCount() == 1);
-        CommonTree typeSpecifierList = (CommonTree) enumContainerType
-                .getChild(0);
+        CommonTree typeSpecifierList = (CommonTree) enumContainerType.getChild(0);
 
         /* Parse it and get the corresponding declaration */
         IDeclaration decl = parseTypeSpecifierList(typeSpecifierList, null);
@@ -1970,8 +2027,7 @@ public class IOStructGen {
                 hasName = true;
 
                 assert (child.getChildCount() == 1);
-                CommonTree variantNameIdentifier = (CommonTree) child
-                        .getChild(0);
+                CommonTree variantNameIdentifier = (CommonTree) child.getChild(0);
 
                 assert (variantNameIdentifier.getType() == CTFParser.IDENTIFIER);
                 variantName = variantNameIdentifier.getText();
@@ -1983,8 +2039,7 @@ public class IOStructGen {
                 hasTag = true;
 
                 assert (child.getChildCount() == 1);
-                CommonTree variantTagIdentifier = (CommonTree) child
-                        .getChild(0);
+                CommonTree variantTagIdentifier = (CommonTree) child.getChild(0);
 
                 assert (variantTagIdentifier.getType() == CTFParser.IDENTIFIER);
                 variantTag = variantTagIdentifier.getText();
@@ -2095,18 +2150,15 @@ public class IOStructGen {
         assert (children != null);
 
         /* Get the type specifier list node */
-        CommonTree typeSpecifierListNode = (CommonTree) declaration
-                .getFirstChildWithType(CTFParser.TYPE_SPECIFIER_LIST);
+        CommonTree typeSpecifierListNode = (CommonTree) declaration.getFirstChildWithType(CTFParser.TYPE_SPECIFIER_LIST);
         assert (typeSpecifierListNode != null);
 
         /* Get the type declarator list node */
-        CommonTree typeDeclaratorListNode = (CommonTree) declaration
-                .getFirstChildWithType(CTFParser.TYPE_DECLARATOR_LIST);
+        CommonTree typeDeclaratorListNode = (CommonTree) declaration.getFirstChildWithType(CTFParser.TYPE_DECLARATOR_LIST);
         assert (typeDeclaratorListNode != null);
 
         /* Get the type declarator list */
-        List<CommonTree> typeDeclaratorList = typeDeclaratorListNode
-                .getChildren();
+        List<CommonTree> typeDeclaratorList = typeDeclaratorListNode.getChildren();
         assert (typeDeclaratorList != null);
 
         /*
@@ -2213,40 +2265,35 @@ public class IOStructGen {
             sb.append(typeSpecifier.getText());
             break;
         case CTFParser.STRUCT: {
-            CommonTree structName = (CommonTree) typeSpecifier
-                    .getFirstChildWithType(CTFParser.STRUCT_NAME);
+            CommonTree structName = (CommonTree) typeSpecifier.getFirstChildWithType(CTFParser.STRUCT_NAME);
             if (structName == null) {
                 throw new ParseException(
                         "nameless struct found in createTypeSpecifierString"); //$NON-NLS-1$
             }
             assert (structName.getChildCount() == 1);
 
-            CommonTree structNameIdentifier = (CommonTree) structName
-                    .getChild(0);
+            CommonTree structNameIdentifier = (CommonTree) structName.getChild(0);
             assert (structNameIdentifier.getType() == CTFParser.IDENTIFIER);
 
             sb.append(structNameIdentifier.getText());
             break;
         }
         case CTFParser.VARIANT: {
-            CommonTree variantName = (CommonTree) typeSpecifier
-                    .getFirstChildWithType(CTFParser.VARIANT_NAME);
+            CommonTree variantName = (CommonTree) typeSpecifier.getFirstChildWithType(CTFParser.VARIANT_NAME);
             if (variantName == null) {
                 throw new ParseException(
                         "nameless variant found in createTypeSpecifierString"); //$NON-NLS-1$
             }
             assert (variantName.getChildCount() == 1);
 
-            CommonTree variantNameIdentifier = (CommonTree) variantName
-                    .getChild(0);
+            CommonTree variantNameIdentifier = (CommonTree) variantName.getChild(0);
             assert (variantNameIdentifier.getType() == CTFParser.IDENTIFIER);
 
             sb.append(variantNameIdentifier.getText());
             break;
         }
         case CTFParser.ENUM: {
-            CommonTree enumName = (CommonTree) typeSpecifier
-                    .getFirstChildWithType(CTFParser.ENUM_NAME);
+            CommonTree enumName = (CommonTree) typeSpecifier.getFirstChildWithType(CTFParser.ENUM_NAME);
             if (enumName == null) {
                 throw new ParseException(
                         "nameless enum found in createTypeSpecifierString"); //$NON-NLS-1$
@@ -2315,8 +2362,8 @@ public class IOStructGen {
      * @return True if the given node is an unary string.
      */
     private static boolean isUnaryString(CommonTree node) {
-        return ((node.getType() == CTFParser.UNARY_EXPRESSION_STRING) || (node
-                .getType() == CTFParser.UNARY_EXPRESSION_STRING_QUOTES));
+        return ((node.getType() == CTFParser.UNARY_EXPRESSION_STRING) ||
+                (node.getType() == CTFParser.UNARY_EXPRESSION_STRING_QUOTES));
     }
 
     /**
@@ -2325,9 +2372,9 @@ public class IOStructGen {
      * @return True if the given node is an unary integer.
      */
     private static boolean isUnaryInteger(CommonTree node) {
-        return ((node.getType() == CTFParser.UNARY_EXPRESSION_DEC)
-                || (node.getType() == CTFParser.UNARY_EXPRESSION_HEX) || (node
-                    .getType() == CTFParser.UNARY_EXPRESSION_OCT));
+        return ((node.getType() == CTFParser.UNARY_EXPRESSION_DEC) ||
+                (node.getType() == CTFParser.UNARY_EXPRESSION_HEX) ||
+                (node.getType() == CTFParser.UNARY_EXPRESSION_OCT));
     }
 
     /**
index db406d00f20e1a3270acb6c046fd1be461f48b7b..90582aa6433a57d92fec8464b1c9e486be46a12d 100644 (file)
    <requires>
       <import plugin="org.eclipse.core.runtime" version="3.7.0" match="greaterOrEqual"/>
       <import plugin="org.antlr.runtime" version="3.2.0" match="greaterOrEqual"/>
-      <import plugin="org.eclipse.linuxtools.ctf.parser" version="1.0.0" match="greaterOrEqual"/>
    </requires>
 
    <plugin
-         id="org.eclipse.linuxtools.ctf.core"
+         id="org.eclipse.linuxtools.ctf.parser"
          download-size="0"
          install-size="0"
-         version="0.0.0"
-         unpack="false"/>
+         version="0.0.0"/>
 
    <plugin
-         id="org.eclipse.linuxtools.ctf.parser"
+         id="org.eclipse.linuxtools.ctf.core"
          download-size="0"
          install-size="0"
-         version="0.0.0"/>
+         version="0.0.0"
+         unpack="false"/>
 
 </feature>
index 4877df630a7af50d3829a510605830d93430fb54..4c6da56f8c5bb3e012b993799ab4a9a0ae99a69b 100644 (file)
@@ -727,7 +727,6 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker,
             content[i] = fields[i].getValue() != null ? fields[i].getValue().toString() : ""; //$NON-NLS-1$
         }
         item.setText(content);
-        item.setData(event);
         item.setData(Key.TIMESTAMP, new TmfTimestamp(event.getTimestamp()));
         item.setData(Key.RANK, rank);
 
@@ -820,7 +819,6 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker,
                 item.setText(i, ""); //$NON-NLS-1$
             }
         }
-        item.setData(null);
         item.setData(Key.TIMESTAMP, null);
         item.setData(Key.RANK, null);
         item.setForeground(null);
@@ -1284,6 +1282,7 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker,
         protected long rank;
         protected long foundRank = -1;
         protected TmfDataRequest request;
+        private ITmfTimestamp foundTimestamp = null;
 
         public SearchThread(final ITmfFilterTreeNode searchFilter, final ITmfFilterTreeNode eventFilter, final int startIndex,
                 final long currentRank, final int direction) {
@@ -1315,6 +1314,7 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker,
                     rank = event.rank;
                     if (searchFilter.matches(event.event) && ((eventFilter == null) || eventFilter.matches(event.event))) {
                         foundRank = event.rank;
+                        foundTimestamp = event.event.getTimestamp();
                         break;
                     }
                     if (direction == Direction.FORWARD) {
@@ -1352,6 +1352,7 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker,
                         super.handleData(event);
                         if (searchFilter.matches(event) && ((eventFilter == null) || eventFilter.matches(event))) {
                             foundRank = currentRank;
+                            foundTimestamp = event.getTimestamp();
                             if (direction == Direction.FORWARD) {
                                 done();
                                 return;
@@ -1415,6 +1416,10 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker,
                     }
                     fTable.setSelection(selection);
                     fSelectedRank = foundRank;
+                    fRawViewer.selectAndReveal(fSelectedRank);
+                    if (foundTimestamp != null) {
+                        broadcast(new TmfTimeSynchSignal(TmfEventsTable.this, foundTimestamp));
+                    }
                     synchronized (fSearchSyncObj) {
                         fSearchThread = null;
                     }
This page took 0.035577 seconds and 5 git commands to generate.