Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/lttng
diff options
context:
space:
mode:
authorMatthew Khouzam2012-06-14 21:21:22 +0000
committerMatthew Khouzam2012-06-14 21:21:33 +0000
commitfcd3b789a0691b8062ca0aeae678fa1fe1e2ce2b (patch)
tree475a230449099e2abc9362cb275438dfede258e8 /lttng
parent687c6eab67f0e370512268e10b3391be0f2dc6c3 (diff)
downloadorg.eclipse.linuxtools-fcd3b789a0691b8062ca0aeae678fa1fe1e2ce2b.tar.gz
org.eclipse.linuxtools-fcd3b789a0691b8062ca0aeae678fa1fe1e2ce2b.tar.xz
org.eclipse.linuxtools-fcd3b789a0691b8062ca0aeae678fa1fe1e2ce2b.zip
Display signed 32-bit integers with a sign.
Thanks to Francois Rajotte for reporting the bug. Signed-off-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Diffstat (limited to 'lttng')
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/IntegerDefinition.java10
1 files changed, 9 insertions, 1 deletions
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 1157abde24..b39a97ce95 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
@@ -16,7 +16,7 @@ import org.eclipse.linuxtools.internal.ctf.core.event.io.BitBuffer;
/**
* A CTF integer definition.
- *
+ *
* The definition of a integer basic data type. It will take the data
* from a trace and store it (and make it fit) as a long.
*
@@ -83,6 +83,7 @@ public class IntegerDefinition extends Definition {
@Override
public void read(BitBuffer input) {
+ final long longNegBit = 0x0000000080000000L;
int align = (int) declaration.getAlignment();
int pos = input.position() + ((align-(input.position() % align))%align);
input.position(pos);
@@ -102,6 +103,13 @@ public class IntegerDefinition extends Definition {
} else {
bits = input.getInt(length, signed);
bits = bits & 0x00000000FFFFFFFFL;
+ /*
+ * The previous line loses sign information but is necessary, this fixes the sign
+ * for 32 bit numbers. Sorry, in java all 64 bit ints are signed.
+ */
+ if( (longNegBit == (bits & longNegBit)) && signed) {
+ bits |= 0xffffffff00000000L;
+ }
}
value = bits;

Back to the top