Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEugene Tarassov2015-12-21 22:44:17 -0500
committerEugene Tarassov2015-12-21 22:44:17 -0500
commit9a820b0bbc0bf50bb8d8ac03409564dcea96ac8d (patch)
treeed5e65a3fc2b63456648a57779dfb10192c84ed1 /plugins
parent583e7e1401c1250282f0b7bd5a39f67c959302c0 (diff)
downloadorg.eclipse.tcf-9a820b0bbc0bf50bb8d8ac03409564dcea96ac8d.tar.gz
org.eclipse.tcf-9a820b0bbc0bf50bb8d8ac03409564dcea96ac8d.tar.xz
org.eclipse.tcf-9a820b0bbc0bf50bb8d8ac03409564dcea96ac8d.zip
TCF Debugger: fixed handling of negative input number for unsigned ints
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFNumberFormat.java10
1 files changed, 6 insertions, 4 deletions
diff --git a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFNumberFormat.java b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFNumberFormat.java
index afa19d8aa..11ce576a2 100644
--- a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFNumberFormat.java
+++ b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFNumberFormat.java
@@ -75,8 +75,11 @@ public class TCFNumberFormat {
public static byte[] toByteArray(String s, int radix, boolean fp, int size, boolean signed, boolean big_endian) throws Exception {
byte[] bf = null;
+ boolean sign_extention = false;
if (!fp) {
- bf = new BigInteger(s, radix).toByteArray();
+ BigInteger n = new BigInteger(s, radix);
+ sign_extention = n.signum() < 0;
+ bf = n.toByteArray();
}
else if (size == 4) {
int n = Float.floatToIntBits(Float.parseFloat(s));
@@ -184,9 +187,8 @@ public class TCFNumberFormat {
throw new Exception("Unsupported floating point format");
}
byte[] rs = new byte[size];
- if (signed && rs.length > bf.length && (bf[0] & 0x80) != 0) {
- // Sign extension
- for (int i = 0; i < rs.length; i++) rs[i] = (byte)0xff;
+ if (rs.length > bf.length && sign_extention) {
+ for (int i = bf.length; i < rs.length; i++) rs[i] = (byte)0xff;
}
for (int i = 0; i < bf.length; i++) {
// i == 0 -> least significant byte

Back to the top