Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoreutarass2011-09-27 01:52:39 +0000
committereutarass2011-09-27 01:52:39 +0000
commit3125274ce860c37a0f7dfde2b977828033f2a9cb (patch)
tree544ab308aef9a2a54eebecf2404a77318896b717
parent93fe91e55769eb06bb8fdfb57af81619bf614c0b (diff)
downloadorg.eclipse.tcf-3125274ce860c37a0f7dfde2b977828033f2a9cb.tar.gz
org.eclipse.tcf-3125274ce860c37a0f7dfde2b977828033f2a9cb.tar.xz
org.eclipse.tcf-3125274ce860c37a0f7dfde2b977828033f2a9cb.zip
TCF Debugger: added display of decimal value for 80-bit floating point numbers.
-rw-r--r--plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFNodeExpression.java38
-rw-r--r--plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFNodeRegister.java15
-rw-r--r--plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFNumberFormat.java68
-rw-r--r--plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/tests/TestRCBP1.java1
4 files changed, 78 insertions, 44 deletions
diff --git a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFNodeExpression.java b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFNodeExpression.java
index 39c929e5e..fd8f3f4a2 100644
--- a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFNodeExpression.java
+++ b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFNodeExpression.java
@@ -456,7 +456,7 @@ public class TCFNodeExpression extends TCFNode implements IElementEditor, ICastT
set(null, null, toASCIIString(data, 0, data.length, '"'));
return true;
}
- BigInteger a = toBigInteger(data, 0, data.length, v.isBigEndian(), false);
+ BigInteger a = TCFNumberFormat.toBigInteger(data, 0, data.length, v.isBigEndian(), false);
if (!a.equals(BigInteger.valueOf(0))) {
addr = a;
Protocol.invokeLater(this);
@@ -805,27 +805,6 @@ public class TCFNodeExpression extends TCFNode implements IElementEditor, ICastT
return bf.toString();
}
- private BigInteger toBigInteger(byte[] data, int offs, int size, boolean big_endian, boolean sign_extension) {
- assert offs + size <= data.length;
- byte[] temp = null;
- if (sign_extension) {
- temp = new byte[size];
- }
- else {
- temp = new byte[size + 1];
- temp[0] = 0; // Extra byte to avoid sign extension by BigInteger
- }
- if (big_endian) {
- System.arraycopy(data, offs, temp, sign_extension ? 0 : 1, size);
- }
- else {
- for (int i = 0; i < size; i++) {
- temp[temp.length - i - 1] = data[i + offs];
- }
- }
- return new BigInteger(temp);
- }
-
private String toNumberString(int radix, ISymbols.TypeClass t, byte[] data, int offs, int size, boolean big_endian) {
if (size <= 0 || size > 16) return "";
if (radix != 16) {
@@ -841,25 +820,16 @@ public class TCFNodeExpression extends TCFNode implements IElementEditor, ICastT
if (t != null) {
switch (t) {
case integer:
- s = toBigInteger(data, offs, size, big_endian, true).toString();
+ s = TCFNumberFormat.toBigInteger(data, offs, size, big_endian, true).toString();
break;
case real:
- switch (size) {
- case 4:
- s = Float.toString(Float.intBitsToFloat(toBigInteger(
- data, offs, size, big_endian, true).intValue()));
- break;
- case 8:
- s = Double.toString(Double.longBitsToDouble(toBigInteger(
- data, offs, size, big_endian, true).longValue()));
- break;
- }
+ s = TCFNumberFormat.toFPString(data, offs, size, big_endian);
break;
}
}
}
if (s == null) {
- s = toBigInteger(data, offs, size, big_endian, false).toString(radix);
+ s = TCFNumberFormat.toBigInteger(data, offs, size, big_endian, false).toString(radix);
switch (radix) {
case 8:
if (!s.startsWith("0")) s = "0" + s;
diff --git a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFNodeRegister.java b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFNodeRegister.java
index 7042c63f5..864646268 100644
--- a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFNodeRegister.java
+++ b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFNodeRegister.java
@@ -348,17 +348,12 @@ public class TCFNodeRegister extends TCFNode implements IElementEditor {
}
return bf.toString();
}
- byte[] temp = new byte[data.length + 1];
- temp[0] = 0; // Extra byte to avoid sign extension by BigInteger
- if (ctx.isBigEndian()) {
- System.arraycopy(data, 0, temp, 1, data.length);
+ if (radix == 10 && ctx.isFloat()) {
+ String s = TCFNumberFormat.toFPString(data, 0, data.length, ctx.isBigEndian());
+ if (s != null) return s;
}
- else {
- for (int i = 0; i < data.length; i++) {
- temp[temp.length - i - 1] = data[i];
- }
- }
- String s = new BigInteger(temp).toString(radix);
+ BigInteger b = TCFNumberFormat.toBigInteger(data, 0, data.length, ctx.isBigEndian(), false);
+ String s = b.toString(radix);
switch (radix) {
case 8:
if (!s.startsWith("0")) s = "0" + s;
diff --git a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFNumberFormat.java b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFNumberFormat.java
index 610a98f94..6689b6753 100644
--- a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFNumberFormat.java
+++ b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFNumberFormat.java
@@ -10,7 +10,9 @@
*******************************************************************************/
package org.eclipse.tm.internal.tcf.debug.ui.model;
+import java.math.BigDecimal;
import java.math.BigInteger;
+import java.math.RoundingMode;
public class TCFNumberFormat {
@@ -106,4 +108,70 @@ public class TCFNumberFormat {
}
return rs;
}
+
+ public static String toFPString(byte[] data, int offs, int size, boolean big_endian) {
+ switch (size) {
+ case 4:
+ return Float.toString(Float.intBitsToFloat(toBigInteger(
+ data, offs, size, big_endian, true).intValue()));
+ case 8:
+ return Double.toString(Double.longBitsToDouble(toBigInteger(
+ data, offs, size, big_endian, true).longValue()));
+ case 10:
+ {
+ byte[] arr = new byte[size];
+ if (!big_endian) {
+ for (int i = 0; i < size; i++) {
+ arr[arr.length - i - 1] = data[offs + i];
+ }
+ }
+ else {
+ System.arraycopy(data, offs, arr, 0, size);
+ }
+ boolean neg = (arr[0] & 0x80) != 0;
+ int scale = ((arr[0] & 0x7f) << 8) | (arr[1] & 0xff);
+ if (scale == 0x7fff) {
+ for (int i = 2; i < arr.length; i++) {
+ int n = arr[i] & 0xff;
+ if (i == 2) n &= 0x7f;
+ if (n != 0) return neg ? "-NaN" : "+NaN";
+ }
+ return neg ? "-Inf" : "+Inf";
+ }
+ scale -= 16446;
+ arr[0] = arr[1] = 0;
+ BigDecimal a = new BigDecimal(new BigInteger(arr), 0);
+ if (a.signum() != 0 && scale != 0) {
+ BigDecimal p = new BigDecimal(BigInteger.valueOf(2), 0);
+ if (scale > 0) a = a.multiply(p.pow(scale));
+ else a = a.divide(p.pow(-scale), a.scale() - scale / 3, RoundingMode.HALF_DOWN);
+ }
+ String s = a.toString();
+ if (neg) s = "-" + s;
+ return s;
+ }
+ }
+ return null;
+ }
+
+ public static BigInteger toBigInteger(byte[] data, int offs, int size, boolean big_endian, boolean sign_extension) {
+ assert offs + size <= data.length;
+ byte[] temp = null;
+ if (sign_extension) {
+ temp = new byte[size];
+ }
+ else {
+ temp = new byte[size + 1];
+ temp[0] = 0; // Extra byte to avoid sign extension by BigInteger
+ }
+ if (big_endian) {
+ System.arraycopy(data, offs, temp, sign_extension ? 0 : 1, size);
+ }
+ else {
+ for (int i = 0; i < size; i++) {
+ temp[temp.length - i - 1] = data[i + offs];
+ }
+ }
+ return new BigInteger(temp);
+ }
}
diff --git a/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/tests/TestRCBP1.java b/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/tests/TestRCBP1.java
index d92b74d5c..56ed77663 100644
--- a/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/tests/TestRCBP1.java
+++ b/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/tests/TestRCBP1.java
@@ -1476,6 +1476,7 @@ class TestRCBP1 implements ITCFTest, IRunControl.RunControlListener {
if (!ctx.isWriteable()) continue;
if (ctx.isReadOnce()) continue;
if (ctx.isWriteOnce()) continue;
+ if (ctx.getSize() == 0) continue;
int offs = rnd.nextInt(ctx.getSize());
int size = rnd.nextInt(ctx.getSize() - offs) + 1;
locs.add(new IRegisters.Location(id, offs, size));

Back to the top