aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandre Montplaisir2012-03-14 15:00:37 (EDT)
committerFrancois Chouinard2012-03-19 17:43:47 (EDT)
commit5d5902a323109ca9ef4510593f762b82d133613d (patch)
treed47c3f16c1aeccb61257a541531116ba6f94702f
parent4cc0a4c7e7e0f17b65f9ee96a7ae880f54e81f59 (diff)
downloadorg.eclipse.linuxtools-5d5902a323109ca9ef4510593f762b82d133613d.zip
org.eclipse.linuxtools-5d5902a323109ca9ef4510593f762b82d133613d.tar.gz
org.eclipse.linuxtools-5d5902a323109ca9ef4510593f762b82d133613d.tar.bz2
Restore extra checks in SequenceDefinition's constructor
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/SequenceDeclaration.java12
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/SequenceDefinition.java37
2 files changed, 31 insertions, 18 deletions
diff --git a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/SequenceDeclaration.java b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/SequenceDeclaration.java
index 609ea46..8532e6e 100644
--- a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/SequenceDeclaration.java
+++ b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/SequenceDeclaration.java
@@ -12,6 +12,8 @@
package org.eclipse.linuxtools.ctf.core.event.types;
+import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException;
+
/**
* <b><u>SequenceDeclaration</u></b>
*/
@@ -52,7 +54,15 @@ public class SequenceDeclaration implements IDeclaration {
@Override
public SequenceDefinition createDefinition(
IDefinitionScope definitionScope, String fieldName) {
- return new SequenceDefinition(this, definitionScope, fieldName);
+ SequenceDefinition ret = null;
+ try {
+ ret = new SequenceDefinition(this, definitionScope, fieldName);
+ } catch (CTFReaderException e) {
+ // Temporarily catch this here, eventually this should be thrown
+ // up the call stack
+ e.printStackTrace();
+ }
+ return ret;
}
@Override
diff --git a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/SequenceDefinition.java b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/SequenceDefinition.java
index 3f29d1f..9a7a1bd 100644
--- a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/SequenceDefinition.java
+++ b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/SequenceDefinition.java
@@ -13,6 +13,7 @@
package org.eclipse.linuxtools.ctf.core.event.types;
import org.eclipse.linuxtools.ctf.core.event.io.BitBuffer;
+import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException;
/**
* <b><u>SequenceDefinition</u></b>
@@ -24,7 +25,7 @@ public class SequenceDefinition extends Definition {
// ------------------------------------------------------------------------
private final SequenceDeclaration declaration;
- private IntegerDefinition lengthDefinition;
+ private final IntegerDefinition lengthDefinition;
private Definition definitions[];
private int currentLength;
@@ -33,27 +34,29 @@ public class SequenceDefinition extends Definition {
// ------------------------------------------------------------------------
public SequenceDefinition(SequenceDeclaration declaration,
- IDefinitionScope definitionScope, String fieldName) {
+ IDefinitionScope definitionScope, String fieldName) throws CTFReaderException {
super(definitionScope, fieldName);
-
+ Definition lenDef = null;
+
this.declaration = declaration;
- // this.definitionScope = definitionScope;
if (definitionScope != null) {
- Definition lenDef = definitionScope.lookupDefinition(declaration.getLengthName());
- lengthDefinition = (IntegerDefinition) lenDef;
+ lenDef = definitionScope.lookupDefinition(declaration.getLengthName());
+ }
+
+ if (lenDef == null) {
+ throw new CTFReaderException("Sequence length field not found"); //$NON-NLS-1$
+ }
+
+ if (!(lenDef instanceof IntegerDefinition)) {
+ throw new CTFReaderException("Sequence length field not integer"); //$NON-NLS-1$
+ }
+
+ lengthDefinition = (IntegerDefinition) lenDef;
+
+ if (this.lengthDefinition.getDeclaration().isSigned()) {
+ throw new CTFReaderException("Sequence length must not be signed"); //$NON-NLS-1$
}
- /*
- * if (lenDef == null) { throw new
- * Exception("Sequence length field not found"); }
- *
- * if (!(lenDef instanceof IntegerDefinition)) { throw new
- * Exception("Sequence length field not integer"); }
- */
- /*
- * if (this.lengthDefinition.declaration.signed) { throw new
- * Exception("Sequence length must not be signed"); }
- */
}
// ------------------------------------------------------------------------