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
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>
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/types/EventHeaderDeclarationTest.java19
-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
3 files changed, 37 insertions, 9 deletions
diff --git a/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/types/EventHeaderDeclarationTest.java b/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/types/EventHeaderDeclarationTest.java
index 6a7b5b0b75..e5a8c0d758 100644
--- a/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/types/EventHeaderDeclarationTest.java
+++ b/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/types/EventHeaderDeclarationTest.java
@@ -19,6 +19,7 @@ import java.util.ArrayList;
import java.util.List;
import org.eclipse.linuxtools.ctf.core.event.io.BitBuffer;
+import org.eclipse.linuxtools.ctf.core.event.types.Encoding;
import org.eclipse.linuxtools.ctf.core.event.types.EnumDeclaration;
import org.eclipse.linuxtools.ctf.core.event.types.FloatDeclaration;
import org.eclipse.linuxtools.ctf.core.event.types.IntegerDeclaration;
@@ -75,12 +76,16 @@ public class EventHeaderDeclarationTest {
*/
StructDeclaration base = new StructDeclaration(8);
- base.addField("id", new EnumDeclaration(IntegerDeclaration.UINT_5B_DECL));
+ EnumDeclaration enumDec = new EnumDeclaration(IntegerDeclaration.createDeclaration(5, false,
+ 10, ByteOrder.BIG_ENDIAN, Encoding.NONE, "", 1));
+ enumDec.add(0, 30, "compact");
+ enumDec.add(31, 31, "extended");
+ base.addField("id", enumDec);
VariantDeclaration variantV = new VariantDeclaration();
- StructDeclaration compact = new StructDeclaration(8);
- compact.addField("timestamp", IntegerDeclaration.UINT_27B_DECL);
+ StructDeclaration compact = new StructDeclaration(1);
+ compact.addField("timestamp", IntegerDeclaration.createDeclaration(27, false, 10, ByteOrder.BIG_ENDIAN, Encoding.NONE, "", 1));
variantV.addField("compact", compact);
- StructDeclaration large = new StructDeclaration(8);
+ StructDeclaration large = new StructDeclaration(1);
large.addField("id", IntegerDeclaration.UINT_32B_DECL);
large.addField("timestamp", IntegerDeclaration.UINT_64B_DECL);
variantV.addField("extended", large);
@@ -107,7 +112,11 @@ public class EventHeaderDeclarationTest {
*/
base = new StructDeclaration(8);
- base.addField("id", new EnumDeclaration(IntegerDeclaration.UINT_16B_DECL));
+ enumDec = new EnumDeclaration(IntegerDeclaration.createDeclaration(16, false,
+ 10, ByteOrder.BIG_ENDIAN, Encoding.NONE, "", 1));
+ enumDec.add(0, 30, "compact");
+ enumDec.add(31, 31, "extended");
+ base.addField("id", enumDec);
variantV = new VariantDeclaration();
compact = new StructDeclaration(8);
compact.addField("timestamp", IntegerDeclaration.UINT_32B_DECL);
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