Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/lttng
diff options
context:
space:
mode:
authorMatthew Khouzam2014-12-04 03:29:40 +0000
committerMatthew Khouzam2014-12-19 19:25:44 +0000
commit081483010c64d829fa1f2b4a415f9ac82be6dd49 (patch)
treea972e2238418229d95cbc4edaa538edf2ee45e73 /lttng
parent36ac3bd73b38abbbb2d21eca55cc3487ffb59645 (diff)
downloadorg.eclipse.linuxtools-081483010c64d829fa1f2b4a415f9ac82be6dd49.tar.gz
org.eclipse.linuxtools-081483010c64d829fa1f2b4a415f9ac82be6dd49.tar.xz
org.eclipse.linuxtools-081483010c64d829fa1f2b4a415f9ac82be6dd49.zip
tmf: ctf: add support for traces with changing endianess
The issue is that IOStructGen assumed the endianness of a trace did not change half way through the tsdl file. Now the elements are progressively loaded and thus the endinanness is updated as need be. Fixes bug 453673 Change-Id: Ia4a91005a89e437eb0fc92cb73c635bb5674767d Signed-off-by: Matthew Khouzam <matthew.khouzam@ericsson.com> Reviewed-on: https://git.eclipse.org/r/37531 Tested-by: Hudson CI Reviewed-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com> Tested-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
Diffstat (limited to 'lttng')
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/event/metadata/IOStructGen.java93
1 files changed, 24 insertions, 69 deletions
diff --git a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/event/metadata/IOStructGen.java b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/event/metadata/IOStructGen.java
index fc889461f4..f50bfa6a28 100644
--- a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/event/metadata/IOStructGen.java
+++ b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/event/metadata/IOStructGen.java
@@ -49,6 +49,8 @@ import org.eclipse.linuxtools.internal.ctf.core.event.types.StructDeclarationFla
import org.eclipse.linuxtools.internal.ctf.core.event.types.composite.EventHeaderCompactDeclaration;
import org.eclipse.linuxtools.internal.ctf.core.event.types.composite.EventHeaderLargeDeclaration;
+import com.google.common.collect.Iterables;
+
/**
* IOStructGen
*/
@@ -158,96 +160,69 @@ public class IOStructGen {
private void parseRoot(CommonTree root) throws ParseException {
List<CommonTree> children = root.getChildren();
+ List<CommonTree> events = new ArrayList<>();
CommonTree traceNode = null;
- List<CommonTree> streams = new ArrayList<>();
- List<CommonTree> events = new ArrayList<>();
- List<CommonTree> declarations = new ArrayList<>();
- List<CommonTree> environments = new ArrayList<>();
- List<CommonTree> clocks = new ArrayList<>();
- List<CommonTree> callsites = new ArrayList<>();
+ boolean hasStreams = false;
/* Create a new declaration scope with no parent. */
pushScope();
-
for (CommonTree child : children) {
final int type = child.getType();
switch (type) {
case CTFParser.DECLARATION:
- declarations.add(child);
+ parseRootDeclaration(child);
break;
case CTFParser.TRACE:
if (traceNode != null) {
throw new ParseException("Only one trace block is allowed"); //$NON-NLS-1$
}
traceNode = child;
+ parseTrace(traceNode);
break;
case CTFParser.STREAM:
- streams.add(child);
+ parseStream(child);
+ hasStreams = true;
break;
case CTFParser.EVENT:
events.add(child);
break;
case CTFParser.CLOCK:
- clocks.add(child);
+ parseClock(child);
break;
case CTFParser.ENV:
- environments.add(child);
+ parseEnvironment(child);
break;
case CTFParser.CALLSITE:
- callsites.add(child);
+ parseCallsite(child);
break;
default:
childTypeError(child);
}
}
- for (CommonTree decl : declarations) {
- parseRootDeclaration(decl);
- }
if (traceNode == null) {
throw new ParseException("Missing trace block"); //$NON-NLS-1$
}
+ parseEvents(events, hasStreams);
+ popScope();
+ fHasBeenParsed = true;
+ }
- parseTrace(traceNode);
-
- for (CommonTree environment : environments) {
- parseEnvironment(environment);
- }
- for (CommonTree clock : clocks) {
- parseClock(clock);
- }
- for (CommonTree callsite : callsites) {
- parseCallsite(callsite);
- }
-
- if (!streams.isEmpty()) {
- for (CommonTree stream : streams) {
- parseStream(stream);
- }
- } else {
- /* Add an empty stream that will have a null id */
+ private void parseEvents(List<CommonTree> events, boolean hasStreams) throws ParseException {
+ if (!hasStreams && !events.isEmpty()) {
fTrace.addStream(new CTFStream(fTrace));
}
-
for (CommonTree event : events) {
parseEvent(event);
}
- popScope();
- fHasBeenParsed = true;
}
private void parseIncompleteRoot(CommonTree root) throws ParseException {
- List<CommonTree> children = root.getChildren();
-
if (!fHasBeenParsed) {
throw new ParseException("You need to run generate first"); //$NON-NLS-1$
}
- List<CommonTree> streams = new ArrayList<>();
+ List<CommonTree> children = root.getChildren();
List<CommonTree> events = new ArrayList<>();
- List<CommonTree> declarations = new ArrayList<>();
- List<CommonTree> environments = new ArrayList<>();
- List<CommonTree> clocks = new ArrayList<>();
- List<CommonTree> callsites = new ArrayList<>();
/* Create a new declaration scope with no parent. */
pushScope();
@@ -255,50 +230,30 @@ public class IOStructGen {
final int type = child.getType();
switch (type) {
case CTFParser.DECLARATION:
- declarations.add(child);
+ parseRootDeclaration(child);
break;
case CTFParser.TRACE:
throw new ParseException("Trace block defined here, please use generate and not generateFragment to parse this fragment"); //$NON-NLS-1$
case CTFParser.STREAM:
- streams.add(child);
+ parseStream(child);
break;
case CTFParser.EVENT:
events.add(child);
break;
case CTFParser.CLOCK:
- clocks.add(child);
+ parseClock(child);
break;
case CTFParser.ENV:
- environments.add(child);
+ parseEnvironment(child);
break;
case CTFParser.CALLSITE:
- callsites.add(child);
+ parseCallsite(child);
break;
default:
childTypeError(child);
}
}
- for (CommonTree decl : declarations) {
- parseRootDeclaration(decl);
- }
-
- for (CommonTree environment : environments) {
- parseEnvironment(environment);
- }
- for (CommonTree clock : clocks) {
- parseClock(clock);
- }
- for (CommonTree callsite : callsites) {
- parseCallsite(callsite);
- }
-
- for (CommonTree stream : streams) {
- parseStream(stream);
- }
-
- for (CommonTree event : events) {
- parseEvent(event);
- }
+ parseEvents(events, !Iterables.isEmpty(fTrace.getStreams()));
popScope();
}

Back to the top