summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
9ef463a)
Change-Id: I8b717fca910b67e1a3150dba5010ca8d062fa5e9
Signed-off-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Signed-off-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/44609
Reviewed-by: Hudson CI
- Long contentSize = (Long) fAttributes.get(CTFStrings.CONTENT_SIZE);
- Long packetSize = (Long) fAttributes.get(CTFStrings.PACKET_SIZE);
- Long tsBegin = (Long) fAttributes.get(CTFStrings.TIMESTAMP_BEGIN);
- Long tsEnd = (Long) fAttributes.get(CTFStrings.TIMESTAMP_END);
- boolean hasDevice = fAttributes.containsKey(CTFStrings.DEVICE);
+ fContentSizeBits = computeContentSize(fileSizeBytes);
+ fPacketSizeBits = computePacketSize(fileSizeBytes);
+ fTimestampBegin = computeTsBegin();
+ fTimestampEnd = computeTsEnd();
+ fOffsetBits = dataOffsetBits;
+ fOffsetBytes = dataOffsetBits / Byte.SIZE;
+
- Long cpuId = (Long) fAttributes.get(CTFStrings.CPU_ID);
- Long lostEvents = (Long) fAttributes.get(CTFStrings.EVENTS_DISCARDED);
+ Target target = lookupTarget(streamPacketContextDef);
+ fTarget = target.string;
+ fTargetID = target.number;
+ fLostEvents = computeLostEvents(lostSoFar);
+ }
+
+ private Long getPacketSize() {
+ return (Long) fAttributes.get(CTFStrings.PACKET_SIZE);
+ }
+ private long computeContentSize(long fileSizeBytes) {
+ Long contentSize = (Long) fAttributes.get(CTFStrings.CONTENT_SIZE);
/* Read the content size in bits */
if (contentSize != null) {
/* Read the content size in bits */
if (contentSize != null) {
- fContentSizeBits = (contentSize.longValue());
- } else if (packetSize != null) {
- fContentSizeBits = (packetSize.longValue());
- } else {
- fContentSizeBits = (fileSizeBytes * Byte.SIZE);
+ return contentSize.longValue();
+ Long packetSize = getPacketSize();
+ if (packetSize != null) {
+ return packetSize.longValue();
+ }
+ return fileSizeBytes * Byte.SIZE;
+ }
+ private long computePacketSize(long fileSizeBytes) {
+ Long packetSize = getPacketSize();
/* Read the packet size in bits */
if (packetSize != null) {
/* Read the packet size in bits */
if (packetSize != null) {
- fPacketSizeBits = (packetSize.longValue());
- } else if (this.getContentSizeBits() != 0) {
- fPacketSizeBits = fContentSizeBits;
- } else {
- fPacketSizeBits = (fileSizeBytes * Byte.SIZE);
+ return packetSize.longValue();
+ long contentSizeBits = computeContentSize(fileSizeBytes);
+ if (contentSizeBits != 0) {
+ return contentSizeBits;
+ }
+ return fileSizeBytes * Byte.SIZE;
+ }
+ private long computeTsBegin() {
+ Long tsBegin = (Long) fAttributes.get(CTFStrings.TIMESTAMP_BEGIN);
/* Read the begin timestamp */
if (tsBegin != null) {
/* Read the begin timestamp */
if (tsBegin != null) {
- fTimestampBegin = (tsBegin.longValue());
- } else {
- fTimestampBegin = 0;
+ return tsBegin.longValue();
+ private long computeTsEnd() {
+ Long tsEnd = (Long) fAttributes.get(CTFStrings.TIMESTAMP_END);
/* Read the end timestamp */
if (tsEnd != null) {
// check if tsEnd == unsigned long max value
if (tsEnd == -1) {
/* Read the end timestamp */
if (tsEnd != null) {
// check if tsEnd == unsigned long max value
if (tsEnd == -1) {
- tsEnd = Long.MAX_VALUE;
- fTimestampEnd = (tsEnd.longValue());
- } else {
- fTimestampEnd = Long.MAX_VALUE;
+ return tsEnd.longValue();
+ return Long.MAX_VALUE;
+ }
- Target target = lookupTarget(streamPacketContextDef, hasDevice, cpuId);
- fTarget = target.string;
- fTargetID = target.number;
-
+ private long computeLostEvents(long lostSoFar) {
+ Long lostEvents = (Long) fAttributes.get(CTFStrings.EVENTS_DISCARDED);
if (lostEvents != null) {
if (lostEvents != null) {
- fLostEvents = (lostEvents - lostSoFar);
- } else {
- fLostEvents = 0;
+ return lostEvents - lostSoFar;
-
- fOffsetBits = dataOffsetBits;
- fOffsetBytes = dataOffsetBits / Byte.SIZE;
}
private static class Target {
}
private static class Target {
- private static Target lookupTarget(StructDefinition streamPacketContextDef, boolean hasDevice, Long cpuId) {
+ private Target lookupTarget(StructDefinition streamPacketContextDef) {
Target ret = new Target();
Target ret = new Target();
+ boolean hasDevice = fAttributes.containsKey(CTFStrings.DEVICE);
if (hasDevice) {
IDefinition def = streamPacketContextDef.lookupDefinition(CTFStrings.DEVICE);
if (def instanceof SimpleDatatypeDefinition) {
if (hasDevice) {
IDefinition def = streamPacketContextDef.lookupDefinition(CTFStrings.DEVICE);
if (def instanceof SimpleDatatypeDefinition) {
ret.number = Integer.parseInt(number);
}
}
ret.number = Integer.parseInt(number);
}
}
- } else if (cpuId != null) {
- ret.string = ("CPU" + cpuId.toString()); //$NON-NLS-1$
- ret.number = cpuId;
+ } else {
+ Long cpuId = (Long) fAttributes.get(CTFStrings.CPU_ID);
+ if (cpuId != null) {
+ ret.string = ("CPU" + cpuId.toString()); //$NON-NLS-1$
+ ret.number = cpuId;
+ }