Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoreutarass2011-09-01 20:58:57 +0000
committereutarass2011-09-01 20:58:57 +0000
commit2b3c25c1aaaae0db91bf5c850ee04046bc77a5cc (patch)
treef561a0a43da4fd1cbd733806439497319a83b22c /plugins/org.eclipse.tm.tcf.debug
parentf10c693c1fcfa84ed90218ebe35c5215ff8250b0 (diff)
downloadorg.eclipse.tcf-2b3c25c1aaaae0db91bf5c850ee04046bc77a5cc.tar.gz
org.eclipse.tcf-2b3c25c1aaaae0db91bf5c850ee04046bc77a5cc.tar.xz
org.eclipse.tcf-2b3c25c1aaaae0db91bf5c850ee04046bc77a5cc.zip
TCF Debugger: a bit better code for conversion of JSON numbers to BigInteger.
Diffstat (limited to 'plugins/org.eclipse.tm.tcf.debug')
-rw-r--r--plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/actions/TCFActionStepInto.java7
-rw-r--r--plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/actions/TCFActionStepOut.java3
-rw-r--r--plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/actions/TCFActionStepOver.java9
-rw-r--r--plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/model/TCFMemoryRegion.java7
-rw-r--r--plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/tests/TestExpressions.java5
-rw-r--r--plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/tests/TestRCBP1.java3
6 files changed, 17 insertions, 17 deletions
diff --git a/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/actions/TCFActionStepInto.java b/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/actions/TCFActionStepInto.java
index f34e20312..0966ce985 100644
--- a/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/actions/TCFActionStepInto.java
+++ b/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/actions/TCFActionStepInto.java
@@ -18,6 +18,7 @@ import org.eclipse.tm.internal.tcf.debug.model.TCFContextState;
import org.eclipse.tm.internal.tcf.debug.model.TCFLaunch;
import org.eclipse.tm.internal.tcf.debug.model.TCFSourceRef;
import org.eclipse.tm.tcf.protocol.IToken;
+import org.eclipse.tm.tcf.protocol.JSON;
import org.eclipse.tm.tcf.protocol.Protocol;
import org.eclipse.tm.tcf.services.ILineNumbers;
import org.eclipse.tm.tcf.services.IRunControl;
@@ -65,10 +66,8 @@ public abstract class TCFActionStepInto extends TCFAction implements IRunControl
private void setSourceRef(TCFSourceRef ref) {
ILineNumbers.CodeArea area = ref.area;
if (area != null) {
- if (area.start_address instanceof BigInteger) pc0 = (BigInteger)area.start_address;
- else if (area.start_address != null) pc0 = new BigInteger(area.start_address.toString());
- if (area.end_address instanceof BigInteger) pc1 = (BigInteger)area.end_address;
- else if (area.end_address != null) pc1 = new BigInteger(area.end_address.toString());
+ pc0 = JSON.toBigInteger(area.start_address);
+ pc1 = JSON.toBigInteger(area.end_address);
}
else {
pc0 = null;
diff --git a/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/actions/TCFActionStepOut.java b/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/actions/TCFActionStepOut.java
index c1028f8fa..3656395cc 100644
--- a/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/actions/TCFActionStepOut.java
+++ b/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/actions/TCFActionStepOut.java
@@ -18,6 +18,7 @@ import java.util.Map;
import org.eclipse.tm.internal.tcf.debug.model.TCFContextState;
import org.eclipse.tm.internal.tcf.debug.model.TCFLaunch;
import org.eclipse.tm.tcf.protocol.IToken;
+import org.eclipse.tm.tcf.protocol.JSON;
import org.eclipse.tm.tcf.protocol.Protocol;
import org.eclipse.tm.tcf.services.IBreakpoints;
import org.eclipse.tm.tcf.services.IRunControl;
@@ -112,7 +113,7 @@ public abstract class TCFActionStepOut extends TCFAction implements IRunControl.
return;
}
if (step_back) {
- BigInteger n = new BigInteger(addr.toString());
+ BigInteger n = JSON.toBigInteger(addr);
addr = n.subtract(BigInteger.valueOf(1));
}
String id = "Step." + ctx.getID();
diff --git a/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/actions/TCFActionStepOver.java b/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/actions/TCFActionStepOver.java
index b5518bd89..c52ae5834 100644
--- a/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/actions/TCFActionStepOver.java
+++ b/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/actions/TCFActionStepOver.java
@@ -19,6 +19,7 @@ import org.eclipse.tm.internal.tcf.debug.model.TCFContextState;
import org.eclipse.tm.internal.tcf.debug.model.TCFLaunch;
import org.eclipse.tm.internal.tcf.debug.model.TCFSourceRef;
import org.eclipse.tm.tcf.protocol.IToken;
+import org.eclipse.tm.tcf.protocol.JSON;
import org.eclipse.tm.tcf.protocol.Protocol;
import org.eclipse.tm.tcf.services.IBreakpoints;
import org.eclipse.tm.tcf.services.ILineNumbers;
@@ -73,10 +74,8 @@ public abstract class TCFActionStepOver extends TCFAction implements IRunControl
private void setSourceRef(TCFSourceRef ref) {
ILineNumbers.CodeArea area = ref.area;
if (area != null) {
- if (area.start_address instanceof BigInteger) pc0 = (BigInteger)area.start_address;
- else if (area.start_address != null) pc0 = new BigInteger(area.start_address.toString());
- if (area.end_address instanceof BigInteger) pc1 = (BigInteger)area.end_address;
- else if (area.end_address != null) pc1 = new BigInteger(area.end_address.toString());
+ pc0 = JSON.toBigInteger(area.start_address);
+ pc1 = JSON.toBigInteger(area.end_address);
}
else {
pc0 = null;
@@ -175,7 +174,7 @@ public abstract class TCFActionStepOver extends TCFAction implements IRunControl
return;
}
if (step_back) {
- BigInteger n = new BigInteger(addr.toString());
+ BigInteger n = JSON.toBigInteger(addr);
addr = n.subtract(BigInteger.valueOf(1));
}
String id = "Step." + ctx.getID();
diff --git a/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/model/TCFMemoryRegion.java b/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/model/TCFMemoryRegion.java
index 2975e8cfc..8017fe254 100644
--- a/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/model/TCFMemoryRegion.java
+++ b/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/model/TCFMemoryRegion.java
@@ -13,6 +13,7 @@ package org.eclipse.tm.internal.tcf.debug.model;
import java.math.BigInteger;
import java.util.Map;
+import org.eclipse.tm.tcf.protocol.JSON;
import org.eclipse.tm.tcf.services.IMemoryMap;
import org.eclipse.tm.tcf.services.IMemoryMap.MemoryRegion;
@@ -25,10 +26,8 @@ public class TCFMemoryRegion implements MemoryRegion, Comparable<TCFMemoryRegion
public TCFMemoryRegion(Map<String,Object> props) {
this.props = props;
- Number addr = (Number)props.get(IMemoryMap.PROP_ADDRESS);
- Number size = (Number)props.get(IMemoryMap.PROP_SIZE);
- this.addr = addr == null || addr instanceof BigInteger ? (BigInteger)addr : new BigInteger(addr.toString());
- this.size = size == null || size instanceof BigInteger ? (BigInteger)size : new BigInteger(size.toString());
+ this.addr = JSON.toBigInteger((Number)props.get(IMemoryMap.PROP_ADDRESS));
+ this.size = JSON.toBigInteger((Number)props.get(IMemoryMap.PROP_SIZE));
}
public Number getAddress() {
diff --git a/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/tests/TestExpressions.java b/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/tests/TestExpressions.java
index a5dcbd7c4..eee12ab4b 100644
--- a/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/tests/TestExpressions.java
+++ b/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/tests/TestExpressions.java
@@ -20,6 +20,7 @@ import java.util.Set;
import org.eclipse.tm.tcf.protocol.IChannel;
import org.eclipse.tm.tcf.protocol.IToken;
+import org.eclipse.tm.tcf.protocol.JSON;
import org.eclipse.tm.tcf.protocol.Protocol;
import org.eclipse.tm.tcf.services.IBreakpoints;
import org.eclipse.tm.tcf.services.IDiagnostics;
@@ -182,7 +183,7 @@ class TestExpressions implements ITCFTest,
if (run_to_bp_done) return false;
if (sym_func3 == null) return false;
if (suspended_pc == null) return false;
- BigInteger pc0 = new BigInteger(sym_func3.getValue().toString());
+ BigInteger pc0 = JSON.toBigInteger(sym_func3.getValue());
BigInteger pc1 = new BigInteger(suspended_pc);
if (pc0.equals(pc1)) return false;
}
@@ -340,7 +341,7 @@ class TestExpressions implements ITCFTest,
return;
}
if (!run_to_bp_done) {
- BigInteger pc0 = new BigInteger(sym_func3.getValue().toString());
+ BigInteger pc0 = JSON.toBigInteger(sym_func3.getValue());
BigInteger pc1 = new BigInteger(suspended_pc);
if (!pc0.equals(pc1)) {
waiting_suspend = true;
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 e44457f9a..d92b74d5c 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
@@ -23,6 +23,7 @@ import java.util.Set;
import org.eclipse.tm.tcf.protocol.IChannel;
import org.eclipse.tm.tcf.protocol.IErrorReport;
import org.eclipse.tm.tcf.protocol.IToken;
+import org.eclipse.tm.tcf.protocol.JSON;
import org.eclipse.tm.tcf.protocol.Protocol;
import org.eclipse.tm.tcf.services.IBreakpoints;
import org.eclipse.tm.tcf.services.IDiagnostics;
@@ -1567,7 +1568,7 @@ class TestRCBP1 implements ITCFTest, IRunControl.RunControlListener {
exit(new Exception("Invalid symbol size attribute"));
return;
}
- BigInteger y = new BigInteger(addr.toString());
+ BigInteger y = JSON.toBigInteger(addr);
BigInteger z = y.add(BigInteger.valueOf(size));
if (x.compareTo(y) < 0 || x.compareTo(z) >= 0) {
exit(new Exception("Invalid symbol address attribute"));

Back to the top