diff options
author | Eugene Tarassov | 2015-12-22 03:44:17 +0000 |
---|---|---|
committer | Eugene Tarassov | 2015-12-22 03:44:17 +0000 |
commit | 9a820b0bbc0bf50bb8d8ac03409564dcea96ac8d (patch) | |
tree | ed5e65a3fc2b63456648a57779dfb10192c84ed1 | |
parent | 583e7e1401c1250282f0b7bd5a39f67c959302c0 (diff) | |
download | org.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
-rw-r--r-- | plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFNumberFormat.java | 10 |
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 |