summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorSimon Marchi2013-10-10 14:00:58 (EDT)
committer Matthew Khouzam2013-10-17 14:29:34 (EDT)
commit9e91367a7f265278d60dbaf9cb7763a502c7bb66 (patch)
tree943f48051122a66cf37523e7cabab1c355d603f7
parent10e3bfbc3f5b3b4feb2bcbbc1e84cffbd4f128c7 (diff)
downloadorg.eclipse.linuxtools-9e91367a7f265278d60dbaf9cb7763a502c7bb66.zip
org.eclipse.linuxtools-9e91367a7f265278d60dbaf9cb7763a502c7bb66.tar.gz
org.eclipse.linuxtools-9e91367a7f265278d60dbaf9cb7763a502c7bb66.tar.bz2
Change from int to long for values that represent sizes in bitrefs/changes/22/17422/2
This fixes parsing of traces with big packets, whose size in bits overflow an 32-bit int. Change-Id: I5d2d1ede73e638bdd2a3e5b38a5ee2a053fa5d3a Signed-off-by: Simon Marchi <simon.marchi@polymtl.ca> Reviewed-on: https://git.eclipse.org/r/17422 Reviewed-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im> Tested-by: Hudson CI Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com> IP-Clean: Matthew Khouzam <matthew.khouzam@ericsson.com> Tested-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/io/BitBufferTest.java2
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/io/BitBuffer.java70
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/EnumDefinition.java2
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/IntegerDefinition.java2
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/StructDefinition.java2
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/StreamInput.java4
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/trace/StreamInputPacketIndexEntry.java18
7 files changed, 50 insertions, 50 deletions
diff --git a/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/io/BitBufferTest.java b/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/io/BitBufferTest.java
index b13dfd1..90f1fdb 100644
--- a/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/io/BitBufferTest.java
+++ b/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/io/BitBufferTest.java
@@ -143,7 +143,7 @@ public class BitBufferTest {
*/
@Test
public void testGetPosition() {
- int result = fixture.position();
+ long result = fixture.position();
assertEquals(1, result);
}
diff --git a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/io/BitBuffer.java b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/io/BitBuffer.java
index 07df164..1b75d93 100644
--- a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/io/BitBuffer.java
+++ b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/io/BitBuffer.java
@@ -46,7 +46,7 @@ public final class BitBuffer {
// ------------------------------------------------------------------------
private ByteBuffer buf;
- private int pos;
+ private long pos;
private ByteOrder byteOrder;
// ------------------------------------------------------------------------
@@ -128,9 +128,9 @@ public final class BitBuffer {
case BitBuffer.BIT_CHAR:
// Byte
if (signed) {
- val = this.buf.get(this.pos / 8);
+ val = this.buf.get((int) (this.pos / 8));
} else {
- val = (this.buf.get(this.pos / 8)) & 0xff;
+ val = (this.buf.get((int) (this.pos / 8))) & 0xff;
}
gotIt = true;
break;
@@ -138,9 +138,9 @@ public final class BitBuffer {
case BitBuffer.BIT_SHORT:
// Word
if (signed) {
- val = this.buf.getShort(this.pos / 8);
+ val = this.buf.getShort((int) (this.pos / 8));
} else {
- short a = this.buf.getShort(this.pos / 8);
+ short a = this.buf.getShort((int) (this.pos / 8));
val = a & 0xffff;
}
gotIt = true;
@@ -148,7 +148,7 @@ public final class BitBuffer {
case BitBuffer.BIT_INT:
// Double word
- val = this.buf.getInt(this.pos / 8);
+ val = this.buf.getInt((int) (this.pos / 8));
gotIt = true;
break;
@@ -169,11 +169,11 @@ public final class BitBuffer {
return val;
}
- private int getIntBE(int index, int length, boolean signed) {
+ private int getIntBE(long index, int length, boolean signed) {
assert ((length > 0) && (length <= BIT_INT));
- int end = index + length;
- int startByte = index / BIT_CHAR;
- int endByte = (end + (BIT_CHAR - 1)) / BIT_CHAR;
+ long end = index + length;
+ int startByte = (int) (index / BIT_CHAR);
+ int endByte = (int) ((end + (BIT_CHAR - 1)) / BIT_CHAR);
int currByte, lshift, cshift, mask, cmask, cache;
int value = 0;
@@ -193,7 +193,7 @@ public final class BitBuffer {
value |= cmask;
return value;
}
- cshift = index % BIT_CHAR;
+ cshift = (int) (index % BIT_CHAR);
if (cshift > 0) {
mask = ~((~0) << (BIT_CHAR - cshift));
cmask = cache & mask;
@@ -206,7 +206,7 @@ public final class BitBuffer {
value <<= BIT_CHAR;
value |= this.buf.get(currByte) & 0xFF;
}
- lshift = end % BIT_CHAR;
+ lshift = (int) (end % BIT_CHAR);
if (lshift > 0) {
mask = ~((~0) << lshift);
cmask = this.buf.get(currByte) & 0xFF;
@@ -221,17 +221,17 @@ public final class BitBuffer {
return value;
}
- private int getIntLE(int index, int length, boolean signed) {
+ private int getIntLE(long index, int length, boolean signed) {
assert ((length > 0) && (length <= BIT_INT));
- int end = index + length;
- int startByte = index / BIT_CHAR;
- int endByte = (end + (BIT_CHAR - 1)) / BIT_CHAR;
+ long end = index + length;
+ int startByte = (int) (index / BIT_CHAR);
+ int endByte = (int) ((end + (BIT_CHAR - 1)) / BIT_CHAR);
int currByte, lshift, cshift, mask, cmask, cache, mod;
int value = 0;
currByte = endByte - 1;
cache = buf.get(currByte) & 0xFF;
- mod = end % BIT_CHAR;
+ mod = (int) (end % BIT_CHAR);
lshift = (mod > 0) ? mod : BIT_CHAR;
boolean isNeg = (cache & (1 << (lshift - 1))) != 0;
if (signed && isNeg) {
@@ -247,7 +247,7 @@ public final class BitBuffer {
value |= cmask;
return value;
}
- cshift = end % BIT_CHAR;
+ cshift = (int) (end % BIT_CHAR);
if (cshift > 0) {
mask = ~((~0) << cshift);
cmask = cache & mask;
@@ -259,7 +259,7 @@ public final class BitBuffer {
value <<= BIT_CHAR;
value |= buf.get(currByte) & 0xFF;
}
- lshift = index % BIT_CHAR;
+ lshift = (int) (index % BIT_CHAR);
if (lshift > 0) {
mask = ~((~0) << (BIT_CHAR - lshift));
cmask = buf.get(currByte) & 0xFF;
@@ -307,7 +307,7 @@ public final class BitBuffer {
* The value to write
*/
public void putInt(int length, int value) {
- final int curPos = this.pos;
+ final long curPos = this.pos;
if (!canRead(length)) {
throw new BufferOverflowException();
@@ -323,11 +323,11 @@ public final class BitBuffer {
this.pos += length;
}
- private void putIntBE(int index, int length, int value) {
+ private void putIntBE(long index, int length, int value) {
assert ((length > 0) && (length <= BIT_INT));
- int end = index + length;
- int startByte = index / BIT_CHAR;
- int endByte = (end + (BIT_CHAR - 1)) / BIT_CHAR;
+ long end = index + length;
+ int startByte = (int) (index / BIT_CHAR);
+ int endByte = (int) ((end + (BIT_CHAR - 1)) / BIT_CHAR);
int currByte, lshift, cshift, mask, cmask;
int correctedValue = value;
@@ -342,7 +342,7 @@ public final class BitBuffer {
/* sub byte */
if (startByte == (endByte - 1)) {
- lshift = (BIT_CHAR - (end % BIT_CHAR)) % BIT_CHAR;
+ lshift = (int) ((BIT_CHAR - (end % BIT_CHAR)) % BIT_CHAR);
mask = ~((~0) << lshift);
if ((index % BIT_CHAR) > 0) {
mask |= (~(0)) << (BIT_CHAR - (index % BIT_CHAR));
@@ -360,7 +360,7 @@ public final class BitBuffer {
/* head byte contains MSB */
currByte = endByte - 1;
- cshift = end % BIT_CHAR;
+ cshift = (int) (end % BIT_CHAR);
if (cshift > 0) {
lshift = BIT_CHAR - cshift;
mask = ~((~0) << lshift);
@@ -388,11 +388,11 @@ public final class BitBuffer {
}
}
- private void putIntLE(int index, int length, int value) {
+ private void putIntLE(long index, int length, int value) {
assert ((length > 0) && (length <= BIT_INT));
- int end = index + length;
- int startByte = index / BIT_CHAR;
- int endByte = (end + (BIT_CHAR - 1)) / BIT_CHAR;
+ long end = index + length;
+ int startByte = (int) (index / BIT_CHAR);
+ int endByte = (int) ((end + (BIT_CHAR - 1)) / BIT_CHAR);
int currByte, lshift, cshift, mask, cmask;
int correctedValue = value;
@@ -407,7 +407,7 @@ public final class BitBuffer {
/* sub byte */
if (startByte == (endByte - 1)) {
- lshift = index % BIT_CHAR;
+ lshift = (int) (index % BIT_CHAR);
mask = ~((~0) << lshift);
if ((end % BIT_CHAR) > 0) {
mask |= (~(0)) << (end % BIT_CHAR);
@@ -425,7 +425,7 @@ public final class BitBuffer {
/* head byte */
currByte = startByte;
- cshift = index % BIT_CHAR;
+ cshift = (int) (index % BIT_CHAR);
if (cshift > 0) {
mask = ~((~0) << cshift);
cmask = correctedValue << cshift;
@@ -468,7 +468,7 @@ public final class BitBuffer {
return false;
}
- if ((this.pos + length) > (this.buf.capacity() * BIT_CHAR)) {
+ if ((this.pos + length) > (((long) this.buf.capacity()) * BIT_CHAR)) {
return false;
}
return true;
@@ -502,7 +502,7 @@ public final class BitBuffer {
* @param newPosition
* The new position of the buffer.
*/
- public void position(int newPosition) {
+ public void position(long newPosition) {
this.pos = newPosition;
}
@@ -512,7 +512,7 @@ public final class BitBuffer {
*
* @return order The position of the buffer.
*/
- public int position() {
+ public long position() {
return this.pos;
}
diff --git a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/EnumDefinition.java b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/EnumDefinition.java
index 9e6e237..d057d5a 100644
--- a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/EnumDefinition.java
+++ b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/EnumDefinition.java
@@ -104,7 +104,7 @@ public class EnumDefinition extends SimpleDatatypeDefinition {
@Override
public void read(BitBuffer input) {
int align = (int) declaration.getAlignment();
- int pos = input.position() + ((align-(input.position() % align))%align);
+ long pos = input.position() + ((align - (input.position() % align)) % align);
input.position(pos);
integerValue.read(input);
long val = integerValue.getValue();
diff --git a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/IntegerDefinition.java b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/IntegerDefinition.java
index f9680ee..7e8701f 100644
--- a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/IntegerDefinition.java
+++ b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/IntegerDefinition.java
@@ -102,7 +102,7 @@ public class IntegerDefinition extends SimpleDatatypeDefinition {
public void read(BitBuffer input) {
final long longNegBit = 0x0000000080000000L;
int align = (int) declaration.getAlignment();
- int pos = input.position() + ((align - (input.position() % align)) % align);
+ long pos = input.position() + ((align - (input.position() % align)) % align);
input.position(pos);
boolean signed = declaration.isSigned();
int length = declaration.getLength();
diff --git a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/StructDefinition.java b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/StructDefinition.java
index 97b711c..4f39e07 100644
--- a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/StructDefinition.java
+++ b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/StructDefinition.java
@@ -92,7 +92,7 @@ public class StructDefinition extends Definition implements IDefinitionScope {
@Override
public void read(BitBuffer input) {
final int align = (int) declaration.getAlignment();
- int pos = input.position()
+ long pos = input.position()
+ ((align - (input.position() % align)) % align);
input.position(pos);
final List<String> fieldList = declaration.getFieldsList();
diff --git a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/StreamInput.java b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/StreamInput.java
index 6b640cb..d8ad3d6 100644
--- a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/StreamInput.java
+++ b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/StreamInput.java
@@ -396,8 +396,8 @@ public class StreamInput implements IDefinitionScope {
* If there is no packet context, infer the content and packet size from
* the file size (assume that there is only one packet and no padding)
*/
- packetIndex.setContentSizeBits((int) (fileSizeBytes * 8));
- packetIndex.setPacketSizeBits((int) (fileSizeBytes * 8));
+ packetIndex.setContentSizeBits(fileSizeBytes * 8);
+ packetIndex.setPacketSizeBits(fileSizeBytes * 8);
}
private void parsePacketContext(long fileSizeBytes,
diff --git a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/trace/StreamInputPacketIndexEntry.java b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/trace/StreamInputPacketIndexEntry.java
index 0cb19ab..a237357 100644
--- a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/trace/StreamInputPacketIndexEntry.java
+++ b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/trace/StreamInputPacketIndexEntry.java
@@ -34,17 +34,17 @@ public class StreamInputPacketIndexEntry {
/**
* Offset of the data in the packet, in bits
*/
- private int dataOffsetBits = 0;
+ private long dataOffsetBits = 0;
/**
* Packet size, in bits
*/
- private int packetSizeBits = 0;
+ private long packetSizeBits = 0;
/**
* Content size, in bits
*/
- private int contentSizeBits = 0;
+ private long contentSizeBits = 0;
/**
* Begin timestamp
@@ -125,7 +125,7 @@ public class StreamInputPacketIndexEntry {
/**
* @return the dataOffsetBits
*/
- public int getDataOffsetBits() {
+ public long getDataOffsetBits() {
return dataOffsetBits;
}
@@ -133,14 +133,14 @@ public class StreamInputPacketIndexEntry {
* @param dataOffsetBits
* the dataOffsetBits to set
*/
- public void setDataOffsetBits(int dataOffsetBits) {
+ public void setDataOffsetBits(long dataOffsetBits) {
this.dataOffsetBits = dataOffsetBits;
}
/**
* @return the packetSizeBits
*/
- public int getPacketSizeBits() {
+ public long getPacketSizeBits() {
return packetSizeBits;
}
@@ -148,14 +148,14 @@ public class StreamInputPacketIndexEntry {
* @param packetSizeBits
* the packetSizeBits to set
*/
- public void setPacketSizeBits(int packetSizeBits) {
+ public void setPacketSizeBits(long packetSizeBits) {
this.packetSizeBits = packetSizeBits;
}
/**
* @return the contentSizeBits
*/
- public int getContentSizeBits() {
+ public long getContentSizeBits() {
return contentSizeBits;
}
@@ -163,7 +163,7 @@ public class StreamInputPacketIndexEntry {
* @param contentSizeBits
* the contentSizeBits to set
*/
- public void setContentSizeBits(int contentSizeBits) {
+ public void setContentSizeBits(long contentSizeBits) {
this.contentSizeBits = contentSizeBits;
}