Skip to content
This repository has been archived by the owner on Nov 20, 2023. It is now read-only.

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

Open
compudj opened this issue Oct 31, 2018 · 1 comment
Open

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

compudj opened this issue Oct 31, 2018 · 1 comment

Comments

@compudj
Copy link

compudj commented Oct 31, 2018

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
Copy link
Member

jgalar commented Oct 31, 2018

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.

TheMatthew pushed a commit to tracecompass/tracecompass that referenced this issue Nov 2, 2018
Make implicitly declared enumerations have a value == range.max + 1

To be clear:

enum bob {4-7};
enum alice;

bob is added with a range of 4-7
alice is now added with a range of 8-8 instead of 5-8 as it was before

Link: lttng/lttng-scope#79
Reported-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Suggested-by: Jeremie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ic88b5749e1a19548f8c1342f54acf290a173a28d
Signed-off-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/131749
Tested-by: CI Bot
Reviewed-by: Patrick Tasse <patrick.tasse@gmail.com>
Tested-by: Patrick Tasse <patrick.tasse@gmail.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants