lttng / lttng-scope

A trace viewer and analyzer for LTTng kernel and user space traces
https://lttng.org/beta/#lttng-scope
Eclipse Public License 1.0
28 stars 6 forks source link

CTF parser enum: "auto" label following range does not parse #79

Open compudj opened 5 years ago

compudj commented 5 years ago

In CTF, enumerations support labels that map to ranges of values, labels that map to a single explicit value, and labels that map to an implicit value, which is inferred by using the previous label's value + 1, or previous label's range end + 1.

However, a CTF metadata containing an enum where a range label is followed by a label referring to an implicit value does not parse with the lttng scope CTF parser.

jgalar commented 5 years ago
diff --git a/ctfreader/src/main/java/org/eclipse/tracecompass/ctf/core/event/types/EnumDeclaration.java b/ctfreader/src/main/java/org/eclipse/tracecompass/ctf/core/event/types/EnumDeclaration.java
index e60092bb..5b0e87a7 100644
--- a/ctfreader/src/main/java/org/eclipse/tracecompass/ctf/core/event/types/EnumDeclaration.java
+++ b/ctfreader/src/main/java/org/eclipse/tracecompass/ctf/core/event/types/EnumDeclaration.java
@@ -218,7 +218,7 @@ public final class EnumDeclaration extends Declaration implements ISimpleDatatyp

         public synchronized boolean add(@Nullable String label) {
             LabelAndRange lastAdded = ranges.isEmpty() ? new LabelAndRange(-1, -1, "") : ranges.get(ranges.size() - 1); //$NON-NLS-1$
-            return add(lastAdded.low + 1, lastAdded.high + 1, label);
+            return add(lastAdded.high + 1, lastAdded.high + 1, label);
         }

         public synchronized boolean add(long low, long high, @Nullable String label) {

This appears to fix the problem.