ctf: fix parser not parsing "thing := keyword typealias;" regression
authorMatthew Khouzam <matthew.khouzam@ericsson.com>
Thu, 23 Jul 2015 15:35:11 +0000 (11:35 -0400)
committerMatthew Khouzam <matthew.khouzam@ericsson.com>
Fri, 24 Jul 2015 13:32:42 +0000 (09:32 -0400)
This regression was introduced when dynamic scopes added stricter checks
to tsdl parsing. The checks are good, this fix will extract the pertinent
data before the check.

Change-Id: Id0e0571973569f219339b3733545286a0b53face
Signed-off-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/52447
Reviewed-by: Hudson CI
Reviewed-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
Tested-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/event/metadata/IOStructGen.java

index ab2cb4770c20432ae7d7357287974f6094569a20..a2787fafec9f48dd7c843ff2318d58c70e7c895c 100644 (file)
@@ -25,6 +25,7 @@ import java.util.Set;
 import java.util.UUID;
 
 import org.antlr.runtime.tree.CommonTree;
+import org.antlr.runtime.tree.Tree;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.Nullable;
@@ -609,7 +610,7 @@ public class IOStructGen {
 
             IDeclaration eventHeaderDecl = parseTypeSpecifierList(typeSpecifier);
             DeclarationScope scope = getCurrentScope();
-            DeclarationScope eventHeaderScope = scope.lookupChildRecursive(MetadataStrings.STRUCT);
+            DeclarationScope eventHeaderScope = lookupStructName(typeSpecifier, scope);
             if (eventHeaderScope == null) {
                 throw new ParseException("event.header scope not found"); //$NON-NLS-1$
             }
@@ -666,6 +667,32 @@ public class IOStructGen {
         }
     }
 
+    private static DeclarationScope lookupStructName(CommonTree typeSpecifier, DeclarationScope scope) {
+        /*
+         * This needs a struct.struct_name.name to work, luckily, that is 99.99%
+         * of traces we receive.
+         */
+        final Tree potentialStruct = typeSpecifier.getChild(0);
+        DeclarationScope eventHeaderScope = null;
+        if (potentialStruct.getType() == (CTFParser.STRUCT)) {
+            final Tree potentialStructName = potentialStruct.getChild(0);
+            if (potentialStructName.getType() == (CTFParser.STRUCT_NAME)) {
+                final String name = potentialStructName.getChild(0).getText();
+                eventHeaderScope = scope.lookupChildRecursive(name);
+            }
+        }
+        /*
+         * If that fails, maybe the struct is anonymous
+         */
+        if (eventHeaderScope == null) {
+            eventHeaderScope = scope.lookupChildRecursive(MetadataStrings.STRUCT);
+        }
+        /*
+         * This can still be null
+         */
+        return eventHeaderScope;
+    }
+
     private void parseEvent(CommonTree eventNode) throws ParseException {
 
         List<CommonTree> children = eventNode.getChildren();
This page took 0.026651 seconds and 5 git commands to generate.