Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Khouzam2014-11-07 22:11:24 +0000
committerMatthew Khouzam2014-11-18 18:56:58 +0000
commit7d3e68110d50c87d8edf336efeb1afd2d53b010f (patch)
tree5348e9e7c89757fb97562f6ae33063434b2c4a43 /lttng/org.eclipse.linuxtools.ctf.core/src/org
parent9e1aea82a55afc6a84d7c54783c08bf3e9509573 (diff)
downloadorg.eclipse.linuxtools-7d3e68110d50c87d8edf336efeb1afd2d53b010f.tar.gz
org.eclipse.linuxtools-7d3e68110d50c87d8edf336efeb1afd2d53b010f.tar.xz
org.eclipse.linuxtools-7d3e68110d50c87d8edf336efeb1afd2d53b010f.zip
ctf: better test event headers (bug 446190)
This fixes a problem with non 8 bit aligned event headers. Before the alignemnt was assumed to be 8 bits, now it is checked. Change-Id: Ib938755d6191bbe8fea34400f5e5183cb2dd7035 Signed-off-by: Matthew Khouzam <matthew.khouzam@ericsson.com> Reviewed-on: https://git.eclipse.org/r/36168 Tested-by: Hudson CI Reviewed-by: Genevieve Bastien <gbastien+lttng@versatic.net>
Diffstat (limited to 'lttng/org.eclipse.linuxtools.ctf.core/src/org')
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/event/types/composite/EventHeaderCompactDeclaration.java14
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/event/types/composite/EventHeaderLargeDeclaration.java13
2 files changed, 23 insertions, 4 deletions
diff --git a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/event/types/composite/EventHeaderCompactDeclaration.java b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/event/types/composite/EventHeaderCompactDeclaration.java
index 58cbc2dcbe..c81e0f5cf9 100644
--- a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/event/types/composite/EventHeaderCompactDeclaration.java
+++ b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/event/types/composite/EventHeaderCompactDeclaration.java
@@ -58,6 +58,7 @@ public class EventHeaderCompactDeclaration extends Declaration implements IEvent
* The id is 5 bits
*/
private static final int COMPACT_ID = 5;
+ private static final int COMPACT_ALIGN = 1;
private static final int EXTENDED_VALUE = 31;
/**
* Full sized id is 32 bits
@@ -71,6 +72,7 @@ public class EventHeaderCompactDeclaration extends Declaration implements IEvent
* Compact timestamp is 27 bits,
*/
private static final int COMPACT_TS = 27;
+ private static final int COMPACT_TS_ALIGN = 1;
/**
* Maximum size = largest this header can be
*/
@@ -143,9 +145,14 @@ public class EventHeaderCompactDeclaration extends Declaration implements IEvent
return false;
}
EnumDeclaration eId = (EnumDeclaration) iDeclaration;
- if (eId.getContainerType().getLength() != COMPACT_ID) {
+ final IntegerDeclaration containerType = eId.getContainerType();
+ if (containerType.getLength() != COMPACT_ID) {
return false;
}
+ if (containerType.getAlignment() != COMPACT_ALIGN) {
+ return false;
+ }
+
iDeclaration = declaration.getFields().get(V);
if (!(iDeclaration instanceof VariantDeclaration)) {
@@ -174,7 +181,7 @@ public class EventHeaderCompactDeclaration extends Declaration implements IEvent
return false;
}
IntegerDeclaration tsDec = (IntegerDeclaration) iDeclaration;
- if (tsDec.getLength() != COMPACT_TS || tsDec.isSigned()) {
+ if (tsDec.getLength() != COMPACT_TS || tsDec.isSigned() || tsDec.getAlignment() != COMPACT_TS_ALIGN) {
return false;
}
iDeclaration = vDec.getFields().get(EXTENDED);
@@ -182,6 +189,9 @@ public class EventHeaderCompactDeclaration extends Declaration implements IEvent
return false;
}
StructDeclaration extendedDec = (StructDeclaration) iDeclaration;
+ if (extendedDec.getAlignment() != ALIGN) {
+ return false;
+ }
if (!extendedDec.hasField(TIMESTAMP)) {
return false;
}
diff --git a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/event/types/composite/EventHeaderLargeDeclaration.java b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/event/types/composite/EventHeaderLargeDeclaration.java
index 7b0acf0ce7..3a6ebfe74d 100644
--- a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/event/types/composite/EventHeaderLargeDeclaration.java
+++ b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/event/types/composite/EventHeaderLargeDeclaration.java
@@ -83,6 +83,8 @@ public class EventHeaderLargeDeclaration extends Declaration implements IEventHe
private static final int VARIANT_SIZE = 2;
private static final int COMPACT_SIZE = 1;
private static final int EXTENDED_FIELD_SIZE = 2;
+ private static final long COMPACT_ALIGN = 1;
+ private static final long COMPACT_TS_ALIGN = 8;
private final ByteOrder fByteOrder;
@@ -139,7 +141,11 @@ public class EventHeaderLargeDeclaration extends Declaration implements IEventHe
return false;
}
EnumDeclaration eId = (EnumDeclaration) iDeclaration;
- if (eId.getContainerType().getLength() != COMPACT_ID) {
+ final IntegerDeclaration containerType = eId.getContainerType();
+ if (containerType.getLength() != COMPACT_ID) {
+ return false;
+ }
+ if (containerType.getAlignment() != COMPACT_ALIGN) {
return false;
}
iDeclaration = declaration.getFields().get(V);
@@ -170,7 +176,7 @@ public class EventHeaderLargeDeclaration extends Declaration implements IEventHe
return false;
}
IntegerDeclaration tsDec = (IntegerDeclaration) iDeclaration;
- if (tsDec.getLength() != COMPACT_TS || tsDec.isSigned()) {
+ if (tsDec.getLength() != COMPACT_TS || tsDec.isSigned() || tsDec.getAlignment() != COMPACT_TS_ALIGN) {
return false;
}
iDeclaration = vDec.getFields().get(EXTENDED);
@@ -178,6 +184,9 @@ public class EventHeaderLargeDeclaration extends Declaration implements IEventHe
return false;
}
StructDeclaration extendedDec = (StructDeclaration) iDeclaration;
+ if (extendedDec.getAlignment() != ALIGN) {
+ return false;
+ }
if (!extendedDec.hasField(TIMESTAMP)) {
return false;
}

Back to the top