import org.eclipse.test.performance.Dimension;
import org.eclipse.test.performance.Performance;
import org.eclipse.test.performance.PerformanceMeter;
-import org.eclipse.tracecompass.ctf.core.CTFReaderException;
+import org.eclipse.tracecompass.ctf.core.CTFException;
import org.eclipse.tracecompass.ctf.core.event.CTFCallsite;
import org.eclipse.tracecompass.ctf.core.tests.shared.CtfTestTrace;
import org.eclipse.tracecompass.ctf.core.trace.CTFTrace;
/**
* sets up the test by making a new trace.
*
- * @throws CTFReaderException
+ * @throws CTFException
* an exception from the reader
* @throws SecurityException
* an exception from accessing files illegally
* an exception for passing bad values
*/
@Before
- public void setup() throws CTFReaderException, SecurityException,
+ public void setup() throws CTFException, SecurityException,
IllegalArgumentException {
assumeTrue(testTrace.exists());
fTrace = new CTFTrace(testTrace.getPath());
import org.eclipse.test.performance.Dimension;
import org.eclipse.test.performance.Performance;
import org.eclipse.test.performance.PerformanceMeter;
-import org.eclipse.tracecompass.ctf.core.CTFReaderException;
+import org.eclipse.tracecompass.ctf.core.CTFException;
import org.eclipse.tracecompass.ctf.core.event.EventDefinition;
import org.eclipse.tracecompass.ctf.core.tests.shared.CtfTestTrace;
import org.eclipse.tracecompass.ctf.core.trace.CTFTrace;
traceReader.advance();
}
}
- } catch (CTFReaderException e) {
+ } catch (CTFException e) {
/* Should not happen if assumeTrue() passed above */
fail("Test failed at iteration " + loop + ':' + e.getMessage());
}
import org.eclipse.test.performance.Dimension;
import org.eclipse.test.performance.Performance;
import org.eclipse.test.performance.PerformanceMeter;
-import org.eclipse.tracecompass.ctf.core.CTFReaderException;
+import org.eclipse.tracecompass.ctf.core.CTFException;
import org.eclipse.tracecompass.ctf.core.event.EventDefinition;
import org.eclipse.tracecompass.ctf.core.tests.shared.CtfTestTrace;
import org.eclipse.tracecompass.ctf.core.trace.CTFTrace;
/**
* Run the benchmark scenario for the trace "kernel"
*
- * @throws CTFReaderException
+ * @throws CTFException
* Should not happen
*/
@Test
- public void testKernelTrace() throws CTFReaderException {
+ public void testKernelTrace() throws CTFException {
readAndSeekTrace(CtfTestTrace.KERNEL, "trace-kernel", true);
}
- private static void readAndSeekTrace(CtfTestTrace testTrace, String testName, boolean inGlobalSummary) throws CTFReaderException {
+ private static void readAndSeekTrace(CtfTestTrace testTrace, String testName, boolean inGlobalSummary) throws CTFException {
assumeTrue(testTrace.exists());
Performance perf = Performance.getDefault();
}
pm.stop();
- } catch (CTFReaderException e) {
+ } catch (CTFException e) {
/* Should not happen if assumeTrue() passed above */
fail("Test failed at iteration " + loop + ':' + e.getMessage());
}
import java.io.File;
-import org.eclipse.tracecompass.ctf.core.CTFReaderException;
+import org.eclipse.tracecompass.ctf.core.CTFException;
import org.eclipse.tracecompass.ctf.core.tests.synthetictraces.LttngKernelTraceGenerator;
import org.eclipse.tracecompass.ctf.core.trace.CTFTrace;
* before calling this!
*
* @return The CTFTrace object
- * @throws CTFReaderException
+ * @throws CTFException
* If the trace cannot be found.
*/
- public CTFTrace getTrace() throws CTFReaderException {
+ public CTFTrace getTrace() throws CTFException {
if (fTrace == null) {
fTrace = new CTFTrace(fPath);
}
* before calling this!
*
* @return The CTFTrace object
- * @throws CTFReaderException
+ * @throws CTFException
* If the trace cannot be found.
*/
- public CTFTrace getTraceFromFile() throws CTFReaderException {
+ public CTFTrace getTraceFromFile() throws CTFException {
if (fTraceFromFile == null) {
fTraceFromFile = new CTFTrace(new File(fPath));
}
public boolean exists() {
try {
getTrace();
- } catch (CTFReaderException e) {
+ } catch (CTFException e) {
return false;
}
return true;
import java.util.LinkedList;
import java.util.List;
-import org.eclipse.tracecompass.ctf.core.CTFReaderException;
+import org.eclipse.tracecompass.ctf.core.CTFException;
import org.eclipse.tracecompass.ctf.core.trace.CTFTrace;
import org.eclipse.tracecompass.ctf.core.trace.CTFTraceReader;
import org.junit.Rule;
checkIfWeShoudlSucceed();
}
- } catch (CTFReaderException e) {
+ } catch (CTFException e) {
checkIfWeShouldFail(e);
} catch (OutOfMemoryError e) {
checkIfWeShouldFail(e);
import java.nio.ByteOrder;
import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.tracecompass.ctf.core.CTFReaderException;
+import org.eclipse.tracecompass.ctf.core.CTFException;
import org.eclipse.tracecompass.ctf.core.event.io.BitBuffer;
import org.eclipse.tracecompass.ctf.core.event.types.Definition;
import org.eclipse.tracecompass.ctf.core.event.types.Encoding;
/**
* Run the CTFEventField parseField(Definition,String) method test.
*
- * @throws CTFReaderException
+ * @throws CTFException
*/
@Test
- public void testParseField_complex() throws CTFReaderException {
+ public void testParseField_complex() throws CTFException {
int len = 32;
IntegerDeclaration id = IntegerDeclaration.createDeclaration(
len,
/**
* Run the CTFEventField parseField(Definition,String) method test.
*
- * @throws CTFReaderException
+ * @throws CTFException
*/
@Test
- public void testParseField_simple() throws CTFReaderException {
+ public void testParseField_simple() throws CTFException {
final StringDeclaration elemType = StringDeclaration.getStringDeclaration(Encoding.UTF8);
byte[] bytes = { 'T', 'e', 's', 't', '\0' };
ByteBuffer bb = testMemory(ByteBuffer.wrap(bytes));
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
-import org.eclipse.tracecompass.ctf.core.CTFReaderException;
+import org.eclipse.tracecompass.ctf.core.CTFException;
import org.eclipse.tracecompass.ctf.core.event.io.BitBuffer;
import org.junit.Before;
import org.junit.Test;
/**
* Perform pre-test initialization.
*
- * @throws CTFReaderException
+ * @throws CTFException
* Out of bounds, won't happen
*/
@Before
- public void setUp() throws CTFReaderException {
+ public void setUp() throws CTFException {
ByteBuffer allocateDirect = ByteBuffer.allocateDirect(128);
if (allocateDirect == null) {
throw new IllegalStateException("Failed to allocate memory");
fixture = createBuffer();
}
- private static BitBuffer createBuffer() throws CTFReaderException {
+ private static BitBuffer createBuffer() throws CTFException {
return createBuffer(16);
}
- private static BitBuffer createBuffer(int j) throws CTFReaderException {
+ private static BitBuffer createBuffer(int j) throws CTFException {
final byte[] bytes = new byte[j];
for (int i = 0; i < j; i++) {
bytes[i] = (byte) (i % 0xff);
/**
* Test {@link BitBuffer#getInt} with a basic value
*
- * @throws CTFReaderException
+ * @throws CTFException
* Not expected
*/
@Test
- public void testGetInt_base() throws CTFReaderException {
+ public void testGetInt_base() throws CTFException {
int result = fixture.getInt();
assertEquals(0x020406, result);
}
/**
* Test {@link BitBuffer#getInt} with explicit seek at pos 0.
*
- * @throws CTFReaderException
+ * @throws CTFException
* Not expected
*/
@Test
- public void testGetInt_pos0() throws CTFReaderException {
+ public void testGetInt_pos0() throws CTFException {
fixture.position(0);
int result = fixture.getInt();
assertEquals(0x010203, result);
/**
* Test {@link BitBuffer#get} with seek at pos 1.
*
- * @throws CTFReaderException
+ * @throws CTFException
* Not expected
*/
@Test
- public void testGetInt_pos1() throws CTFReaderException {
+ public void testGetInt_pos1() throws CTFException {
fixture.position(1);
long result = fixture.get(1, true);
/**
* Test {@link BitBuffer#get} with seek at pos 2.
*
- * @throws CTFReaderException
+ * @throws CTFException
* Not expected
*/
@Test
- public void testGetInt_pos2() throws CTFReaderException {
+ public void testGetInt_pos2() throws CTFException {
fixture.position(2);
long result = fixture.get(0, true);
/**
* Test {@link BitBuffer#get} with explicit little-endian reading.
*
- * @throws CTFReaderException
+ * @throws CTFException
* Not expected
*/
@Test
- public void testGetInt_le2() throws CTFReaderException {
+ public void testGetInt_le2() throws CTFException {
BitBuffer leFixture = createBuffer(128);
leFixture.setByteOrder(ByteOrder.LITTLE_ENDIAN);
leFixture.position(0);
* Test {@link BitBuffer#get} with explicit little-endian reading, with an
* offset.
*
- * @throws CTFReaderException
+ * @throws CTFException
* Not expected
*/
@Test
- public void testGetInt_le1() throws CTFReaderException {
+ public void testGetInt_le1() throws CTFException {
BitBuffer leFixture = createBuffer(128);
leFixture.setByteOrder(ByteOrder.LITTLE_ENDIAN);
leFixture.position(1);
* Test {@link BitBuffer#get} with a 32-bit out-of-bounds read. Should throw
* an exception.
*
- * @throws CTFReaderException
+ * @throws CTFException
* Expected
*/
- @Test(expected = CTFReaderException.class)
- public void testGetInt_invalid() throws CTFReaderException {
+ @Test(expected = CTFException.class)
+ public void testGetInt_invalid() throws CTFException {
BitBuffer smallFixture = createBuffer(2);
smallFixture.setByteOrder(ByteOrder.BIG_ENDIAN);
* Test {@link BitBuffer#get} with a 64-bit out-of-bounds read. Should throw
* an exception.
*
- * @throws CTFReaderException
+ * @throws CTFException
* Expected
*/
- @Test(expected = CTFReaderException.class)
- public void testGetInt_invalid2() throws CTFReaderException {
+ @Test(expected = CTFException.class)
+ public void testGetInt_invalid2() throws CTFException {
BitBuffer smallFixture = createBuffer(2);
smallFixture.setByteOrder(ByteOrder.BIG_ENDIAN);
/**
* Test {@link BitBuffer#getLong}.
*
- * @throws CTFReaderException
+ * @throws CTFException
* error
*/
@Test
- public void testGetLong_pos0() throws CTFReaderException {
+ public void testGetLong_pos0() throws CTFException {
fixture.position(0);
long result = fixture.getLong();
assertEquals(0x01020304050607L, result);
/**
* Test {@link BitBuffer#getLong} with an offset of 7.
*
- * @throws CTFReaderException
+ * @throws CTFException
* error
*/
@Test
- public void testGetLong_pos7() throws CTFReaderException {
+ public void testGetLong_pos7() throws CTFException {
fixture.position(7);
long result = fixture.getLong();
assertEquals(0x81018202830384L, result);
/**
* Test {@link BitBuffer#getLong} with an offset of 8.
*
- * @throws CTFReaderException
+ * @throws CTFException
* error
*/
@Test
- public void testGetLong_pos8() throws CTFReaderException {
+ public void testGetLong_pos8() throws CTFException {
fixture.position(8);
long result = fixture.getLong();
assertEquals(0x0102030405060708L, result);
/**
* Test {@link BitBuffer#getLong} with a little-endian buffer.
*
- * @throws CTFReaderException
+ * @throws CTFException
* error
*/
@Test
- public void testGetLong_pos0LE() throws CTFReaderException {
+ public void testGetLong_pos0LE() throws CTFException {
fixture.position(0);
fixture.setByteOrder(ByteOrder.LITTLE_ENDIAN);
long result = fixture.getLong();
/**
* Test {@link BitBuffer#getLong} with a little-endian buffer at pos 7.
*
- * @throws CTFReaderException
+ * @throws CTFException
* error
*/
@Test
- public void testGetLong_pos7LE() throws CTFReaderException {
+ public void testGetLong_pos7LE() throws CTFException {
fixture.position(7);
fixture.setByteOrder(ByteOrder.LITTLE_ENDIAN);
long result = fixture.getLong();
/**
* Test {@link BitBuffer#getLong} with a little-endian buffer at pos 8.
*
- * @throws CTFReaderException
+ * @throws CTFException
* error
*/
@Test
- public void testGetLong_pos8LE() throws CTFReaderException {
+ public void testGetLong_pos8LE() throws CTFException {
fixture.position(8);
fixture.setByteOrder(ByteOrder.LITTLE_ENDIAN);
long result = fixture.getLong();
/**
* Test {@link BitBuffer#get} for >32 bits in length.
*
- * @throws CTFReaderException
+ * @throws CTFException
* error
*/
@Test
- public void testGet35_pos0BE() throws CTFReaderException {
+ public void testGet35_pos0BE() throws CTFException {
fixture.position(0);
long result = fixture.get(35, false);
assertEquals(0x081018L, result);
/**
* Test {@link BitBuffer#get} for >32 bits in length at an offset position.
*
- * @throws CTFReaderException
+ * @throws CTFException
* error
*/
@Test
- public void testGet35_pos8BE() throws CTFReaderException {
+ public void testGet35_pos8BE() throws CTFException {
fixture.position(8);
long result = fixture.get(35, false);
assertEquals(0x08101820L, result);
/**
* Test {@link BitBuffer#get} for >32 bits in length in little-endian.
*
- * @throws CTFReaderException
+ * @throws CTFException
* error
*/
@Test
- public void testGet35_pos0LE() throws CTFReaderException {
+ public void testGet35_pos0LE() throws CTFException {
fixture.position(0);
fixture.setByteOrder(ByteOrder.LITTLE_ENDIAN);
long result = fixture.get(35, false);
* Test {@link BitBuffer#get} for >32 bits in length, in little-endian, at
* position 7.
*
- * @throws CTFReaderException
+ * @throws CTFException
* error
*/
@Test
- public void testGetLong35_pos7LE() throws CTFReaderException {
+ public void testGetLong35_pos7LE() throws CTFException {
fixture.position(7);
fixture.setByteOrder(ByteOrder.LITTLE_ENDIAN);
long result = fixture.get(35, false);
* Test {@link BitBuffer#get} for >32 bits in length, in little-endian, at
* position 8.
*
- * @throws CTFReaderException
+ * @throws CTFException
* error
*/
@Test
- public void testGetLong35_pos8LE() throws CTFReaderException {
+ public void testGetLong35_pos8LE() throws CTFException {
fixture.position(8);
fixture.setByteOrder(ByteOrder.LITTLE_ENDIAN);
long result = fixture.get(35, false);
* Test {@link BitBuffer#get} for >32 bits in length, in little-endian, for
* a signed value.
*
- * @throws CTFReaderException
+ * @throws CTFException
* error
*/
@Test
- public void testGetLong35s_pos0LE() throws CTFReaderException {
+ public void testGetLong35s_pos0LE() throws CTFException {
fixture.position(0);
fixture.setByteOrder(ByteOrder.LITTLE_ENDIAN);
long result = fixture.get(35, true);
* Test {@link BitBuffer#get} for >32 bits in length, in little-endian, for
* a signed value, at position 7.
*
- * @throws CTFReaderException
+ * @throws CTFException
* error
*/
@Test
- public void testGetLong35s_pos7LE() throws CTFReaderException {
+ public void testGetLong35s_pos7LE() throws CTFException {
fixture.position(7);
fixture.setByteOrder(ByteOrder.LITTLE_ENDIAN);
long result = fixture.get(35, true);
* Test {@link BitBuffer#get} for >32 bits in length, in little-endian, for
* a signed value, at position 8.
*
- * @throws CTFReaderException
+ * @throws CTFException
* error
*/
@Test
- public void testGetLong35s_pos8LE() throws CTFReaderException {
+ public void testGetLong35s_pos8LE() throws CTFException {
fixture.position(8);
fixture.setByteOrder(ByteOrder.LITTLE_ENDIAN);
long result = fixture.get(35, true);
/**
* Test reading negative values as signed values.
*
- * @throws CTFReaderException
+ * @throws CTFException
* error
*/
@Test
- public void testGetSigned() throws CTFReaderException {
+ public void testGetSigned() throws CTFException {
fixture.position(0);
fixture.putInt(-1);
fixture.putInt(-1);
/**
* Test reading negative values as unsigned values.
*
- * @throws CTFReaderException
+ * @throws CTFException
* error
*/
@Test
- public void testGetUnsigned() throws CTFReaderException {
+ public void testGetUnsigned() throws CTFException {
fixture.position(0);
fixture.putInt(-1);
fixture.putInt(-1);
/**
* Test reading 24 bits of a 32-bit negative value as a signed value.
*
- * @throws CTFReaderException
+ * @throws CTFException
* error
*/
@Test
- public void testGet24Signed() throws CTFReaderException {
+ public void testGet24Signed() throws CTFException {
fixture.position(0);
fixture.putInt(-1);
fixture.putInt(-1);
/**
* Test reading 24 bits of a 32-bit negative value as an unsigned value.
*
- * @throws CTFReaderException
+ * @throws CTFException
* error
*/
@Test
- public void testGet24Unsigned() throws CTFReaderException {
+ public void testGet24Unsigned() throws CTFException {
fixture.position(0);
fixture.putInt(-1);
fixture.putInt(-1);
/**
* Test {@link BitBuffer#putInt(int)}
*
- * @throws CTFReaderException
+ * @throws CTFException
* Not expected
*/
@Test
- public void testPutInt() throws CTFReaderException {
+ public void testPutInt() throws CTFException {
fixture.position(1);
fixture.putInt(1);
}
/**
* Test {@link BitBuffer#putInt(int, int)}
*
- * @throws CTFReaderException
+ * @throws CTFException
* Not expected
*/
@Test
- public void testPutInt_length1() throws CTFReaderException {
+ public void testPutInt_length1() throws CTFException {
fixture.position(1);
fixture.putInt(1, 1);
}
/**
* Test {@link BitBuffer#putInt(int, int)} with length = 0.
*
- * @throws CTFReaderException
+ * @throws CTFException
* Not expected
*/
@Test
- public void testPutInt_length0() throws CTFReaderException {
+ public void testPutInt_length0() throws CTFException {
fixture.position(1);
fixture.putInt(0, 1);
}
/**
* Test {@link BitBuffer#putInt(int)} Little endian
*
- * @throws CTFReaderException
+ * @throws CTFException
* Not expected
*/
@Test
- public void testPutIntLe() throws CTFReaderException {
+ public void testPutIntLe() throws CTFException {
fixture.setByteOrder(ByteOrder.LITTLE_ENDIAN);
fixture.position(1);
fixture.putInt(1);
/**
* Test {@link BitBuffer#putInt(int, int)} Little endian
*
- * @throws CTFReaderException
+ * @throws CTFException
* Not expected
*/
@Test
- public void testPutIntLe_length1() throws CTFReaderException {
+ public void testPutIntLe_length1() throws CTFException {
fixture.setByteOrder(ByteOrder.LITTLE_ENDIAN);
fixture.position(1);
fixture.putInt(1, 1);
/**
* Test {@link BitBuffer#putInt(int, int)} with length = 0. Little endian
*
- * @throws CTFReaderException
+ * @throws CTFException
* Not expected
*/
@Test
- public void testPutIntLe_length0() throws CTFReaderException {
+ public void testPutIntLe_length0() throws CTFException {
fixture.setByteOrder(ByteOrder.LITTLE_ENDIAN);
fixture.position(1);
fixture.putInt(0, 1);
/**
* Test writing and reading a value defined in hex format.
*
- * @throws CTFReaderException
+ * @throws CTFException
* Not expected
*/
@Test
- public void testPutInt_hex() throws CTFReaderException {
+ public void testPutInt_hex() throws CTFException {
final int value = 0x010203;
for (int i = 0; i <= 32; i++) {
* Test {@link BitBuffer#putInt} with an out-of-bounds length. An exception
* should be thrown.
*
- * @throws CTFReaderException
+ * @throws CTFException
* Expected
*/
- @Test(expected = CTFReaderException.class)
- public void testPutInt_invalid() throws CTFReaderException {
+ @Test(expected = CTFException.class)
+ public void testPutInt_invalid() throws CTFException {
BitBuffer fixture2;
fixture2 = createBuffer(4);
fixture2.setByteOrder(ByteOrder.BIG_ENDIAN);
import java.nio.ByteOrder;
import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.tracecompass.ctf.core.CTFReaderException;
+import org.eclipse.tracecompass.ctf.core.CTFException;
import org.eclipse.tracecompass.ctf.core.event.io.BitBuffer;
import org.junit.Before;
import org.junit.Test;
/**
* Perform pre-test initialization.
*
- * @throws CTFReaderException
+ * @throws CTFException
* An error that cannot happen (position is under 128)
*/
@Before
- public void setUp() throws CTFReaderException {
+ public void setUp() throws CTFException {
fixture = new BitBuffer(Util.testMemory(ByteBuffer.allocateDirect(1)));
fixture.setByteOrder(ByteOrder.BIG_ENDIAN);
fixture.position(1);
/**
* Run the void position(int) method test.
*
- * @throws CTFReaderException
+ * @throws CTFException
* out of bounds? won't happen
*/
@Test
- public void testSetPosition() throws CTFReaderException {
+ public void testSetPosition() throws CTFException {
int newPosition = 1;
fixture.position(newPosition);
}
/**
* Test the get function
*
- * @throws CTFReaderException
+ * @throws CTFException
* won't happen but we seek in a buffer
*/
@Test
- public void testGetBytesMiddle() throws CTFReaderException {
+ public void testGetBytesMiddle() throws CTFException {
@NonNull
byte[] data = new byte[5];
// this string has been carefully selected and tested... don't change
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
-import org.eclipse.tracecompass.ctf.core.CTFReaderException;
+import org.eclipse.tracecompass.ctf.core.CTFException;
import org.eclipse.tracecompass.ctf.core.event.io.BitBuffer;
import org.eclipse.tracecompass.ctf.core.event.scope.ILexicalScope;
import org.eclipse.tracecompass.ctf.core.event.types.Encoding;
/**
* Test the constructor
*
- * @throws CTFReaderException
+ * @throws CTFException
* exception
*/
@Test
- public void testStreamInputPacketIndexEntryConstructor1() throws CTFReaderException {
+ public void testStreamInputPacketIndexEntryConstructor1() throws CTFException {
StructDeclaration sd = new StructDeclaration(8);
sd.addField("timestamp_begin", IntegerDeclaration.INT_32B_DECL);
sd.addField("timestamp_end", IntegerDeclaration.INT_32B_DECL);
/**
* Test the constructor
*
- * @throws CTFReaderException
+ * @throws CTFException
* exception
*/
@Test
- public void testStreamInputPacketIndexEntryConstructor2() throws CTFReaderException {
+ public void testStreamInputPacketIndexEntryConstructor2() throws CTFException {
StructDeclaration sd = new StructDeclaration(8);
sd.addField("timestamp_begin", IntegerDeclaration.INT_32B_DECL);
sd.addField("timestamp_end", IntegerDeclaration.INT_32B_DECL);
/**
* Test the constructor
*
- * @throws CTFReaderException
+ * @throws CTFException
* exception
*/
@Test
- public void testStreamInputPacketIndexEntryConstructor3() throws CTFReaderException {
+ public void testStreamInputPacketIndexEntryConstructor3() throws CTFException {
StructDeclaration sd = new StructDeclaration(8);
sd.addField("timestamp_begin", IntegerDeclaration.INT_32B_DECL);
sd.addField("timestamp_end", IntegerDeclaration.INT_32B_DECL);
/**
* Test the constructor
*
- * @throws CTFReaderException
+ * @throws CTFException
* exception
*/
@Test
- public void testStreamInputPacketIndexEntryConstructor4() throws CTFReaderException {
+ public void testStreamInputPacketIndexEntryConstructor4() throws CTFException {
StructDeclaration sd = new StructDeclaration(8);
sd.addField("content_size", IntegerDeclaration.INT_32B_DECL);
sd.addField("target", StringDeclaration.getStringDeclaration(Encoding.ASCII));
/**
* Test the constructor
*
- * @throws CTFReaderException
+ * @throws CTFException
* exception
*/
@Test
- public void testStreamInputPacketIndexEntryConstructor5() throws CTFReaderException {
+ public void testStreamInputPacketIndexEntryConstructor5() throws CTFException {
StructDeclaration sd = new StructDeclaration(8);
sd.addField("timestamp_end", IntegerDeclaration.INT_32B_DECL);
sd.addField("content_size", IntegerDeclaration.INT_32B_DECL);
/**
* Test the constructor
*
- * @throws CTFReaderException
+ * @throws CTFException
* exception
*/
@Test
- public void testStreamInputPacketIndexEntryConstructor6() throws CTFReaderException {
+ public void testStreamInputPacketIndexEntryConstructor6() throws CTFException {
StructDeclaration sd = new StructDeclaration(8);
sd.addField("timestamp_end", IntegerDeclaration.INT_32B_DECL);
sd.addField("content_size", IntegerDeclaration.INT_32B_DECL);
/**
* Run the String toString() method test.
*
- * @throws CTFReaderException
+ * @throws CTFException
* won't happen
*/
@Test
- public void testToString() throws CTFReaderException {
+ public void testToString() throws CTFException {
String expectedResult = "StreamInputPacketIndexEntry [offsetBits=0, timestampBegin=0, timestampEnd=0]";
StructDeclaration sd = new StructDeclaration(8);
import static org.junit.Assert.assertNotNull;
-import org.eclipse.tracecompass.ctf.core.CTFReaderException;
+import org.eclipse.tracecompass.ctf.core.CTFException;
import org.eclipse.tracecompass.internal.ctf.core.trace.StreamInputPacketIndex;
import org.eclipse.tracecompass.internal.ctf.core.trace.StreamInputPacketIndexEntry;
import org.junit.Before;
/**
* Perform pre-test initialization.
*
- * @throws CTFReaderException
+ * @throws CTFException
*/
@Before
- public void setUp() throws CTFReaderException {
+ public void setUp() throws CTFException {
fixture = new StreamInputPacketIndex();
fixture.append(new StreamInputPacketIndexEntry(1L,0L));
}
import java.io.IOException;
import java.util.Set;
-import org.eclipse.tracecompass.ctf.core.CTFReaderException;
+import org.eclipse.tracecompass.ctf.core.CTFException;
import org.eclipse.tracecompass.ctf.core.event.EventDefinition;
import org.eclipse.tracecompass.ctf.core.event.types.Definition;
import org.eclipse.tracecompass.ctf.core.event.types.Encoding;
/**
* Perform pre-test initialization.
*
- * @throws CTFReaderException
+ * @throws CTFException
*/
@Before
- public void setUp() throws CTFReaderException {
+ public void setUp() throws CTFException {
fixture = getStreamInputReader();
fixture.setName(1);
fixture.setCurrentEvent(new EventDefinition(new EventDeclaration(),
);
}
- private static CTFStreamInputReader getStreamInputReader() throws CTFReaderException {
+ private static CTFStreamInputReader getStreamInputReader() throws CTFException {
assumeTrue(testTrace.exists());
CTFTrace trace = testTrace.getTrace();
CTFStream s = trace.getStream((long) 0);
* Run the StreamInputReader(StreamInput) constructor test, with an invalid
* trace.
*
- * @throws CTFReaderException
+ * @throws CTFException
* @throws IOException
*/
- @Test(expected = CTFReaderException.class)
- public void testStreamInputReader_invalid() throws CTFReaderException, IOException {
+ @Test(expected = CTFException.class)
+ public void testStreamInputReader_invalid() throws CTFException, IOException {
CTFStreamInput streamInput = new CTFStreamInput(new CTFStream(new CTFTrace("")), new File(""));
try (CTFStreamInputReader result = new CTFStreamInputReader(streamInput)) {
assertNotNull(result);
/**
* Run the void goToLastEvent() method test.
*
- * @throws CTFReaderException
+ * @throws CTFException
* error
*/
@Test
- public void testGoToLastEvent1() throws CTFReaderException {
+ public void testGoToLastEvent1() throws CTFException {
final long endTimestamp = goToEnd();
final long endTime = 4287422460315L;
assertEquals(endTime, endTimestamp);
/**
* Run the void goToLastEvent() method test.
*
- * @throws CTFReaderException
+ * @throws CTFException
* error
*/
@Test
- public void testGoToLastEvent2() throws CTFReaderException {
+ public void testGoToLastEvent2() throws CTFException {
long timestamp = -1;
while (fixture.readNextEvent().equals(CTFResponse.OK)) {
timestamp = fixture.getCurrentEvent().getTimestamp();
assertEquals(0, timestamp - endTimestamp);
}
- private long goToEnd() throws CTFReaderException {
+ private long goToEnd() throws CTFException {
fixture.goToLastEvent();
return fixture.getCurrentEvent().getTimestamp();
}
/**
* Run the boolean readNextEvent() method test.
*
- * @throws CTFReaderException
+ * @throws CTFException
* error
*/
@Test
- public void testReadNextEvent() throws CTFReaderException {
+ public void testReadNextEvent() throws CTFException {
assertEquals(CTFResponse.OK, fixture.readNextEvent());
}
/**
* Run the void seek(long) method test. Seek by direct timestamp
*
- * @throws CTFReaderException
+ * @throws CTFException
* error
*/
@Test
- public void testSeek_timestamp() throws CTFReaderException {
+ public void testSeek_timestamp() throws CTFException {
long timestamp = 1L;
fixture.seek(timestamp);
}
* Run the seek test. Seek by passing an EventDefinition to which we've
* given the timestamp we want.
*
- * @throws CTFReaderException
+ * @throws CTFException
*/
@Test
- public void testSeek_eventDefinition() throws CTFReaderException {
+ public void testSeek_eventDefinition() throws CTFException {
EventDefinition eventDefinition = new EventDefinition(
new EventDeclaration(), getStreamInputReader(), 1L, null, null, null, null);
fixture.setCurrentEvent(eventDefinition);
import java.io.FilenameFilter;
import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.tracecompass.ctf.core.CTFReaderException;
+import org.eclipse.tracecompass.ctf.core.CTFException;
import org.eclipse.tracecompass.ctf.core.event.types.IDefinition;
import org.eclipse.tracecompass.ctf.core.tests.shared.CtfTestTrace;
import org.eclipse.tracecompass.ctf.core.trace.CTFStream;
/**
* Perform pre-test initialization.
*
- * @throws CTFReaderException
+ * @throws CTFException
*/
@Before
- public void setUp() throws CTFReaderException {
+ public void setUp() throws CTFException {
assumeTrue(testTrace.exists());
fixture = new CTFStreamInput(new CTFStream(testTrace.getTrace()), createFile());
fixture.setTimestampEnd(1L);
CTFStreamInput s2;
@Test
- public void testEquals1() throws CTFReaderException {
+ public void testEquals1() throws CTFException {
s1 = new CTFStreamInput(new CTFStream(testTrace.getTrace()),
createFile());
assertFalse(s1.equals(null));
}
@Test
- public void testEquals2() throws CTFReaderException {
+ public void testEquals2() throws CTFException {
s1 = new CTFStreamInput(new CTFStream(testTrace.getTrace()),
createFile());
assertFalse(s1.equals(new Long(23L)));
}
@Test
- public void testEquals3() throws CTFReaderException {
+ public void testEquals3() throws CTFException {
s1 = new CTFStreamInput(new CTFStream(testTrace.getTrace()),
createFile());
assertEquals(s1, s1);
}
@Test
- public void testEquals4() throws CTFReaderException {
+ public void testEquals4() throws CTFException {
s1 = new CTFStreamInput(new CTFStream(testTrace.getTrace()),
createFile());
s2 = new CTFStreamInput(new CTFStream(testTrace.getTrace()),
import java.util.Set;
import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.tracecompass.ctf.core.CTFReaderException;
+import org.eclipse.tracecompass.ctf.core.CTFException;
import org.eclipse.tracecompass.ctf.core.event.types.IDeclaration;
import org.eclipse.tracecompass.ctf.core.event.types.StructDeclaration;
import org.eclipse.tracecompass.ctf.core.tests.shared.CtfTestTrace;
/**
* Perform pre-test initialization.
*
- * @throws CTFReaderException
+ * @throws CTFException
*/
@Before
- public void setUp() throws CTFReaderException {
+ public void setUp() throws CTFException {
fixture = new CTFStream(testTrace.getTrace());
fixture.setEventContext(new StructDeclaration(1L));
fixture.setPacketContext(new StructDeclaration(1L));
/**
* Run the Stream(CTFTrace) constructor test.
*
- * @throws CTFReaderException
+ * @throws CTFException
*/
@Test
- public void testStream() throws CTFReaderException {
+ public void testStream() throws CTFException {
CTFTrace trace = testTrace.getTrace();
CTFStream result = new CTFStream(trace);
assertNotNull(result);
import java.nio.file.attribute.FileAttribute;
import java.util.UUID;
-import org.eclipse.tracecompass.ctf.core.CTFReaderException;
+import org.eclipse.tracecompass.ctf.core.CTFException;
import org.eclipse.tracecompass.ctf.core.trace.CTFTrace;
import org.eclipse.tracecompass.ctf.core.trace.CTFTraceReader;
import org.junit.Before;
* Run before every test
*
* @throws IOException won't happen
- * @throws CTFReaderException won't happen
+ * @throws CTFException won't happen
*/
@Before
- public void init() throws IOException, CTFReaderException {
+ public void init() throws IOException, CTFException {
fCtfDirectory = Files.createTempDirectory("temptrace", new FileAttribute<?>[] {});
File metadata = new File(fCtfDirectory.toString() + "/" + "metadata");
fGrowingStream = new File(fCtfDirectory.toString() + "/" + "stream");
/**
* Test a growing stream
*
- * @throws CTFReaderException won't happen
+ * @throws CTFException won't happen
* @throws IOException won't happen
* @throws FileNotFoundException won't happen
*/
@Test
- public void testGrowingLive() throws CTFReaderException, FileNotFoundException, IOException {
+ public void testGrowingLive() throws CTFException, FileNotFoundException, IOException {
try (CTFTraceReader reader = new CTFTraceReader(fFixture);) {
reader.setLive(true);
assertEquals("0x29", reader.getCurrentEventDef().getFields().getDefinition("f").toString());
/**
* Test a growing stream
*
- * @throws CTFReaderException won't happen
+ * @throws CTFException won't happen
* @throws IOException won't happen
* @throws FileNotFoundException won't happen
*/
@Test
- public void testGrowingNotLive() throws CTFReaderException, FileNotFoundException, IOException {
+ public void testGrowingNotLive() throws CTFException, FileNotFoundException, IOException {
try (CTFTraceReader reader = new CTFTraceReader(fFixture);) {
reader.setLive(false);
assertEquals("0x29", reader.getCurrentEventDef().getFields().getDefinition("f").toString());
import java.io.IOException;
import java.io.InputStreamReader;
-import org.eclipse.tracecompass.ctf.core.CTFReaderException;
+import org.eclipse.tracecompass.ctf.core.CTFException;
import org.eclipse.tracecompass.ctf.core.event.EventDefinition;
import org.eclipse.tracecompass.ctf.core.tests.shared.CtfTestTrace;
import org.eclipse.tracecompass.ctf.core.trace.CTFTrace;
* an IO error
* @throws FileNotFoundException
* file's not there
- * @throws CTFReaderException
+ * @throws CTFException
* error in metadata
*/
@Before
- public void init() throws FileNotFoundException, IOException, CTFReaderException {
+ public void init() throws FileNotFoundException, IOException, CTFException {
Metadata md = new Metadata(fixture);
File metadata = new File(fPathName + "/" + "metadata");
/**
* Empty trace test
*
- * @throws CTFReaderException
+ * @throws CTFException
* will not happen
*/
@Test
- public void testEmptyStream() throws CTFReaderException {
+ public void testEmptyStream() throws CTFException {
try (CTFTraceReader reader = new CTFTraceReader(fixture);) {
assertNull(reader.getCurrentEventDef());
}
/**
* Add a stream
*
- * @throws CTFReaderException
+ * @throws CTFException
* should not happen
*/
@Test
- public void testAddStream() throws CTFReaderException {
+ public void testAddStream() throws CTFException {
File stream = new File(fPathName + "/" + "channel1");
try (CTFTraceReader reader = new CTFTraceReader(fixture);) {
fixture.addStreamFile(stream);
/**
* Adds two a stream
*
- * @throws CTFReaderException
+ * @throws CTFException
* should not happen
*/
@Test
- public void testAddTwoStreams1() throws CTFReaderException {
+ public void testAddTwoStreams1() throws CTFException {
File stream = new File(fPathName + "/" + "channel1");
try (CTFTraceReader reader = new CTFTraceReader(fixture);) {
fixture.addStreamFile(stream);
/**
* Adds two a stream
*
- * @throws CTFReaderException
+ * @throws CTFException
* should not happen
*/
@Test
- public void testAddTwoStreams2() throws CTFReaderException {
+ public void testAddTwoStreams2() throws CTFException {
File stream = new File(fPathName + "/" + "channel1");
try (CTFTraceReader reader = new CTFTraceReader(fixture);) {
fixture.addStreamFile(stream);
/**
* Tests that update does not change the position
*
- * @throws CTFReaderException
+ * @throws CTFException
* should not happen
*/
@Test
- public void testAddTwoStreams3() throws CTFReaderException {
+ public void testAddTwoStreams3() throws CTFException {
File stream = new File(fPathName + "/" + "channel1");
try (CTFTraceReader reader = new CTFTraceReader(fixture);) {
fixture.addStreamFile(stream);
/**
* Test adding a bad stream
*
- * @throws CTFReaderException
+ * @throws CTFException
* should happen
*/
- @Test(expected = CTFReaderException.class)
- public void testAddStreamFail() throws CTFReaderException {
+ @Test(expected = CTFException.class)
+ public void testAddStreamFail() throws CTFException {
File stream = new File(fPathName + "/" + "metadata");
try (CTFTraceReader reader = new CTFTraceReader(fixture);) {
fixture.addStreamFile(stream);
import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeTrue;
-import org.eclipse.tracecompass.ctf.core.CTFReaderException;
+import org.eclipse.tracecompass.ctf.core.CTFException;
import org.eclipse.tracecompass.ctf.core.event.EventDefinition;
import org.eclipse.tracecompass.ctf.core.tests.shared.CtfTestTrace;
import org.eclipse.tracecompass.ctf.core.trace.CTFTrace;
/**
* Perform pre-test initialization.
*
- * @throws CTFReaderException
+ * @throws CTFException
*/
@Before
- public void setUp() throws CTFReaderException {
+ public void setUp() throws CTFException {
assumeTrue(testTrace.exists());
fixture = new CTFTraceReader(testTrace.getTrace());
}
* Run the CTFTraceReader(CTFTrace) constructor test. Open a known good
* trace.
*
- * @throws CTFReaderException
+ * @throws CTFException
*/
@Test
- public void testOpen_existing() throws CTFReaderException {
+ public void testOpen_existing() throws CTFException {
CTFTrace trace = testTrace.getTrace();
try (CTFTraceReader result = new CTFTraceReader(trace);) {
assertNotNull(result);
* Run the CTFTraceReader(CTFTrace) constructor test. Open a non-existing
* trace, expect the exception.
*
- * @throws CTFReaderException
+ * @throws CTFException
*/
- @Test(expected = org.eclipse.tracecompass.ctf.core.CTFReaderException.class)
- public void testOpen_nonexisting() throws CTFReaderException {
+ @Test(expected = org.eclipse.tracecompass.ctf.core.CTFException.class)
+ public void testOpen_nonexisting() throws CTFException {
CTFTrace trace = new CTFTrace("badfile.bad");
try (CTFTraceReader result = new CTFTraceReader(trace);) {
assertNotNull(result);
* Run the CTFTraceReader(CTFTrace) constructor test. Try to pen an invalid
* path, expect exception.
*
- * @throws CTFReaderException
+ * @throws CTFException
*/
- @Test(expected = org.eclipse.tracecompass.ctf.core.CTFReaderException.class)
- public void testOpen_invalid() throws CTFReaderException {
+ @Test(expected = org.eclipse.tracecompass.ctf.core.CTFException.class)
+ public void testOpen_invalid() throws CTFException {
CTFTrace trace = new CTFTrace("");
try (CTFTraceReader result = new CTFTraceReader(trace);) {
assertNotNull(result);
/**
* Run the boolean advance() method test. Test advancing normally.
*
- * @throws CTFReaderException
+ * @throws CTFException
* error
*/
@Test
- public void testAdvance_normal() throws CTFReaderException {
+ public void testAdvance_normal() throws CTFException {
boolean result = fixture.advance();
assertTrue(result);
}
* Run the boolean advance() method test. Test advancing when we're at the
* end, so we expect that there is no more events.
*
- * @throws CTFReaderException
+ * @throws CTFException
* error
*/
@Test
- public void testAdvance_end() throws CTFReaderException {
+ public void testAdvance_end() throws CTFException {
int i = 0;
boolean result = fixture.advance();
while (result) {
/**
* Run the CTFTraceReader copy constructor test.
*
- * @throws CTFReaderException
+ * @throws CTFException
* error
*/
@Test
- public void testCopyFrom() throws CTFReaderException {
+ public void testCopyFrom() throws CTFException {
try (CTFTraceReader result = fixture.copyFrom();) {
assertNotNull(result);
}
* Both trace reader are different objects, so they shouldn't "equals" each
* other.
*
- * @throws CTFReaderException
+ * @throws CTFException
*/
@Test
- public void testEquals() throws CTFReaderException {
+ public void testEquals() throws CTFException {
try (CTFTraceReader fixture2 = new CTFTraceReader(testTrace.getTrace());) {
assertEquals(fixture, fixture2);
}
* Run the getCurrentEventDef() method test. Get the last event's
* definition.
*
- * @throws CTFReaderException
+ * @throws CTFException
* error
*/
@Test
- public void testGetCurrentEventDef_last() throws CTFReaderException {
+ public void testGetCurrentEventDef_last() throws CTFException {
fixture.goToLastEvent();
EventDefinition result = fixture.getCurrentEventDef();
assertNotNull(result);
/**
* Run the void goToLastEvent() method test.
*
- * @throws CTFReaderException
+ * @throws CTFException
* error
*/
@Test
- public void testGoToLastEvent() throws CTFReaderException {
+ public void testGoToLastEvent() throws CTFException {
fixture.goToLastEvent();
long ts1 = getTimestamp();
long ts2 = fixture.getEndTime();
/**
* Run the boolean hasMoreEvents() method test.
*
- * @throws CTFReaderException
+ * @throws CTFException
*/
@Test
public void testHasMoreEvents() {
/**
* Run the void printStats() method test with no 'width' parameter.
*
- * @throws CTFReaderException
+ * @throws CTFException
* error
*/
@Test
- public void testPrintStats_noparam() throws CTFReaderException {
+ public void testPrintStats_noparam() throws CTFException {
fixture.advance();
fixture.printStats();
}
/**
* Run the void printStats(int) method test with width = 0.
*
- * @throws CTFReaderException
+ * @throws CTFException
* error
*/
@Test
- public void testPrintStats_width0() throws CTFReaderException {
+ public void testPrintStats_width0() throws CTFException {
fixture.advance();
fixture.printStats(0);
}
/**
* Run the void printStats(int) method test with width = 1.
*
- * @throws CTFReaderException
+ * @throws CTFException
* error
*/
@Test
- public void testPrintStats_width1() throws CTFReaderException {
+ public void testPrintStats_width1() throws CTFException {
fixture.advance();
fixture.printStats(1);
}
/**
* Run the void printStats(int) method test with width = 2.
*
- * @throws CTFReaderException
+ * @throws CTFException
* error
*/
@Test
- public void testPrintStats_width2() throws CTFReaderException {
+ public void testPrintStats_width2() throws CTFException {
fixture.advance();
fixture.printStats(2);
}
/**
* Run the void printStats(int) method test with width = 10.
*
- * @throws CTFReaderException
+ * @throws CTFException
* error
*/
@Test
- public void testPrintStats_width10() throws CTFReaderException {
+ public void testPrintStats_width10() throws CTFException {
fixture.advance();
fixture.printStats(10);
}
/**
* Run the void printStats(int) method test with width = 100.
*
- * @throws CTFReaderException
+ * @throws CTFException
* error
*/
@Test
- public void testPrintStats_100() throws CTFReaderException {
+ public void testPrintStats_100() throws CTFException {
for (int i = 0; i < 1000; i++) {
fixture.advance();
}
/**
* Run the boolean seek(long) method test.
*
- * @throws CTFReaderException
+ * @throws CTFException
* error
*/
@Test
- public void testSeek() throws CTFReaderException {
+ public void testSeek() throws CTFException {
long timestamp = 1L;
boolean result = fixture.seek(timestamp);
assertTrue(result);
import java.nio.ByteOrder;
import java.util.UUID;
-import org.eclipse.tracecompass.ctf.core.CTFReaderException;
+import org.eclipse.tracecompass.ctf.core.CTFException;
import org.eclipse.tracecompass.ctf.core.event.CTFClock;
import org.eclipse.tracecompass.ctf.core.event.types.IDefinition;
import org.eclipse.tracecompass.ctf.core.event.types.StructDeclaration;
assumeTrue(testTrace.exists());
try {
fixture = testTrace.getTraceFromFile();
- } catch (CTFReaderException e) {
+ } catch (CTFException e) {
/* If the assumeTrue() call passed, this should not happen. */
fail();
}
try {
CTFTrace result = testTrace.getTraceFromFile();
assertNotNull(result.getUUID());
- } catch (CTFReaderException e) {
+ } catch (CTFException e) {
fail();
}
}
/**
* Run the CTFTrace(File) constructor test with an invalid path.
*
- * @throws CTFReaderException
+ * @throws CTFException
* is expected
*/
- @Test(expected = org.eclipse.tracecompass.ctf.core.CTFReaderException.class)
- public void testOpen_invalid() throws CTFReaderException {
+ @Test(expected = org.eclipse.tracecompass.ctf.core.CTFException.class)
+ public void testOpen_invalid() throws CTFException {
File path = new File("");
CTFTrace result = new CTFTrace(path);
assertNotNull(result);
CTFStream stream = new CTFStream(testTrace.getTrace());
stream.setId(1234);
fixture.addStream(stream);
- } catch (CTFReaderException e) {
+ } catch (CTFException e) {
fail();
} catch (ParseException e) {
fail();
boolean result = fixture2.packetHeaderIsSet();
assertFalse(result);
- } catch (CTFReaderException e) {
+ } catch (CTFException e) {
fail();
}
}
/**
* Test for getCallsite(eventName, ip)
*
- * @throws CTFReaderException
+ * @throws CTFException
* not expected
*/
@Test
- public void callsitePosition() throws CTFReaderException {
+ public void callsitePosition() throws CTFException {
long ip1 = 2;
long ip2 = 5;
long ip3 = 7;
import java.util.ArrayList;
import java.util.List;
-import org.eclipse.tracecompass.ctf.core.CTFReaderException;
+import org.eclipse.tracecompass.ctf.core.CTFException;
import org.eclipse.tracecompass.ctf.core.event.IEventDeclaration;
import org.eclipse.tracecompass.ctf.core.tests.CtfCoreTestPlugin;
import org.eclipse.tracecompass.ctf.core.trace.CTFTrace;
/**
* Simple test (only the minimum)
*
- * @throws CTFReaderException
+ * @throws CTFException
* something wrong happened
*/
@Test
- public void TSDLSimpleTest() throws CTFReaderException {
+ public void TSDLSimpleTest() throws CTFException {
createDummyTrace(simpleTSDL);
trace = new CTFTrace(tempTraceDir);
assertNotNull(trace);
/**
* Test with environment variables
*
- * @throws CTFReaderException
+ * @throws CTFException
* something wrong happened
*/
@Test
- public void TSDLEnvironmentTest() throws CTFReaderException {
+ public void TSDLEnvironmentTest() throws CTFException {
createDummyTrace(envTSDL);
trace = new CTFTrace(tempTraceDir);
assertNotNull(trace);
/**
* Test with Clocks
*
- * @throws CTFReaderException
+ * @throws CTFException
* something wrong happened
*/
@Test
- public void TSDLEnumTest() throws CTFReaderException {
+ public void TSDLEnumTest() throws CTFException {
createDummyTrace(enumTSDL);
trace = new CTFTrace(tempTraceDir);
assertNotNull(trace);
/**
* Test with Clocks
*
- * @throws CTFReaderException
+ * @throws CTFException
* something wrong happened
*/
@Test
- public void TSDLClockTest() throws CTFReaderException {
+ public void TSDLClockTest() throws CTFException {
createDummyTrace(clockTSDL);
trace = new CTFTrace(tempTraceDir);
assertNotNull(trace);
/**
* Test with Contexts
*
- * @throws CTFReaderException
+ * @throws CTFException
* something wrong happened
*/
@Test
- public void TSDLContextTest() throws CTFReaderException {
+ public void TSDLContextTest() throws CTFException {
createDummyTrace(contextTSDL);
trace = new CTFTrace(tempTraceDir);
assertNotNull(trace);
/**
* Test with Callsites
*
- * @throws CTFReaderException
+ * @throws CTFException
* something wrong happened
*/
@Test
- public void TSDLCallsiteTest() throws CTFReaderException {
+ public void TSDLCallsiteTest() throws CTFException {
createDummyTrace(callsiteTSDL);
trace = new CTFTrace(tempTraceDir);
assertNotNull(trace);
/**
* Test everything
*
- * @throws CTFReaderException
+ * @throws CTFException
* something wrong happened
*/
@Test
- public void TSDLAllTest() throws CTFReaderException {
+ public void TSDLAllTest() throws CTFException {
createDummyTrace(allDressedTSDL);
trace = new CTFTrace(tempTraceDir);
assertNotNull(trace);
import java.util.List;
import java.util.UUID;
-import org.eclipse.tracecompass.ctf.core.CTFReaderException;
+import org.eclipse.tracecompass.ctf.core.CTFException;
import org.eclipse.tracecompass.ctf.core.event.IEventDeclaration;
import org.eclipse.tracecompass.ctf.core.tests.shared.CtfTestTrace;
import org.eclipse.tracecompass.ctf.core.trace.CTFStream;
/**
* Perform pre-test initialization.
*
- * @throws CTFReaderException
+ * @throws CTFException
*/
@Before
- public void setUp() throws CTFReaderException {
+ public void setUp() throws CTFException {
assumeTrue(testTrace.exists());
fixture = new Metadata(testTrace.getTrace());
}
}
@Test
- public void testTextMD() throws CTFReaderException {
+ public void testTextMD() throws CTFException {
testSingleFragment();
}
- protected CTFTrace testSingleFragment() throws CTFReaderException {
+ protected CTFTrace testSingleFragment() throws CTFException {
fixture = new Metadata();
CTFTrace trace = fixture.getTrace();
for (CTFStream s : trace.getStreams()) {
}
@Test
- public void testStreamTextMD() throws CTFReaderException {
+ public void testStreamTextMD() throws CTFException {
CTFTrace trace = testSingleFragment();
fixture.parseTextFragment(mdSecond);
final List<IEventDeclaration> eventDeclarations = new ArrayList<>(trace.getEventDeclarations(0L));
/**
* Run the ByteOrder getDetectedByteOrder() method test.
*
- * @throws CTFReaderException
+ * @throws CTFException
*/
@Test
- public void testGetDetectedByteOrder() throws CTFReaderException {
+ public void testGetDetectedByteOrder() throws CTFException {
setUp();
ByteOrder result = fixture.getDetectedByteOrder();
assertNull(result);
/**
* Test toString
*
- * @throws CTFReaderException
+ * @throws CTFException
*/
@Test
- public void testToString() throws CTFReaderException {
+ public void testToString() throws CTFException {
setUp();
String result = fixture.toString();
assertNotNull(result);
/**
* Run the void parse() method test.
*
- * @throws CTFReaderException
+ * @throws CTFException
*/
@Test
- public void testParse() throws CTFReaderException {
+ public void testParse() throws CTFException {
setUp();
assertEquals(new UUID(0xd18e637435a1cd42L, 0x8e70a9cffa712793L), testTrace.getTrace().getUUID());
assertEquals(1332166405241713920.0, testTrace.getTrace().getClock().getClockOffset(), 200.0);
import java.util.ArrayList;
import java.util.List;
-import org.eclipse.tracecompass.ctf.core.CTFReaderException;
+import org.eclipse.tracecompass.ctf.core.CTFException;
import org.eclipse.tracecompass.ctf.core.CTFStrings;
import org.eclipse.tracecompass.ctf.core.event.EventDefinition;
import org.eclipse.tracecompass.ctf.core.event.types.IntegerDefinition;
}
assertEquals("Event count", fTraceEnum.getNbEvents(), count);
assertEquals("Trace duration", fTraceEnum.getDuration(), (end - start) / 1000000000.0, 1.0);
- } catch (CTFReaderException e) {
+ } catch (CTFException e) {
fail(fTraceEnum.getPath() + " " + e.getMessage());
}
} else {
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
-import org.eclipse.tracecompass.ctf.core.CTFReaderException;
+import org.eclipse.tracecompass.ctf.core.CTFException;
import org.eclipse.tracecompass.ctf.core.event.io.BitBuffer;
import org.eclipse.tracecompass.ctf.core.event.scope.IDefinitionScope;
import org.eclipse.tracecompass.ctf.core.event.types.AbstractArrayDefinition;
* Run the ArrayDefinition createDefinition(DefinitionScope,String) method
* test.
*
- * @throws CTFReaderException
+ * @throws CTFException
* error in the bitbuffer
*/
@Test
- public void testCreateDefinition() throws CTFReaderException {
+ public void testCreateDefinition() throws CTFException {
String fieldName = "";
IDefinitionScope definitionScope = null;
AbstractArrayDefinition result;
import java.util.List;
import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.tracecompass.ctf.core.CTFReaderException;
+import org.eclipse.tracecompass.ctf.core.CTFException;
import org.eclipse.tracecompass.ctf.core.event.io.BitBuffer;
import org.eclipse.tracecompass.ctf.core.event.scope.IDefinitionScope;
import org.eclipse.tracecompass.ctf.core.event.scope.LexicalScope;
/**
* Run the void read(BitBuffer) method test.
*
- * @throws CTFReaderException
+ * @throws CTFException
* error
*/
@Test
- public void testRead_noDefs() throws CTFReaderException {
+ public void testRead_noDefs() throws CTFException {
BitBuffer input = new BitBuffer(Util.testMemory(ByteBuffer.allocateDirect(128)));
charArrayFixture.getDeclaration().createDefinition(null, "test", input);
}
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
-import org.eclipse.tracecompass.ctf.core.CTFReaderException;
+import org.eclipse.tracecompass.ctf.core.CTFException;
import org.eclipse.tracecompass.ctf.core.event.io.BitBuffer;
import org.eclipse.tracecompass.ctf.core.event.scope.IDefinitionScope;
import org.eclipse.tracecompass.ctf.core.event.types.Encoding;
* Run the EnumDefinition createDefinition(DefinitionScope,String) method
* test.
*
- * @throws CTFReaderException
+ * @throws CTFException
* out of bounds error, won't happen
*/
@Test
- public void testCreateDefinition() throws CTFReaderException {
+ public void testCreateDefinition() throws CTFException {
IDefinitionScope definitionScope = null;
String fieldName = "";
byte[] array = { 't', 'e', 's', 't', '\0', 't', 'h', 'i', 's', '\0' };
import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeTrue;
-import org.eclipse.tracecompass.ctf.core.CTFReaderException;
+import org.eclipse.tracecompass.ctf.core.CTFException;
import org.eclipse.tracecompass.ctf.core.event.EventDefinition;
import org.eclipse.tracecompass.ctf.core.event.types.StructDeclaration;
import org.eclipse.tracecompass.ctf.core.tests.shared.CtfTestTrace;
/**
* Perform pre-test initialization.
*
- * @throws CTFReaderException
+ * @throws CTFException
*/
@Before
- public void setUp() throws CTFReaderException {
+ public void setUp() throws CTFException {
assumeTrue(testTrace.exists());
fixture = new EventDeclaration();
fixture.setContext(new StructDeclaration(1L));
/**
* Run the boolean equals(Object) method test.
*
- * @throws CTFReaderException
+ * @throws CTFException
*/
@Test
- public void testEquals() throws CTFReaderException {
+ public void testEquals() throws CTFException {
EventDeclaration obj = new EventDeclaration();
obj.setContext(new StructDeclaration(1L));
obj.setId(1L);
/**
* Test for the EventDefinition class
*
- * @throws CTFReaderException
+ * @throws CTFException
*/
@Test
- public void testEventDefinition() throws CTFReaderException {
+ public void testEventDefinition() throws CTFException {
CTFTrace trace = testTrace.getTrace();
EventDefinition ed = null;
try (CTFTraceReader tr = new CTFTraceReader(trace);) {
import java.util.ArrayList;
import java.util.List;
-import org.eclipse.tracecompass.ctf.core.CTFReaderException;
+import org.eclipse.tracecompass.ctf.core.CTFException;
import org.eclipse.tracecompass.ctf.core.event.io.BitBuffer;
import org.eclipse.tracecompass.ctf.core.event.types.Encoding;
import org.eclipse.tracecompass.ctf.core.event.types.EnumDeclaration;
/**
* Test an compact compact header
*
- * @throws CTFReaderException
+ * @throws CTFException
* if {@link BitBuffer} is null
*/
@Test
- public void testCompactCompact() throws CTFReaderException {
+ public void testCompactCompact() throws CTFException {
ByteBuffer buffer = ByteBuffer.allocate(16);
buffer.putInt(0x80000042);
byte[] validCompact1 = buffer.array();
/**
* Test an extended compact header
*
- * @throws CTFReaderException
+ * @throws CTFException
* if {@link BitBuffer} is null
*/
@Test
- public void testCompactExtended() throws CTFReaderException {
+ public void testCompactExtended() throws CTFException {
ByteBuffer buffer = ByteBuffer.allocate(16);
buffer.put((byte) 0xFF);
buffer.putInt(ID);
/**
* Test an compact large header
*
- * @throws CTFReaderException
+ * @throws CTFException
* if {@link BitBuffer} is null
*/
@Test
- public void testLargeCompact() throws CTFReaderException {
+ public void testLargeCompact() throws CTFException {
ByteBuffer buffer = ByteBuffer.allocate(16);
buffer.putShort((short) ID);
buffer.putInt(TIMESTAMP);
/**
* Test an large large header
*
- * @throws CTFReaderException
+ * @throws CTFException
* if {@link BitBuffer} is null
*/
@Test
- public void testLargeExtended() throws CTFReaderException {
+ public void testLargeExtended() throws CTFException {
ByteBuffer buffer = ByteBuffer.allocate(16);
buffer.putShort((short) -1);
buffer.putInt(ID);
import java.nio.ByteOrder;
import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.tracecompass.ctf.core.CTFReaderException;
+import org.eclipse.tracecompass.ctf.core.CTFException;
import org.eclipse.tracecompass.ctf.core.event.io.BitBuffer;
import org.eclipse.tracecompass.ctf.core.event.types.FloatDeclaration;
import org.eclipse.tracecompass.ctf.core.event.types.FloatDefinition;
/**
* Perform pre-test initialization.
*
- * @throws CTFReaderException
+ * @throws CTFException
* error creating floats
*/
@Before
- public void setUp() throws CTFReaderException {
+ public void setUp() throws CTFException {
testFloat248();
testFloat5311();
}
@Test
- public void testFloat248() throws CTFReaderException {
+ public void testFloat248() throws CTFException {
parent = new FloatDeclaration(8, 24, ByteOrder.nativeOrder(), 0);
BitBuffer bb = create32BitFloatByteBuffer();
singleFixture = parent.createDefinition(null, fieldName, bb);
}
@Test
- public void testFloat5311() throws CTFReaderException {
+ public void testFloat5311() throws CTFException {
parent = new FloatDeclaration(11, 53, ByteOrder.nativeOrder(), 0);
BitBuffer bb = create64BitFloatByteBuffer();
doubleFixture = parent.createDefinition(null, fieldName, bb);
}
@Test
- public void testFloat32Bit() throws CTFReaderException {
+ public void testFloat32Bit() throws CTFException {
for (int i = 1; i < 31; i++) {
parent = new FloatDeclaration(i, 32 - i, ByteOrder.nativeOrder(), 0);
}
@Test
- public void testFloat64Bit() throws CTFReaderException {
+ public void testFloat64Bit() throws CTFException {
for (int i = 1; i < 63; i++) {
parent = new FloatDeclaration(i, 64 - i, ByteOrder.nativeOrder(), 0);
fixture = parent.createDefinition(null, fieldName, create64BitFloatByteBuffer());
}
@Test
- public void testFloat48Bit() throws CTFReaderException {
+ public void testFloat48Bit() throws CTFException {
parent = new FloatDeclaration(12, 32, ByteOrder.nativeOrder(), 0);
fixture = parent.createDefinition(null, fieldName, create64BitFloatByteBuffer());
assertNotNull(fixture);
import java.nio.ByteOrder;
import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.tracecompass.ctf.core.CTFReaderException;
+import org.eclipse.tracecompass.ctf.core.CTFException;
import org.eclipse.tracecompass.ctf.core.event.io.BitBuffer;
import org.eclipse.tracecompass.ctf.core.event.scope.IDefinitionScope;
import org.eclipse.tracecompass.ctf.core.event.types.Encoding;
/**
* Perform pre-test initialization.
*
- * @throws CTFReaderException
+ * @throws CTFException
* won't happen
*/
@Before
- public void setUp() throws CTFReaderException {
+ public void setUp() throws CTFException {
IntegerDeclaration id = IntegerDeclaration.createDeclaration(1, false, 1, ByteOrder.BIG_ENDIAN, Encoding.NONE, clockName, 8);
ByteBuffer byb = ByteBuffer.allocate(128);
byb.mark();
import java.nio.ByteOrder;
import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.tracecompass.ctf.core.CTFReaderException;
+import org.eclipse.tracecompass.ctf.core.CTFException;
import org.eclipse.tracecompass.ctf.core.event.io.BitBuffer;
import org.eclipse.tracecompass.ctf.core.event.types.Encoding;
import org.eclipse.tracecompass.ctf.core.event.types.IntegerDeclaration;
/**
* Read 32-bits BE
*
- * @throws CTFReaderException
+ * @throws CTFException
* error
*/
@Test
- public void test32BE() throws CTFReaderException {
+ public void test32BE() throws CTFException {
IntegerDeclaration be = IntegerDeclaration.createDeclaration(32, true, 1, ByteOrder.BIG_ENDIAN, Encoding.NONE, clockName, 8);
IntegerDefinition fixture_be = be.createDefinition(null, name, input);
assertEquals(0xabcdef12, fixture_be.getValue());
/**
* Read 64-bits BE
*
- * @throws CTFReaderException
+ * @throws CTFException
* error
*/
@Test
- public void test64BE() throws CTFReaderException {
+ public void test64BE() throws CTFException {
IntegerDeclaration be = IntegerDeclaration.createDeclaration(64, true, 1, ByteOrder.BIG_ENDIAN, Encoding.NONE, clockName, 8);
IntegerDefinition fixture_be = be.createDefinition(null, name, input);
assertEquals(0xabcdef123456789aL, fixture_be.getValue());
/**
* Read 32-bits LE
*
- * @throws CTFReaderException
+ * @throws CTFException
* error
*/
@Test
- public void test32LE() throws CTFReaderException {
+ public void test32LE() throws CTFException {
IntegerDeclaration le = IntegerDeclaration.createDeclaration(32, true, 1, ByteOrder.LITTLE_ENDIAN, Encoding.NONE, clockName, 8);
IntegerDefinition fixture_le = le.createDefinition(null, name, input);
assertEquals(0x12efcdab, fixture_le.getValue());
/**
* Read 64-bits LE
*
- * @throws CTFReaderException
+ * @throws CTFException
* error
*/
@Test
- public void test64LE() throws CTFReaderException {
+ public void test64LE() throws CTFException {
IntegerDeclaration le = IntegerDeclaration.createDeclaration(64, true, 1, ByteOrder.LITTLE_ENDIAN, Encoding.NONE, clockName, 8);
IntegerDefinition fixture_le = le.createDefinition(null, name, input);
assertEquals(0x9a78563412efcdabL, fixture_le.getValue());
import java.nio.ByteOrder;
import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.tracecompass.ctf.core.CTFReaderException;
+import org.eclipse.tracecompass.ctf.core.CTFException;
import org.eclipse.tracecompass.ctf.core.event.io.BitBuffer;
import org.eclipse.tracecompass.ctf.core.event.types.AbstractArrayDefinition;
import org.eclipse.tracecompass.ctf.core.event.types.Definition;
* Run the SequenceDefinition createDefinition(DefinitionScope,String)
* method test.
*
- * @throws CTFReaderException
+ * @throws CTFException
* an error in the bitbuffer
*/
@Test
- public void testCreateDefinition() throws CTFReaderException {
+ public void testCreateDefinition() throws CTFException {
long seqLen = 2;
IntegerDeclaration id = IntegerDeclaration.createDeclaration(8, false, 8,
ByteOrder.LITTLE_ENDIAN, Encoding.UTF8, "", 32);
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
-import org.eclipse.tracecompass.ctf.core.CTFReaderException;
+import org.eclipse.tracecompass.ctf.core.CTFException;
import org.eclipse.tracecompass.ctf.core.event.io.BitBuffer;
import org.eclipse.tracecompass.ctf.core.event.types.Definition;
import org.eclipse.tracecompass.ctf.core.event.types.Encoding;
/**
* Perform pre-test initialization.
*
- * @throws CTFReaderException
+ * @throws CTFException
*/
@Before
- public void setUp() throws CTFReaderException {
+ public void setUp() throws CTFException {
fixture = initString();
}
- private static ByteArrayDefinition initString() throws CTFReaderException {
+ private static ByteArrayDefinition initString() throws CTFException {
StructDeclaration structDec;
StructDefinition structDef;
import java.nio.ByteBuffer;
-import org.eclipse.tracecompass.ctf.core.CTFReaderException;
+import org.eclipse.tracecompass.ctf.core.CTFException;
import org.eclipse.tracecompass.ctf.core.event.io.BitBuffer;
import org.eclipse.tracecompass.ctf.core.event.scope.IDefinitionScope;
import org.eclipse.tracecompass.ctf.core.event.types.Encoding;
* Run the StringDefinition createDefinition(DefinitionScope,String) method
* test.
*
- * @throws CTFReaderException
+ * @throws CTFException
* out of buffer exception
*/
@Test
- public void testCreateDefinition() throws CTFReaderException {
+ public void testCreateDefinition() throws CTFException {
IDefinitionScope definitionScope = null;
String fieldName = "id";
ByteBuffer allocate = ByteBuffer.allocate(100);
import java.nio.ByteBuffer;
-import org.eclipse.tracecompass.ctf.core.CTFReaderException;
+import org.eclipse.tracecompass.ctf.core.CTFException;
import org.eclipse.tracecompass.ctf.core.event.io.BitBuffer;
import org.eclipse.tracecompass.ctf.core.event.scope.IDefinitionScope;
import org.eclipse.tracecompass.ctf.core.event.types.Encoding;
/**
* Perform pre-test initialization.
*
- * @throws CTFReaderException
+ * @throws CTFException
* won't happen
*/
@Before
- public void setUp() throws CTFReaderException {
+ public void setUp() throws CTFException {
String name = "testString";
StringDeclaration stringDec = StringDeclaration.getStringDeclaration(Encoding.UTF8);
ByteBuffer byteBuffer = ByteBuffer.allocate(100);
import java.nio.ByteBuffer;
-import org.eclipse.tracecompass.ctf.core.CTFReaderException;
+import org.eclipse.tracecompass.ctf.core.CTFException;
import org.eclipse.tracecompass.ctf.core.event.io.BitBuffer;
import org.eclipse.tracecompass.ctf.core.event.types.Encoding;
import org.eclipse.tracecompass.ctf.core.event.types.IDeclaration;
* Run the StructDefinition createDefinition(DefinitionScope,String) method
* test.
*
- * @throws CTFReaderException
+ * @throws CTFException
* out of bounds
*/
@Test
- public void testCreateDefinition() throws CTFReaderException {
+ public void testCreateDefinition() throws CTFException {
String fieldName = "";
ByteBuffer allocate = ByteBuffer.allocate(100);
if (allocate == null) {
import java.nio.ByteBuffer;
import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.tracecompass.ctf.core.CTFReaderException;
+import org.eclipse.tracecompass.ctf.core.CTFException;
import org.eclipse.tracecompass.ctf.core.event.io.BitBuffer;
import org.eclipse.tracecompass.ctf.core.event.types.AbstractArrayDefinition;
import org.eclipse.tracecompass.ctf.core.event.types.Encoding;
/**
* Perform pre-test initialization.
*
- * @throws CTFReaderException
+ * @throws CTFException
* won't happen
*/
@Before
- public void setUp() throws CTFReaderException {
+ public void setUp() throws CTFException {
StructDeclaration sDec = new StructDeclaration(12);
IntegerDeclaration id = IntegerDeclaration.INT_32B_DECL;
IntegerDeclaration lenDec = IntegerDeclaration.UINT_8_DECL;
import java.nio.ByteBuffer;
-import org.eclipse.tracecompass.ctf.core.CTFReaderException;
+import org.eclipse.tracecompass.ctf.core.CTFException;
import org.eclipse.tracecompass.ctf.core.event.io.BitBuffer;
import org.eclipse.tracecompass.ctf.core.event.scope.IDefinitionScope;
import org.eclipse.tracecompass.ctf.core.event.types.Definition;
fixture = new VariantDeclaration();
}
- private static IDefinitionScope createDefinitionScope() throws CTFReaderException {
+ private static IDefinitionScope createDefinitionScope() throws CTFException {
assumeTrue(testTrace.exists());
StructDeclaration declaration = new StructDeclaration(8);
VariantDeclaration variantDeclaration = new VariantDeclaration();
* Run the VariantDefinition createDefinition(DefinitionScope,String) method
* test.
*
- * @throws CTFReaderException
+ * @throws CTFException
* Should not happen
*/
@Test
- public void testCreateDefinition() throws CTFReaderException {
+ public void testCreateDefinition() throws CTFException {
fixture.setTag("tag");
fixture.addField("a", IntegerDeclaration.UINT_64B_DECL);
IDefinitionScope definitionScope = createDefinitionScope();
import java.nio.ByteOrder;
import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.tracecompass.ctf.core.CTFReaderException;
+import org.eclipse.tracecompass.ctf.core.CTFException;
import org.eclipse.tracecompass.ctf.core.event.io.BitBuffer;
import org.eclipse.tracecompass.ctf.core.event.scope.IDefinitionScope;
import org.eclipse.tracecompass.ctf.core.event.types.AbstractArrayDefinition;
*
* Not sure it needs to be that complicated, oh well...
*
- * @throws CTFReaderException
+ * @throws CTFException
* won't happen
*/
@Before
- public void setUp() throws CTFReaderException {
+ public void setUp() throws CTFException {
StructDeclaration sDec = new StructDeclaration(12);
StructDeclaration smallStruct = new StructDeclaration(8);
IntegerDeclaration iDec = IntegerDeclaration.createDeclaration(32, false, 32, ByteOrder.BIG_ENDIAN, Encoding.NONE, "", 8);
/**
* Run the VariantDefinition(VariantDeclaration,DefinitionScope,String)
*
- * @throws CTFReaderException
+ * @throws CTFException
* should not happen
*/
@Test
- public void testVariantDefinition() throws CTFReaderException {
+ public void testVariantDefinition() throws CTFException {
VariantDeclaration declaration = new VariantDeclaration();
declaration.setTag("");
VariantDeclaration variantDeclaration = new VariantDeclaration();
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2011, 2014 Ericsson, Ecole Polytechnique de Montreal
+ *
+ * All rights reserved. This program and the accompanying materials are made
+ * available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexandre Montplaisir - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.ctf.core;
+
+/**
+ * General exception that is thrown when there is a problem somewhere with the
+ * CTF trace reader.
+ *
+ * @author Alexandre Montplaisir
+ * @since 1.0
+ */
+public class CTFException extends Exception {
+
+ private static final long serialVersionUID = 2065258365219777672L;
+
+ /**
+ * Default constructor with no message.
+ */
+ public CTFException() {
+ super();
+ }
+
+ /**
+ * Constructor with an attached message.
+ *
+ * @param message
+ * The message attached to this exception
+ */
+ public CTFException(String message) {
+ super(message);
+ }
+
+ /**
+ * Re-throw an exception into this type.
+ *
+ * @param e
+ * The previous Exception we caught
+ */
+ public CTFException(Exception e) {
+ super(e);
+ }
+
+ /**
+ * Constructor with an attached message and re-throw an exception into this type.
+ *
+ * @param message
+ * The message attached to this exception
+ * @param exception
+ * The previous Exception caught
+ */
+ public CTFException(String message, Throwable exception) {
+ super(message, exception);
+ }
+
+}
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2011, 2014 Ericsson, Ecole Polytechnique de Montreal
- *
- * All rights reserved. This program and the accompanying materials are made
- * available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Alexandre Montplaisir - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.tracecompass.ctf.core;
-
-/**
- * General exception that is thrown when there is a problem somewhere with the
- * CTF trace reader.
- *
- * @author Alexandre Montplaisir
- * @since 1.0
- */
-public class CTFReaderException extends Exception {
-
- private static final long serialVersionUID = 2065258365219777672L;
-
- /**
- * Default constructor with no message.
- */
- public CTFReaderException() {
- super();
- }
-
- /**
- * Constructor with an attached message.
- *
- * @param message
- * The message attached to this exception
- */
- public CTFReaderException(String message) {
- super(message);
- }
-
- /**
- * Re-throw an exception into this type.
- *
- * @param e
- * The previous Exception we caught
- */
- public CTFReaderException(Exception e) {
- super(e);
- }
-
- /**
- * Constructor with an attached message and re-throw an exception into this type.
- *
- * @param message
- * The message attached to this exception
- * @param exception
- * The previous Exception caught
- */
- public CTFReaderException(String message, Throwable exception) {
- super(message, exception);
- }
-
-}
import java.util.Set;
import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.tracecompass.ctf.core.CTFReaderException;
+import org.eclipse.tracecompass.ctf.core.CTFException;
import org.eclipse.tracecompass.ctf.core.event.io.BitBuffer;
import org.eclipse.tracecompass.ctf.core.event.types.StructDeclaration;
import org.eclipse.tracecompass.ctf.core.trace.CTFStream;
* @param timestamp
* The timestamp when the event was taken
* @return A new EventDefinition.
- * @throws CTFReaderException
+ * @throws CTFException
* As a bitbuffer is used to read, it could have wrapped
* IOExceptions.
*/
- EventDefinition createDefinition(CTFStreamInputReader streamInputReader, @NonNull BitBuffer input, long timestamp) throws CTFReaderException;
+ EventDefinition createDefinition(CTFStreamInputReader streamInputReader, @NonNull BitBuffer input, long timestamp) throws CTFException;
/**
* Gets the name of an event declaration
import java.nio.ByteOrder;
import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.tracecompass.ctf.core.CTFReaderException;
+import org.eclipse.tracecompass.ctf.core.CTFException;
/**
* <b><u>BitBuffer</u></b>
* byte order.
*
* @return The int value (signed) read from the buffer
- * @throws CTFReaderException
+ * @throws CTFException
* An error occurred reading the long. This exception can be
* raised if the buffer tries to read out of bounds
*/
- public int getInt() throws CTFReaderException {
+ public int getInt() throws CTFException {
return getInt(BIT_INT, true);
}
* byte order.
*
* @return The long value (signed) read from the buffer
- * @throws CTFReaderException
+ * @throws CTFException
* An error occurred reading the long. This exception can be
* raised if the buffer tries to read out of bounds
*/
- public long getLong() throws CTFReaderException {
+ public long getLong() throws CTFException {
return get(BIT_LONG, true);
}
* @param signed
* The sign extended flag
* @return The long value read from the buffer
- * @throws CTFReaderException
+ * @throws CTFException
* An error occurred reading the data. If more than 64 bits at a
* time are read, or the buffer is read beyond its end, this
* exception will be raised.
*/
- public long get(int length, boolean signed) throws CTFReaderException {
+ public long get(int length, boolean signed) throws CTFException {
if (length > BIT_LONG) {
- throw new CTFReaderException("Cannot read a long longer than 64 bits. Rquested: " + length); //$NON-NLS-1$
+ throw new CTFException("Cannot read a long longer than 64 bits. Rquested: " + length); //$NON-NLS-1$
}
if (length > BIT_INT) {
final int highShift = length - BIT_INT;
* @param signed
* The sign extended flag
* @return The int value read from the buffer
- * @throws CTFReaderException
+ * @throws CTFException
* An error occurred reading the data. When the buffer is read
* beyond its end, this exception will be raised.
*/
- private int getInt(int length, boolean signed) throws CTFReaderException {
+ private int getInt(int length, boolean signed) throws CTFException {
/* Nothing to read. */
if (length == 0) {
/* Validate that the buffer has enough bits. */
if (!canRead(length)) {
- throw new CTFReaderException("Cannot read the integer, " + //$NON-NLS-1$
+ throw new CTFException("Cannot read the integer, " + //$NON-NLS-1$
"the buffer does not have enough remaining space. " + //$NON-NLS-1$
"Requested:" + length); //$NON-NLS-1$
}
*
* @param value
* The int value to write
- * @throws CTFReaderException
+ * @throws CTFException
* An error occurred writing the data. If the buffer is written
* beyond its end, this exception will be raised.
*/
- public void putInt(int value) throws CTFReaderException {
+ public void putInt(int value) throws CTFException {
putInt(BIT_INT, value);
}
* The number of bits to write
* @param value
* The value to write
- * @throws CTFReaderException
+ * @throws CTFException
* An error occurred writing the data. If the buffer is written
* beyond its end, this exception will be raised.
*/
- public void putInt(int length, int value) throws CTFReaderException {
+ public void putInt(int length, int value) throws CTFException {
final long curPos = fPosition;
if (!canRead(length)) {
- throw new CTFReaderException("Cannot write to bitbuffer, " //$NON-NLS-1$
+ throw new CTFException("Cannot write to bitbuffer, " //$NON-NLS-1$
+ "insufficient space. Requested: " + length); //$NON-NLS-1$
}
if (length == 0) {
*
* @param newPosition
* The new position of the buffer.
- * @throws CTFReaderException
+ * @throws CTFException
* Thrown on out of bounds exceptions
*/
- public void position(long newPosition) throws CTFReaderException {
+ public void position(long newPosition) throws CTFException {
if (newPosition > fBitCapacity) {
- throw new CTFReaderException("Out of bounds exception on a position move, attempting to access position: " + newPosition); //$NON-NLS-1$
+ throw new CTFException("Out of bounds exception on a position move, attempting to access position: " + newPosition); //$NON-NLS-1$
}
fPosition = newPosition;
}
package org.eclipse.tracecompass.ctf.core.event.types;
import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.tracecompass.ctf.core.CTFReaderException;
+import org.eclipse.tracecompass.ctf.core.CTFException;
import org.eclipse.tracecompass.ctf.core.event.io.BitBuffer;
import org.eclipse.tracecompass.ctf.core.event.scope.IDefinitionScope;
import org.eclipse.tracecompass.ctf.core.event.scope.ILexicalScope;
*
* @param input
* The bitbuffer that is being read
- * @throws CTFReaderException
+ * @throws CTFException
* Happens when there is an out of bounds exception
*/
- protected final void alignRead(BitBuffer input) throws CTFReaderException {
+ protected final void alignRead(BitBuffer input) throws CTFException {
long mask = getAlignment() - 1;
/*
* The alignment is a power of 2
import java.util.Set;
import org.eclipse.jdt.annotation.Nullable;
-import org.eclipse.tracecompass.ctf.core.CTFReaderException;
+import org.eclipse.tracecompass.ctf.core.CTFException;
import org.eclipse.tracecompass.ctf.core.event.io.BitBuffer;
import org.eclipse.tracecompass.ctf.core.event.scope.IDefinitionScope;
// ------------------------------------------------------------------------
@Override
- public EnumDefinition createDefinition(@Nullable IDefinitionScope definitionScope, String fieldName, BitBuffer input) throws CTFReaderException {
+ public EnumDefinition createDefinition(@Nullable IDefinitionScope definitionScope, String fieldName, BitBuffer input) throws CTFException {
alignRead(input);
IntegerDefinition value = getContainerType().createDefinition(definitionScope, fieldName, input);
return new EnumDefinition(this, definitionScope, fieldName, value);
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
-import org.eclipse.tracecompass.ctf.core.CTFReaderException;
+import org.eclipse.tracecompass.ctf.core.CTFException;
import org.eclipse.tracecompass.ctf.core.event.io.BitBuffer;
import org.eclipse.tracecompass.ctf.core.event.scope.IDefinitionScope;
@Override
public FloatDefinition createDefinition(@Nullable IDefinitionScope definitionScope,
- String fieldName, BitBuffer input) throws CTFReaderException {
+ String fieldName, BitBuffer input) throws CTFException {
ByteOrder byteOrder = input.getByteOrder();
input.setByteOrder(fByteOrder);
double value = read(input);
return "[declaration] float[" + Integer.toHexString(hashCode()) + ']'; //$NON-NLS-1$
}
- private double read(BitBuffer input) throws CTFReaderException {
+ private double read(BitBuffer input) throws CTFException {
/* Offset the buffer position wrt the current alignment */
alignRead(input);
final int exp = getExponent();
}
private static double readRawFloat32(BitBuffer input, final int manBits,
- final int expBits) throws CTFReaderException {
+ final int expBits) throws CTFException {
long temp = input.get(32, false);
return createFloat(temp, manBits - 1, expBits);
}
private static double readRawFloat64(BitBuffer input, final int manBits,
- final int expBits) throws CTFReaderException {
+ final int expBits) throws CTFException {
long temp = input.get(64, false);
return createFloat(temp, manBits - 1, expBits);
}
package org.eclipse.tracecompass.ctf.core.event.types;
import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.tracecompass.ctf.core.CTFReaderException;
+import org.eclipse.tracecompass.ctf.core.CTFException;
import org.eclipse.tracecompass.ctf.core.event.io.BitBuffer;
import org.eclipse.tracecompass.ctf.core.event.scope.IDefinitionScope;
import org.eclipse.tracecompass.ctf.core.event.scope.ILexicalScope;
* @param input
* a bitbuffer to read from
* @return a reference to the definition
- * @throws CTFReaderException
+ * @throws CTFException
* error in reading
*/
- Definition createDefinition(IDefinitionScope definitionScope, @NonNull String fieldName, @NonNull BitBuffer input) throws CTFReaderException;
+ Definition createDefinition(IDefinitionScope definitionScope, @NonNull String fieldName, @NonNull BitBuffer input) throws CTFException;
/**
* Get the path of a definition
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
-import org.eclipse.tracecompass.ctf.core.CTFReaderException;
+import org.eclipse.tracecompass.ctf.core.CTFException;
import org.eclipse.tracecompass.ctf.core.event.io.BitBuffer;
import org.eclipse.tracecompass.ctf.core.event.scope.IDefinitionScope;
@Override
public IntegerDefinition createDefinition(@Nullable IDefinitionScope definitionScope,
- String fieldName, BitBuffer input) throws CTFReaderException {
+ String fieldName, BitBuffer input) throws CTFException {
ByteOrder byteOrder = input.getByteOrder();
input.setByteOrder(fByteOrder);
long value = read(input);
return checkNotNull(BigInteger.ONE.shiftLeft(significantBits).negate());
}
- private long read(BitBuffer input) throws CTFReaderException {
+ private long read(BitBuffer input) throws CTFException {
/* Offset the buffer position wrt the current alignment */
alignRead(input);
}
if (length > SIZE_64) {
- throw new CTFReaderException("Cannot read an integer with over 64 bits. Length given: " + length); //$NON-NLS-1$
+ throw new CTFException("Cannot read an integer with over 64 bits. Length given: " + length); //$NON-NLS-1$
}
bits = input.get(length, signed);
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.tracecompass.common.core.NonNullUtils;
-import org.eclipse.tracecompass.ctf.core.CTFReaderException;
+import org.eclipse.tracecompass.ctf.core.CTFException;
import org.eclipse.tracecompass.ctf.core.event.io.BitBuffer;
import org.eclipse.tracecompass.ctf.core.event.scope.IDefinitionScope;
@Override
public StringDefinition createDefinition(@Nullable IDefinitionScope definitionScope,
- String fieldName, BitBuffer input) throws CTFReaderException {
+ String fieldName, BitBuffer input) throws CTFException {
String value = read(input);
return new StringDefinition(this, definitionScope, fieldName, value);
}
- private String read(BitBuffer input) throws CTFReaderException {
+ private String read(BitBuffer input) throws CTFException {
/* Offset the buffer position wrt the current alignment */
alignRead(input);
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
-import org.eclipse.tracecompass.ctf.core.CTFReaderException;
+import org.eclipse.tracecompass.ctf.core.CTFException;
import org.eclipse.tracecompass.ctf.core.event.io.BitBuffer;
import org.eclipse.tracecompass.ctf.core.event.scope.IDefinitionScope;
import org.eclipse.tracecompass.ctf.core.event.scope.ILexicalScope;
@Override
public StructDefinition createDefinition(IDefinitionScope definitionScope,
- String fieldName, BitBuffer input) throws CTFReaderException {
+ String fieldName, BitBuffer input) throws CTFException {
alignRead(input);
final Definition[] myFields = new Definition[fFieldMap.size()];
StructDefinition structDefinition = new StructDefinition(this, definitionScope, fieldName, fFieldMap.keySet(), myFields);
* @param input
* a bitbuffer to read from
* @return a reference to the definition
- * @throws CTFReaderException
+ * @throws CTFException
* error in reading
* @since 1.0
*/
public StructDefinition createDefinition(IDefinitionScope definitionScope,
- ILexicalScope fieldScope, @NonNull BitBuffer input) throws CTFReaderException {
+ ILexicalScope fieldScope, @NonNull BitBuffer input) throws CTFException {
alignRead(input);
final Definition[] myFields = new Definition[fFieldMap.size()];
fMaxAlign = Math.max(fMaxAlign, declaration.getAlignment());
}
- private void fillStruct(@NonNull BitBuffer input, final Definition[] myFields, StructDefinition structDefinition) throws CTFReaderException {
+ private void fillStruct(@NonNull BitBuffer input, final Definition[] myFields, StructDefinition structDefinition) throws CTFException {
Iterator<Map.Entry<String, IDeclaration>> iter = fFieldMap.entrySet().iterator();
for (int i = 0; i < fFieldMap.size(); i++) {
Map.Entry<String, IDeclaration> entry = iter.next();
import java.util.Map;
import java.util.Map.Entry;
-import org.eclipse.tracecompass.ctf.core.CTFReaderException;
+import org.eclipse.tracecompass.ctf.core.CTFException;
import org.eclipse.tracecompass.ctf.core.event.io.BitBuffer;
import org.eclipse.tracecompass.ctf.core.event.scope.IDefinitionScope;
@Override
public VariantDefinition createDefinition(IDefinitionScope definitionScope,
- String fieldName, BitBuffer input) throws CTFReaderException {
+ String fieldName, BitBuffer input) throws CTFException {
alignRead(input);
Definition def = definitionScope.lookupDefinition(fTag);
EnumDefinition tagDef = (EnumDefinition) ((def instanceof EnumDefinition) ? def : null);
if (tagDef == null) {
- throw new CTFReaderException("Tag is not defined " + fTag); //$NON-NLS-1$
+ throw new CTFException("Tag is not defined " + fTag); //$NON-NLS-1$
}
String varFieldName = tagDef.getStringValue();
fDeclarationToPopulate = fFields.get(varFieldName);
if (fDeclarationToPopulate == null) {
- throw new CTFReaderException("Unknown enum selector for variant " + //$NON-NLS-1$
+ throw new CTFException("Unknown enum selector for variant " + //$NON-NLS-1$
definitionScope.getScopePath().getPath());
}
Definition fieldValue = fDeclarationToPopulate.createDefinition(definitionScope, fieldName, input);
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2015 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are made
+ * available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: Matthew Khouzam - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tracecompass.ctf.core.trace;
+
+import org.eclipse.tracecompass.ctf.core.CTFException;
+
+/**
+ * An exception just for trace readers and writers
+ *
+ * @since 1.0
+ */
+public class CTFIOException extends CTFException {
+
+ /**
+ * Unique ID
+ */
+ private static final long serialVersionUID = -2216400542574921838L;
+
+ /**
+ * Constructor with an attached message.
+ *
+ * @param message
+ * The message attached to this exception
+ */
+ public CTFIOException(String message) {
+ super(message);
+ }
+
+ /**
+ * Constructor with an attached message.
+ *
+ * @param e
+ * The exception attached to this exception
+ */
+ public CTFIOException(Exception e) {
+ super(e);
+ }
+
+ /**
+ * Constructor with an attached message and exception.
+ *
+ * @param message
+ * The message attached to this exception
+ * @param e
+ * The encapsulated exception
+ * @since 1.0
+ */
+ public CTFIOException(String message, Exception e) {
+ super(message, e);
+ }
+
+}
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
-import org.eclipse.tracecompass.ctf.core.CTFReaderException;
+import org.eclipse.tracecompass.ctf.core.CTFException;
import org.eclipse.tracecompass.ctf.core.event.IEventDeclaration;
import org.eclipse.tracecompass.ctf.core.event.types.IDeclaration;
import org.eclipse.tracecompass.ctf.core.event.types.IEventHeaderDeclaration;
*
* @param events
* list of the events to add
- * @throws CTFReaderException
+ * @throws CTFException
* if the list already contains data
*/
- public void addEvents(Collection<IEventDeclaration> events) throws CTFReaderException {
+ public void addEvents(Collection<IEventDeclaration> events) throws CTFException {
if (fEventUnsetId) {
- throw new CTFReaderException("Cannot add to a stream with an unidentified event"); //$NON-NLS-1$
+ throw new CTFException("Cannot add to a stream with an unidentified event"); //$NON-NLS-1$
}
if (fEvents.isEmpty()) {
fEvents.addAll(events);
int index = event.getId().intValue();
ensureSize(fEvents, index);
if (fEvents.get(index) != null) {
- throw new CTFReaderException("Both lists have an event defined at position " + index); //$NON-NLS-1$
+ throw new CTFException("Both lists have an event defined at position " + index); //$NON-NLS-1$
}
fEvents.set(index, event);
}
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
-import org.eclipse.tracecompass.ctf.core.CTFReaderException;
+import org.eclipse.tracecompass.ctf.core.CTFException;
import org.eclipse.tracecompass.ctf.core.event.io.BitBuffer;
import org.eclipse.tracecompass.ctf.core.event.scope.IDefinitionScope;
import org.eclipse.tracecompass.ctf.core.event.scope.ILexicalScope;
* properly</strong>
*
* @return true if there are more packets to add
- * @throws CTFReaderException
+ * @throws CTFException
* If there was a problem reading the packed header
*/
- public boolean addPacketHeaderIndex() throws CTFReaderException {
+ public boolean addPacketHeaderIndex() throws CTFException {
long currentPosBits = 0L;
if (!fIndex.isEmpty()) {
StreamInputPacketIndexEntry pos = fIndex.lastElement();
}
private StreamInputPacketIndexEntry createPacketIndexEntry(long dataOffsetbits)
- throws CTFReaderException {
+ throws CTFException {
try (FileChannel fc = FileChannel.open(fFile.toPath(), StandardOpenOption.READ)) {
if (fc == null) {
/* Basic validation */
if (packetIndex.getContentSizeBits() > packetIndex.getPacketSizeBits()) {
- throw new CTFReaderException("Content size > packet size"); //$NON-NLS-1$
+ throw new CTFException("Content size > packet size"); //$NON-NLS-1$
}
if (packetIndex.getPacketSizeBits() > ((size * Byte.SIZE - packetIndex.getOffsetBits()))) {
- throw new CTFReaderException("Not enough data remaining in the file for the size of this packet"); //$NON-NLS-1$
+ throw new CTFException("Not enough data remaining in the file for the size of this packet"); //$NON-NLS-1$
}
return packetIndex;
} catch (IOException e) {
- throw new CTFReaderException("Failed to create packet index entry", e); //$NON-NLS-1$
+ throw new CTFException("Failed to create packet index entry", e); //$NON-NLS-1$
}
}
- private BitBuffer createBitBufferForPacketHeader(FileChannel fc, long dataOffsetbits) throws CTFReaderException, IOException {
+ private BitBuffer createBitBufferForPacketHeader(FileChannel fc, long dataOffsetbits) throws CTFException, IOException {
/*
* create a packet bit buffer to read the packet header
*/
return bitBuffer;
}
- private static ByteBuffer getByteBufferAt(FileChannel fc, long position, long size) throws CTFReaderException, IOException {
+ private static ByteBuffer getByteBufferAt(FileChannel fc, long position, long size) throws CTFException, IOException {
ByteBuffer map = SafeMappedByteBuffer.map(fc, MapMode.READ_ONLY, position, size);
if (map == null) {
- throw new CTFReaderException("Failed to allocate mapped byte buffer"); //$NON-NLS-1$
+ throw new CTFException("Failed to allocate mapped byte buffer"); //$NON-NLS-1$
}
return map;
}
private static ByteBuffer createPacketBitBuffer(FileChannel fc,
- long packetOffsetBytes, long maxSize) throws CTFReaderException, IOException {
+ long packetOffsetBytes, long maxSize) throws CTFException, IOException {
/*
* If there is less data remaining than what we want to map, reduce the
* map size.
try {
return getByteBufferAt(fc, packetOffsetBytes, mapSize);
} catch (IllegalArgumentException | IOException e) {
- throw new CTFReaderException(e);
+ throw new CTFException(e);
}
}
private StructDefinition parseTracePacketHeader(
- BitBuffer bitBuffer) throws CTFReaderException {
+ BitBuffer bitBuffer) throws CTFException {
StructDefinition tracePacketHeaderDef = fTracePacketHeaderDecl.createDefinition(fStream.getTrace(), ILexicalScope.TRACE_PACKET_HEADER, bitBuffer);
if (magicDef != null) {
int magic = (int) magicDef.getValue();
if (magic != Utils.CTF_MAGIC) {
- throw new CTFReaderException(
+ throw new CTFException(
"CTF magic mismatch " + Integer.toHexString(magic) + " vs " + Integer.toHexString(Utils.CTF_MAGIC)); //$NON-NLS-1$//$NON-NLS-2$
}
}
UUID uuid = Utils.getUUIDfromDefinition(uuidDef);
if (!getStream().getTrace().getUUID().equals(uuid)) {
- throw new CTFReaderException("UUID mismatch"); //$NON-NLS-1$
+ throw new CTFException("UUID mismatch"); //$NON-NLS-1$
}
}
long streamID = streamIDDef.getValue();
if (streamID != getStream().getId()) {
- throw new CTFReaderException("Stream ID changing within a StreamInput"); //$NON-NLS-1$
+ throw new CTFException("Stream ID changing within a StreamInput"); //$NON-NLS-1$
}
}
return tracePacketHeaderDef;
}
private StreamInputPacketIndexEntry parsePacketContext(long dataOffsetBits, long fileSizeBytes,
- BitBuffer bitBuffer) throws CTFReaderException {
+ BitBuffer bitBuffer) throws CTFException {
StreamInputPacketIndexEntry packetIndex;
StructDefinition streamPacketContextDef = fStreamPacketContextDecl.createDefinition(this, ILexicalScope.STREAM_PACKET_CONTEXT, bitBuffer);
packetIndex = new StreamInputPacketIndexEntry(dataOffsetBits, streamPacketContextDef, fileSizeBytes, fLostSoFar);
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
-import org.eclipse.tracecompass.ctf.core.CTFReaderException;
+import org.eclipse.tracecompass.ctf.core.CTFException;
import org.eclipse.tracecompass.ctf.core.CTFStrings;
import org.eclipse.tracecompass.ctf.core.event.EventDefinition;
import org.eclipse.tracecompass.ctf.core.event.IEventDeclaration;
* @param input
* the bitbuffer to read from
* @return an context definition, can be null
- * @throws CTFReaderException
+ * @throws CTFException
* out of bounds exception or such
*/
- public StructDefinition getEventContextDefinition(@NonNull BitBuffer input) throws CTFReaderException {
+ public StructDefinition getEventContextDefinition(@NonNull BitBuffer input) throws CTFException {
return fStreamEventContextDecl.createDefinition(fStreamInputReader.getStreamInput(), ILexicalScope.STREAM_EVENT_CONTEXT, input);
}
* @param input
* the bitbuffer to read from
* @return an context definition, can be null
- * @throws CTFReaderException
+ * @throws CTFException
* out of bounds exception or such
*/
- public StructDefinition getStreamPacketContextDefinition(@NonNull BitBuffer input) throws CTFReaderException {
+ public StructDefinition getStreamPacketContextDefinition(@NonNull BitBuffer input) throws CTFException {
return fStreamPacketContextDecl.createDefinition(fStreamInputReader.getStreamInput(), ILexicalScope.STREAM_PACKET_CONTEXT, input);
}
* @param input
* the bitbuffer to read from
* @return an header definition, can be null
- * @throws CTFReaderException
+ * @throws CTFException
* out of bounds exception or such
*/
- public StructDefinition getTracePacketHeaderDefinition(@NonNull BitBuffer input) throws CTFReaderException {
+ public StructDefinition getTracePacketHeaderDefinition(@NonNull BitBuffer input) throws CTFException {
return fTracePacketHeaderDecl.createDefinition(fStreamInputReader.getStreamInput().getStream().getTrace(), ILexicalScope.TRACE_PACKET_HEADER, input);
}
// ------------------------------------------------------------------------
@NonNull
- private ByteBuffer getByteBufferAt(long position, long size) throws CTFReaderException, IOException {
+ private ByteBuffer getByteBufferAt(long position, long size) throws CTFException, IOException {
ByteBuffer map = SafeMappedByteBuffer.map(fStreamInputReader.getFc(), MapMode.READ_ONLY, position, size);
if (map == null) {
- throw new CTFReaderException("Failed to allocate mapped byte buffer"); //$NON-NLS-1$
+ throw new CTFIOException("Failed to allocate mapped byte buffer"); //$NON-NLS-1$
}
return map;
}
*
* @param currentPacket
* The index entry of the packet to switch to.
- * @throws CTFReaderException
+ * @throws CTFException
* If we get an error reading the packet
*/
- void setCurrentPacket(StreamInputPacketIndexEntry currentPacket) throws CTFReaderException {
+ void setCurrentPacket(StreamInputPacketIndexEntry currentPacket) throws CTFException {
StreamInputPacketIndexEntry prevPacket = null;
fCurrentPacket = currentPacket;
try {
bb = getByteBufferAt(fCurrentPacket.getOffsetBytes(), (fCurrentPacket.getPacketSizeBits() + BITS_PER_BYTE - 1) / BITS_PER_BYTE);
} catch (IOException e) {
- throw new CTFReaderException(e.getMessage(), e);
+ throw new CTFIOException(e.getMessage(), e);
}
BitBuffer bitBuffer = new BitBuffer(bb);
*
* @return The event definition containing the event data that was just
* read.
- * @throws CTFReaderException
+ * @throws CTFException
* If there was a problem reading the trace
*/
- public EventDefinition readNextEvent() throws CTFReaderException {
+ public EventDefinition readNextEvent() throws CTFException {
/* Default values for those fields */
// compromise since we cannot have 64 bit addressing of arrays yet.
int eventID = (int) EventDeclaration.UNSET_EVENT_ID;
if (idDef instanceof SimpleDatatypeDefinition) {
simpleIdDef = ((SimpleDatatypeDefinition) idDef);
} else if (idDef != null) {
- throw new CTFReaderException("Id defintion not an integer, enum or float definiton in event header."); //$NON-NLS-1$
+ throw new CTFIOException("Id defintion not an integer, enum or float definiton in event header."); //$NON-NLS-1$
}
/*
/* Get the right event definition using the event id. */
IEventDeclaration eventDeclaration = fStreamInputReader.getStreamInput().getStream().getEventDeclaration(eventID);
if (eventDeclaration == null) {
- throw new CTFReaderException("Incorrect event id : " + eventID); //$NON-NLS-1$
+ throw new CTFIOException("Incorrect event id : " + eventID); //$NON-NLS-1$
}
EventDefinition eventDef = eventDeclaration.createDefinition(fStreamInputReader, currentBitBuffer, timestamp);
*/
if (posStart == currentBitBuffer.position()) {
- throw new CTFReaderException("Empty event not allowed, event: " + eventDef.getDeclaration().getName()); //$NON-NLS-1$
+ throw new CTFIOException("Empty event not allowed, event: " + eventDef.getDeclaration().getName()); //$NON-NLS-1$
}
return eventDef;
import java.nio.file.StandardOpenOption;
import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.tracecompass.ctf.core.CTFReaderException;
+import org.eclipse.tracecompass.ctf.core.CTFException;
import org.eclipse.tracecompass.ctf.core.event.EventDefinition;
import org.eclipse.tracecompass.ctf.core.event.IEventDeclaration;
import org.eclipse.tracecompass.ctf.core.event.types.StructDeclaration;
*
* @param streamInput
* The StreamInput to read.
- * @throws CTFReaderException
+ * @throws CTFException
* If the file cannot be opened
*/
- public CTFStreamInputReader(CTFStreamInput streamInput) throws CTFReaderException {
+ public CTFStreamInputReader(CTFStreamInput streamInput) throws CTFException {
if (streamInput == null) {
throw new IllegalArgumentException("stream cannot be null"); //$NON-NLS-1$
}
try {
fFileChannel = FileChannel.open(fFile.toPath(), StandardOpenOption.READ);
} catch (IOException e) {
- throw new CTFReaderException(e);
+ throw new CTFIOException(e);
}
fPacketReader = new CTFStreamInputPacketReader(this);
/*
* Reads the next event in the current event variable.
*
* @return If an event has been successfully read.
- * @throws CTFReaderException
+ * @throws CTFException
* if an error occurs
*/
- public CTFResponse readNextEvent() throws CTFReaderException {
+ public CTFResponse readNextEvent() throws CTFException {
/*
* Change packet if needed
/**
* Change the current packet of the packet reader to the next one.
*
- * @throws CTFReaderException
+ * @throws CTFException
* if an error occurs
*/
- private void goToNextPacket() throws CTFReaderException {
+ private void goToNextPacket() throws CTFException {
fPacketIndex++;
// did we already index the packet?
if (getPacketSize() >= (fPacketIndex + 1)) {
* @param timestamp
* The timestamp to seek to.
* @return The offset compared to the current position
- * @throws CTFReaderException
+ * @throws CTFException
* if an error occurs
*/
- public long seek(long timestamp) throws CTFReaderException {
+ public long seek(long timestamp) throws CTFException {
long offset = 0;
gotoPacket(timestamp);
try {
fStreamInput.addPacketHeaderIndex();
goToNextPacket();
- } catch (CTFReaderException e) {
+ } catch (CTFException e) {
// do nothing here
Activator.log(e.getMessage());
}
/**
* @param timestamp
* the time to seek
- * @throws CTFReaderException
+ * @throws CTFException
* if an error occurs
*/
- private void gotoPacket(long timestamp) throws CTFReaderException {
+ private void gotoPacket(long timestamp) throws CTFException {
fPacketIndex = fStreamInput.getIndex().search(timestamp)
.previousIndex();
/*
/**
* Seeks the last event of a stream and returns it.
*
- * @throws CTFReaderException
+ * @throws CTFException
* if an error occurs
*/
- public void goToLastEvent() throws CTFReaderException {
+ public void goToLastEvent() throws CTFException {
/*
* Search in the index for the packet to search in.
*/
import java.util.TreeSet;
import java.util.UUID;
-import org.eclipse.tracecompass.ctf.core.CTFReaderException;
+import org.eclipse.tracecompass.ctf.core.CTFException;
import org.eclipse.tracecompass.ctf.core.event.CTFCallsite;
import org.eclipse.tracecompass.ctf.core.event.CTFClock;
import org.eclipse.tracecompass.ctf.core.event.IEventDeclaration;
*
* @param path
* Filesystem path of the trace directory
- * @throws CTFReaderException
+ * @throws CTFException
* If no CTF trace was found at the path
*/
- public CTFTrace(String path) throws CTFReaderException {
+ public CTFTrace(String path) throws CTFException {
this(new File(path));
}
*
* @param path
* Filesystem path of the trace directory.
- * @throws CTFReaderException
+ * @throws CTFException
* If no CTF trace was found at the path
*/
- public CTFTrace(File path) throws CTFReaderException {
+ public CTFTrace(File path) throws CTFException {
fPath = path;
final Metadata metadata = new Metadata(this);
/* Set up the internal containers for this trace */
if (!fPath.exists()) {
- throw new CTFReaderException("Trace (" + path.getPath() + ") doesn't exist. Deleted or moved?"); //$NON-NLS-1$ //$NON-NLS-2$
+ throw new CTFException("Trace (" + path.getPath() + ") doesn't exist. Deleted or moved?"); //$NON-NLS-1$ //$NON-NLS-2$
}
if (!fPath.isDirectory()) {
- throw new CTFReaderException("Path must be a valid directory"); //$NON-NLS-1$
+ throw new CTFException("Path must be a valid directory"); //$NON-NLS-1$
}
/* Open and parse the metadata file */
fPath = null;
}
- private void init(File path) throws CTFReaderException {
+ private void init(File path) throws CTFException {
/* Open all the trace files */
* @param index
* Which index in the class' streamFileChannel array this file
* must use
- * @throws CTFReaderException
+ * @throws CTFException
* if there is a file error
*/
- private CTFStream openStreamInput(File streamFile) throws CTFReaderException {
+ private CTFStream openStreamInput(File streamFile) throws CTFException {
ByteBuffer byteBuffer;
BitBuffer streamBitBuffer;
CTFStream stream;
if (!streamFile.canRead()) {
- throw new CTFReaderException("Unreadable file : " //$NON-NLS-1$
+ throw new CTFException("Unreadable file : " //$NON-NLS-1$
+ streamFile.getPath());
}
}
} catch (IOException e) {
/* Shouldn't happen at this stage if every other check passed */
- throw new CTFReaderException(e);
+ throw new CTFException(e);
}
if (fPacketHeaderDef != null) {
validateMagicNumber(fPacketHeaderDef);
}
if (stream == null) {
- throw new CTFReaderException("Unexpected end of stream"); //$NON-NLS-1$
+ throw new CTFException("Unexpected end of stream"); //$NON-NLS-1$
}
/*
return stream;
}
- private void validateUUID(StructDefinition packetHeaderDef) throws CTFReaderException {
+ private void validateUUID(StructDefinition packetHeaderDef) throws CTFException {
IDefinition lookupDefinition = packetHeaderDef.lookupDefinition("uuid"); //$NON-NLS-1$
ArrayDefinition uuidDef = (ArrayDefinition) lookupDefinition;
if (uuidDef != null) {
UUID otheruuid = Utils.getUUIDfromDefinition(uuidDef);
if (!fUuid.equals(otheruuid)) {
- throw new CTFReaderException("UUID mismatch"); //$NON-NLS-1$
+ throw new CTFException("UUID mismatch"); //$NON-NLS-1$
}
}
}
- private static void validateMagicNumber(StructDefinition packetHeaderDef) throws CTFReaderException {
+ private static void validateMagicNumber(StructDefinition packetHeaderDef) throws CTFException {
IntegerDefinition magicDef = (IntegerDefinition) packetHeaderDef.lookupDefinition("magic"); //$NON-NLS-1$
int magic = (int) magicDef.getValue();
if (magic != Utils.CTF_MAGIC) {
- throw new CTFReaderException("CTF magic mismatch"); //$NON-NLS-1$
+ throw new CTFException("CTF magic mismatch"); //$NON-NLS-1$
}
}
*
* @param streamFile
* the file of the stream
- * @throws CTFReaderException
+ * @throws CTFException
* A stream had an issue being read
*/
- public void addStreamFile(File streamFile) throws CTFReaderException {
+ public void addStreamFile(File streamFile) throws CTFException {
openStreamInput(streamFile);
}
* the ID of the stream
* @param streamFile
* new file in the stream
- * @throws CTFReaderException
+ * @throws CTFException
* The file must exist
*/
- public void addStream(long id, File streamFile) throws CTFReaderException {
+ public void addStream(long id, File streamFile) throws CTFException {
CTFStream stream = null;
final File file = streamFile;
if (file == null) {
- throw new CTFReaderException("cannot create a stream with no file"); //$NON-NLS-1$
+ throw new CTFException("cannot create a stream with no file"); //$NON-NLS-1$
}
if (fStreams.containsKey(id)) {
stream = fStreams.get(id);
import java.util.PriorityQueue;
import java.util.Set;
-import org.eclipse.tracecompass.ctf.core.CTFReaderException;
+import org.eclipse.tracecompass.ctf.core.CTFException;
import org.eclipse.tracecompass.ctf.core.event.EventDefinition;
import org.eclipse.tracecompass.ctf.core.event.IEventDeclaration;
import org.eclipse.tracecompass.internal.ctf.core.Activator;
*
* @param trace
* The trace to read from.
- * @throws CTFReaderException
+ * @throws CTFException
* if an error occurs
*/
- public CTFTraceReader(CTFTrace trace) throws CTFReaderException {
+ public CTFTraceReader(CTFTrace trace) throws CTFException {
fTrace = trace;
fStreamInputReaders.clear();
* Copy constructor
*
* @return The new CTFTraceReader
- * @throws CTFReaderException
+ * @throws CTFException
* if an error occurs
*/
- public CTFTraceReader copyFrom() throws CTFReaderException {
+ public CTFTraceReader copyFrom() throws CTFException {
CTFTraceReader newReader = null;
newReader = new CTFTraceReader(fTrace);
/**
* Creates one trace file reader per trace file contained in the trace.
*
- * @throws CTFReaderException
+ * @throws CTFException
* if an error occurs
*/
- private void createStreamInputReaders() throws CTFReaderException {
+ private void createStreamInputReaders() throws CTFException {
/*
* For each stream.
*/
/**
* Update the priority queue to make it match the parent trace
*
- * @throws CTFReaderException
+ * @throws CTFException
* An error occured
*/
- public void update() throws CTFReaderException {
+ public void update() throws CTFException {
Set<CTFStreamInputReader> readers = new HashSet<>();
for (CTFStream stream : fTrace.getStreams()) {
Set<CTFStreamInput> streamInputs = stream.getStreamInputs();
* Initializes the priority queue used to choose the trace file with the
* lower next event timestamp.
*
- * @throws CTFReaderException
+ * @throws CTFException
* if an error occurs
*/
- private void populateStreamInputReaderHeap() throws CTFReaderException {
+ private void populateStreamInputReaderHeap() throws CTFException {
if (fStreamInputReaders.isEmpty()) {
fPrio = new PriorityQueue<>(MIN_PRIO_SIZE,
new StreamInputReaderTimestampComparator());
* Go to the next event.
*
* @return True if an event was read.
- * @throws CTFReaderException
+ * @throws CTFException
* if an error occurs
*/
- public boolean advance() throws CTFReaderException {
+ public boolean advance() throws CTFException {
/*
* Remove the reader from the top of the priority queue.
*/
/**
* Go to the last event in the trace.
*
- * @throws CTFReaderException
+ * @throws CTFException
* if an error occurs
*/
- public void goToLastEvent() throws CTFReaderException {
+ public void goToLastEvent() throws CTFException {
seek(getEndTime());
while (fPrio.size() > 1) {
advance();
* the timestamp to seek to
* @return true if there are events above or equal the seek timestamp, false
* if seek at the end of the trace (no valid event).
- * @throws CTFReaderException
+ * @throws CTFException
* if an error occurs
*/
- public boolean seek(long timestamp) throws CTFReaderException {
+ public boolean seek(long timestamp) throws CTFException {
/*
* Remove all the trace readers from the priority queue
*/
import org.antlr.runtime.RecognitionException;
import org.antlr.runtime.tree.CommonTree;
import org.antlr.runtime.tree.RewriteCardinalityException;
-import org.eclipse.tracecompass.ctf.core.CTFReaderException;
+import org.eclipse.tracecompass.ctf.core.CTFException;
import org.eclipse.tracecompass.ctf.parser.CTFLexer;
import org.eclipse.tracecompass.ctf.parser.CTFParser;
import org.eclipse.tracecompass.ctf.parser.CTFParser.parse_return;
/**
* Parse the metadata file.
*
- * @throws CTFReaderException
+ * @throws CTFException
* If there was a problem parsing the metadata
*/
- public void parseFile() throws CTFReaderException {
+ public void parseFile() throws CTFException {
/*
* Reader. It will contain a StringReader if we are using packet-based
readMetaDataText(metadataTextInput);
} catch (FileNotFoundException e) {
- throw new CTFReaderException("Cannot find metadata file!", e); //$NON-NLS-1$
+ throw new CTFException("Cannot find metadata file!", e); //$NON-NLS-1$
} catch (IOException | ParseException e) {
- throw new CTFReaderException(e);
+ throw new CTFException(e);
} catch (RecognitionException | RewriteCardinalityException e) {
throw new CtfAntlrException(e);
}
}
- private Reader readBinaryMetaData(FileChannel metadataFileChannel) throws CTFReaderException {
+ private Reader readBinaryMetaData(FileChannel metadataFileChannel) throws CTFException {
/* Create StringBuffer to receive metadata text */
StringBuffer metadataText = new StringBuffer();
*
* @param data
* the data to read
- * @throws CTFReaderException
+ * @throws CTFException
* this exception wraps a ParseException, IOException or
* CtfAntlrException, three exceptions that can be obtained from
* parsing a TSDL file
*/
- public void parseText(String data) throws CTFReaderException {
+ public void parseText(String data) throws CTFException {
Reader metadataTextInput = new StringReader(data);
try {
readMetaDataText(metadataTextInput);
} catch (IOException | ParseException e) {
- throw new CTFReaderException(e);
+ throw new CTFException(e);
} catch (RecognitionException | RewriteCardinalityException e) {
throw new CtfAntlrException(e);
}
*
* @param dataFragment
* the data to read
- * @throws CTFReaderException
+ * @throws CTFException
* this exception wraps a ParseException, IOException or
* CtfAntlrException, three exceptions that can be obtained from
* parsing a TSDL file
*/
- public void parseTextFragment(String dataFragment) throws CTFReaderException {
+ public void parseTextFragment(String dataFragment) throws CTFException {
Reader metadataTextInput = new StringReader(dataFragment);
try {
readMetaDataTextFragment(metadataTextInput);
} catch (IOException | ParseException e) {
- throw new CTFReaderException(e);
+ throw new CTFException(e);
} catch (RecognitionException | RewriteCardinalityException e) {
throw new CtfAntlrException(e);
}
* @param metadataFileChannel
* FileChannel of the metadata file.
* @return True if the metadata is packet-based.
- * @throws CTFReaderException
+ * @throws CTFException
*/
private boolean isPacketBased(FileChannel metadataFileChannel)
- throws CTFReaderException {
+ throws CTFException {
/*
* Create a ByteBuffer to read the TSDL magic number (default is
* big-endian)
try {
metadataFileChannel.read(magicByteBuffer, 0);
} catch (IOException e) {
- throw new CTFReaderException("Unable to read metadata file channel.", e); //$NON-NLS-1$
+ throw new CTFException("Unable to read metadata file channel.", e); //$NON-NLS-1$
}
/* Get the first int from the file */
* StringBuffer to which the metadata text will be appended.
* @return A structure describing the header of the metadata packet, or null
* if the end of the file is reached.
- * @throws CTFReaderException
+ * @throws CTFException
*/
private MetadataPacketHeader readMetadataPacket(
FileChannel metadataFileChannel, StringBuffer metadataText)
- throws CTFReaderException {
+ throws CTFException {
/* Allocate a ByteBuffer for the header */
ByteBuffer headerByteBuffer = ByteBuffer.allocate(METADATA_PACKET_HEADER_SIZE);
}
if (nbBytesRead != METADATA_PACKET_HEADER_SIZE) {
- throw new CTFReaderException("Error reading the metadata header."); //$NON-NLS-1$
+ throw new CTFException("Error reading the metadata header."); //$NON-NLS-1$
}
} catch (IOException e) {
- throw new CTFReaderException("Error reading the metadata header.", e); //$NON-NLS-1$
+ throw new CTFException("Error reading the metadata header.", e); //$NON-NLS-1$
}
/* Set ByteBuffer's position to 0 */
/* Check TSDL magic number */
if (!header.isMagicValid()) {
- throw new CTFReaderException("TSDL magic number does not match"); //$NON-NLS-1$
+ throw new CTFException("TSDL magic number does not match"); //$NON-NLS-1$
}
/* Check UUID */
if (!trace.uuidIsSet()) {
trace.setUUID(header.getUuid());
} else if (!trace.getUUID().equals(header.getUuid())) {
- throw new CTFReaderException("UUID mismatch"); //$NON-NLS-1$
+ throw new CTFException("UUID mismatch"); //$NON-NLS-1$
}
/* Extract the text from the packet */
int payloadSize = ((header.getContentSize() / BITS_PER_BYTE) - METADATA_PACKET_HEADER_SIZE);
if (payloadSize < 0) {
- throw new CTFReaderException("Invalid metadata packet payload size."); //$NON-NLS-1$
+ throw new CTFException("Invalid metadata packet payload size."); //$NON-NLS-1$
}
int skipSize = (header.getPacketSize() - header.getContentSize()) / BITS_PER_BYTE;
try {
metadataFileChannel.read(payloadByteBuffer);
} catch (IOException e) {
- throw new CTFReaderException("Error reading metadata packet payload.", e); //$NON-NLS-1$
+ throw new CTFException("Error reading metadata packet payload.", e); //$NON-NLS-1$
}
payloadByteBuffer.rewind();
import java.util.UUID;
-import org.eclipse.tracecompass.ctf.core.CTFReaderException;
+import org.eclipse.tracecompass.ctf.core.CTFException;
import org.eclipse.tracecompass.ctf.core.event.types.AbstractArrayDefinition;
import org.eclipse.tracecompass.ctf.core.event.types.CompoundDeclaration;
import org.eclipse.tracecompass.ctf.core.event.types.IDeclaration;
* @param uuidDef
* the array defintions, must contain integer bytes
* @return the UUID
- * @throws CTFReaderException
+ * @throws CTFException
* if the definition contains less than 16 elements
*/
- public static UUID getUUIDfromDefinition(AbstractArrayDefinition uuidDef) throws CTFReaderException {
+ public static UUID getUUIDfromDefinition(AbstractArrayDefinition uuidDef) throws CTFException {
byte[] uuidArray = new byte[UUID_LEN];
IDeclaration declaration = uuidDef.getDeclaration();
if (!(declaration instanceof CompoundDeclaration)) {
- throw new CTFReaderException("UUID must be a sequence of unsigned bytes"); //$NON-NLS-1$
+ throw new CTFException("UUID must be a sequence of unsigned bytes"); //$NON-NLS-1$
}
CompoundDeclaration uuidDec = (CompoundDeclaration) declaration;
IDeclaration uuidElem = uuidDec.getElementType();
if (!(uuidElem instanceof IntegerDeclaration)) {
- throw new CTFReaderException("UUID must be a sequence of unsigned bytes"); //$NON-NLS-1$
+ throw new CTFException("UUID must be a sequence of unsigned bytes"); //$NON-NLS-1$
}
IntegerDeclaration intUuidElem = (IntegerDeclaration) uuidElem;
if (!intUuidElem.isUnsignedByte()) {
- throw new CTFReaderException("UUID must be a sequence of unsigned bytes"); //$NON-NLS-1$
+ throw new CTFException("UUID must be a sequence of unsigned bytes"); //$NON-NLS-1$
}
return getUUID(uuidDef, uuidArray);
}
- private static UUID getUUID(AbstractArrayDefinition uuidDef, byte[] uuidArray) throws CTFReaderException {
+ private static UUID getUUID(AbstractArrayDefinition uuidDef, byte[] uuidArray) throws CTFException {
for (int i = 0; i < uuidArray.length; i++) {
IntegerDefinition uuidByteDef = (IntegerDefinition) uuidDef.getDefinitions().get(i);
if (uuidByteDef == null) {
- throw new CTFReaderException("UUID incomplete, only " + i + " bytes available"); //$NON-NLS-1$ //$NON-NLS-2$
+ throw new CTFException("UUID incomplete, only " + i + " bytes available"); //$NON-NLS-1$ //$NON-NLS-2$
}
uuidArray[i] = (byte) uuidByteDef.getValue();
}
import java.util.Set;
import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.tracecompass.ctf.core.CTFReaderException;
+import org.eclipse.tracecompass.ctf.core.CTFException;
import org.eclipse.tracecompass.ctf.core.CTFStrings;
import org.eclipse.tracecompass.ctf.core.event.EventDefinition;
import org.eclipse.tracecompass.ctf.core.event.IEventDeclaration;
}
@Override
- public EventDefinition createDefinition(CTFStreamInputReader streamInputReader, @NonNull BitBuffer input, long timestamp) throws CTFReaderException {
+ public EventDefinition createDefinition(CTFStreamInputReader streamInputReader, @NonNull BitBuffer input, long timestamp) throws CTFException {
StructDeclaration streamEventContextDecl = streamInputReader.getStreamEventContextDecl();
StructDefinition streamEventContext = streamEventContextDecl != null ? streamEventContextDecl.createDefinition(fStream.getTrace(), ILexicalScope.STREAM_EVENT_CONTEXT, input) : null;
StructDefinition packetContext = streamInputReader.getPacketReader().getCurrentPacketEventHeader();
import org.antlr.runtime.MismatchedTokenException;
import org.antlr.runtime.RecognitionException;
-import org.eclipse.tracecompass.ctf.core.CTFReaderException;
+import org.eclipse.tracecompass.ctf.core.CTFException;
import org.eclipse.tracecompass.ctf.parser.CTFLexer;
/**
* CTF Reader exception but dealing with Antlr-specific parsing problems.
*
- * It is separated from the main {@link CTFReaderException} - and is not part of
+ * It is separated from the main {@link CTFException} - and is not part of
* the API - to isolate the Antlr-specific classes and avoid pushing that
* dependency to the users of this plugin.
*
* @author Matthew Khouzam
*/
-public class CtfAntlrException extends CTFReaderException {
+public class CtfAntlrException extends CTFException {
private static final long serialVersionUID = -7078624493350073777L;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
-import org.eclipse.tracecompass.ctf.core.CTFReaderException;
+import org.eclipse.tracecompass.ctf.core.CTFException;
import org.eclipse.tracecompass.ctf.core.event.io.BitBuffer;
import org.eclipse.tracecompass.ctf.core.event.scope.IDefinitionScope;
import org.eclipse.tracecompass.ctf.core.event.types.AbstractArrayDefinition;
@Override
public AbstractArrayDefinition createDefinition(@Nullable IDefinitionScope definitionScope,
- @NonNull String fieldName, BitBuffer input) throws CTFReaderException {
+ @NonNull String fieldName, BitBuffer input) throws CTFException {
alignRead(input);
if (isString()) {
byte[] data = new byte[fLength];
return "[declaration] array[" + Integer.toHexString(hashCode()) + ']'; //$NON-NLS-1$
}
- private @NonNull List<Definition> read(@NonNull BitBuffer input, @Nullable IDefinitionScope definitionScope, String fieldName) throws CTFReaderException {
+ private @NonNull List<Definition> read(@NonNull BitBuffer input, @Nullable IDefinitionScope definitionScope, String fieldName) throws CTFException {
Builder<Definition> definitions = new ImmutableList.Builder<>();
if (!fChildrenNames.containsKey(fieldName)) {
for (int i = 0; i < fLength; i++) {
import java.util.List;
import org.eclipse.jdt.annotation.Nullable;
-import org.eclipse.tracecompass.ctf.core.CTFReaderException;
+import org.eclipse.tracecompass.ctf.core.CTFException;
import org.eclipse.tracecompass.ctf.core.event.io.BitBuffer;
import org.eclipse.tracecompass.ctf.core.event.scope.IDefinitionScope;
import org.eclipse.tracecompass.ctf.core.event.types.AbstractArrayDefinition;
@Override
public AbstractArrayDefinition createDefinition(
- @Nullable IDefinitionScope definitionScope, String fieldName, BitBuffer input) throws CTFReaderException {
+ @Nullable IDefinitionScope definitionScope, String fieldName, BitBuffer input) throws CTFException {
IDefinition lenDef = null;
if (definitionScope != null) {
}
if (lenDef == null) {
- throw new CTFReaderException("Sequence length field not found"); //$NON-NLS-1$
+ throw new CTFException("Sequence length field not found"); //$NON-NLS-1$
}
if (!(lenDef instanceof IntegerDefinition)) {
- throw new CTFReaderException("Sequence length field not integer"); //$NON-NLS-1$
+ throw new CTFException("Sequence length field not integer"); //$NON-NLS-1$
}
IntegerDefinition lengthDefinition = (IntegerDefinition) lenDef;
if (lengthDefinition.getDeclaration().isSigned()) {
- throw new CTFReaderException("Sequence length must not be signed"); //$NON-NLS-1$
+ throw new CTFException("Sequence length must not be signed"); //$NON-NLS-1$
}
long length = lengthDefinition.getValue();
if ((length > Integer.MAX_VALUE) || (!input.canRead((int) length * fElemType.getMaximumSize()))) {
- throw new CTFReaderException("Sequence length too long " + length); //$NON-NLS-1$
+ throw new CTFException("Sequence length too long " + length); //$NON-NLS-1$
}
if (isString()) {
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
-import org.eclipse.tracecompass.ctf.core.CTFReaderException;
+import org.eclipse.tracecompass.ctf.core.CTFException;
import org.eclipse.tracecompass.ctf.core.event.io.BitBuffer;
import org.eclipse.tracecompass.ctf.core.event.scope.IDefinitionScope;
import org.eclipse.tracecompass.ctf.core.event.types.Declaration;
}
@Override
- public EventHeaderDefinition createDefinition(@Nullable IDefinitionScope definitionScope, String fieldName, BitBuffer input) throws CTFReaderException {
+ public EventHeaderDefinition createDefinition(@Nullable IDefinitionScope definitionScope, String fieldName, BitBuffer input) throws CTFException {
alignRead(input);
ByteOrder bo = input.getByteOrder();
input.setByteOrder(fByteOrder);
input.position(input.position() + 3);
long id = input.get(ID_SIZE, false);
if (id > Integer.MAX_VALUE) {
- throw new CTFReaderException("ID " + id + " larger than " + Integer.MAX_VALUE + " is currently unsupported by the parser"); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
+ throw new CTFException("ID " + id + " larger than " + Integer.MAX_VALUE + " is currently unsupported by the parser"); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
}
long timestampLong = input.get(FULL_TS, false);
input.setByteOrder(bo);
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
-import org.eclipse.tracecompass.ctf.core.CTFReaderException;
+import org.eclipse.tracecompass.ctf.core.CTFException;
import org.eclipse.tracecompass.ctf.core.event.io.BitBuffer;
import org.eclipse.tracecompass.ctf.core.event.scope.IDefinitionScope;
import org.eclipse.tracecompass.ctf.core.event.types.Declaration;
}
@Override
- public EventHeaderDefinition createDefinition(@Nullable IDefinitionScope definitionScope, String fieldName, BitBuffer input) throws CTFReaderException {
+ public EventHeaderDefinition createDefinition(@Nullable IDefinitionScope definitionScope, String fieldName, BitBuffer input) throws CTFException {
alignRead(input);
ByteOrder bo = input.getByteOrder();
input.setByteOrder(fByteOrder);
long timestampLong = input.get(FULL_TS, false);
input.setByteOrder(bo);
if (second > Integer.MAX_VALUE) {
- throw new CTFReaderException("ID " + second + " larger than " + Integer.MAX_VALUE + " is currently unsupported by the parser"); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
+ throw new CTFException("ID " + second + " larger than " + Integer.MAX_VALUE + " is currently unsupported by the parser"); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
}
return new EventHeaderDefinition(this, (int) second, timestampLong, FULL_TS);
}
import java.util.TreeSet;
import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.tracecompass.ctf.core.CTFReaderException;
+import org.eclipse.tracecompass.ctf.core.CTFException;
/**
* <b><u>StreamInputPacketIndex</u></b>
* @param preParsedIndex
* the pre-parsed index file
*
- * @throws CTFReaderException
+ * @throws CTFException
* If there was a problem reading the entry
*/
public void appendAll(Collection<StreamInputPacketIndexEntry> preParsedIndex)
- throws CTFReaderException {
+ throws CTFException {
for (StreamInputPacketIndexEntry sipie : preParsedIndex) {
append(checkNotNull(sipie));
}
* @param entry
* element to be appended to this index, cannot be null
* @return {@code true} (as specified by {@link Collection#add})
- * @throws CTFReaderException
+ * @throws CTFException
* If there was a problem reading the entry
*/
public boolean append(@NonNull StreamInputPacketIndexEntry entry)
- throws CTFReaderException {
+ throws CTFException {
/* Validate consistent entry. */
if (entry.getTimestampBegin() > entry.getTimestampEnd()) {
- throw new CTFReaderException("Packet begin timestamp is after end timestamp"); //$NON-NLS-1$
+ throw new CTFException("Packet begin timestamp is after end timestamp"); //$NON-NLS-1$
}
/*
* order.
*/
if (!fEntries.isEmpty() && (entry.getTimestampBegin() < lastElement().getTimestampBegin())) {
- throw new CTFReaderException("Packets begin timestamp decreasing"); //$NON-NLS-1$
+ throw new CTFException("Packets begin timestamp decreasing"); //$NON-NLS-1$
}
fEntries.add(entry);
import java.nio.ByteOrder;
import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.tracecompass.ctf.core.CTFReaderException;
+import org.eclipse.tracecompass.ctf.core.CTFException;
import org.eclipse.tracecompass.ctf.core.event.io.BitBuffer;
import org.eclipse.tracecompass.ctf.core.event.types.Encoding;
import org.eclipse.tracecompass.ctf.core.event.types.EnumDeclaration;
*
* @throws UnsupportedEncodingException
* Thrown when UTF-8 encoding is not available.
- * @throws CTFReaderException
+ * @throws CTFException
* error
*/
@Before
- public void setUp() throws UnsupportedEncodingException, CTFReaderException {
+ public void setUp() throws UnsupportedEncodingException, CTFException {
final byte[] testStringBytes = TEST_STRING.getBytes("UTF-8");
int capacity = 2048;
import static org.eclipse.tracecompass.common.core.NonNullUtils.equalsNullable;
-import org.eclipse.tracecompass.ctf.core.CTFReaderException;
+import org.eclipse.tracecompass.ctf.core.CTFException;
import org.eclipse.tracecompass.ctf.core.trace.CTFStreamInputReader;
import org.eclipse.tracecompass.ctf.core.trace.CTFTrace;
import org.eclipse.tracecompass.ctf.core.trace.CTFTraceReader;
*
* @param ctfTmfTrace
* The {@link CtfTmfTrace} to iterate over
- * @throws CTFReaderException
+ * @throws CTFException
* If the iterator couldn't not be instantiated, probably due to
* a read error.
*/
- public CtfIterator(CTFTrace ctfTrace, CtfTmfTrace ctfTmfTrace) throws CTFReaderException {
+ public CtfIterator(CTFTrace ctfTrace, CtfTmfTrace ctfTmfTrace) throws CTFException {
super(ctfTrace);
fTrace = ctfTmfTrace;
if (hasMoreEvents()) {
* The initial timestamp the iterator will be pointing to
* @param rank
* The initial rank
- * @throws CTFReaderException
+ * @throws CTFException
* If the iterator couldn't not be instantiated, probably due to
* a read error.
*/
public CtfIterator(CTFTrace ctfTrace, CtfTmfTrace ctfTmfTrace, CtfLocationInfo ctfLocationData, long rank)
- throws CTFReaderException {
+ throws CTFException {
super(ctfTrace);
this.fTrace = ctfTmfTrace;
} else {
ret = super.seek(offsetTimestamp);
}
- } catch (CTFReaderException e) {
+ } catch (CTFException e) {
Activator.getDefault().logError(e.getMessage(), e);
return false;
}
boolean ret = false;
try {
ret = super.advance();
- } catch (CTFReaderException e) {
+ } catch (CTFException e) {
Activator.getDefault().logError(e.getMessage(), e);
}
import org.eclipse.core.runtime.Status;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
-import org.eclipse.tracecompass.ctf.core.CTFReaderException;
+import org.eclipse.tracecompass.ctf.core.CTFException;
import org.eclipse.tracecompass.ctf.core.event.CTFCallsite;
import org.eclipse.tracecompass.ctf.core.event.CTFClock;
import org.eclipse.tracecompass.ctf.core.event.IEventDeclaration;
}
}
}
- } catch (final CTFReaderException e) {
+ } catch (final CTFException e) {
/*
* If it failed at the init(), we can assume it's because the file
* was not found or was not recognized as a CTF trace. Throw into
}
}
return new CtfTraceValidationStatus(CONFIDENCE, Activator.PLUGIN_ID, trace.getEnvironment());
- } catch (final CTFReaderException e) {
+ } catch (final CTFException e) {
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.CtfTmfTrace_ReadingError + ": " + e.toString()); //$NON-NLS-1$
} catch (final BufferOverflowException e) {
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.CtfTmfTrace_ReadingError + ": " + Messages.CtfTmfTrace_BufferOverflowErrorMessage); //$NON-NLS-1$
public ITmfContext createIterator() {
try {
return new CtfIterator(fTrace, this);
- } catch (CTFReaderException e) {
+ } catch (CTFException e) {
Activator.getDefault().logError(e.getMessage(), e);
}
return null;
public ITmfContext createIterator(CtfLocationInfo ctfLocationData, long rank) {
try {
return new CtfIterator(fTrace, this, ctfLocationData, rank);
- } catch (CTFReaderException e) {
+ } catch (CTFException e) {
Activator.getDefault().logError(e.getMessage(), e);
}
return null;