Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoreutarass2011-09-01 16:58:57 -0400
committereutarass2011-09-01 16:58:57 -0400
commit2b3c25c1aaaae0db91bf5c850ee04046bc77a5cc (patch)
treef561a0a43da4fd1cbd733806439497319a83b22c /plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse
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.ui/src/org/eclipse')
-rw-r--r--plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/adapters/TCFNodePropertySource.java9
-rw-r--r--plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/commands/MemoryMapItemDialog.java3
-rw-r--r--plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/commands/MemoryMapWidget.java2
-rw-r--r--plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFAnnotationManager.java9
-rw-r--r--plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFNodeExecContext.java15
-rw-r--r--plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFNodeExpression.java4
-rw-r--r--plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFNodeModule.java9
-rw-r--r--plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFNodeStackFrame.java11
8 files changed, 19 insertions, 43 deletions
diff --git a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/adapters/TCFNodePropertySource.java b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/adapters/TCFNodePropertySource.java
index c4e02d9e9..918090087 100644
--- a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/adapters/TCFNodePropertySource.java
+++ b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/adapters/TCFNodePropertySource.java
@@ -24,6 +24,7 @@ import org.eclipse.tm.internal.tcf.debug.ui.model.TCFNode;
import org.eclipse.tm.internal.tcf.debug.ui.model.TCFNodeExecContext;
import org.eclipse.tm.internal.tcf.debug.ui.model.TCFNodeExecContext.MemoryRegion;
import org.eclipse.tm.internal.tcf.debug.ui.model.TCFNodeStackFrame;
+import org.eclipse.tm.tcf.protocol.JSON;
import org.eclipse.tm.tcf.services.IRunControl;
import org.eclipse.tm.tcf.services.IStackTrace;
import org.eclipse.tm.tcf.util.TCFDataCache;
@@ -179,12 +180,7 @@ public class TCFNodePropertySource implements IPropertySource {
}
private static String toHexAddrString(Number num) {
- BigInteger n;
- if (num instanceof BigInteger) {
- n = (BigInteger) num;
- } else {
- n = BigInteger.valueOf(num.longValue());
- }
+ BigInteger n = JSON.toBigInteger(num);
String s = n.toString(16);
int sz = s.length() > 8 ? 16 : 8;
int l = sz - s.length();
@@ -192,5 +188,4 @@ public class TCFNodePropertySource implements IPropertySource {
if (l > 16) l = 16;
return "0x0000000000000000".substring(0, 2 + l) + s;
}
-
}
diff --git a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/commands/MemoryMapItemDialog.java b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/commands/MemoryMapItemDialog.java
index b5f96f0a4..830c5a59a 100644
--- a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/commands/MemoryMapItemDialog.java
+++ b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/commands/MemoryMapItemDialog.java
@@ -32,6 +32,7 @@ import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
+import org.eclipse.tm.tcf.protocol.JSON;
import org.eclipse.tm.tcf.services.IMemoryMap;
class MemoryMapItemDialog extends Dialog {
@@ -202,7 +203,7 @@ class MemoryMapItemDialog extends Dialog {
private String toHex(Number n) {
if (n == null) return null;
- BigInteger x = n instanceof BigInteger ? (BigInteger)n : new BigInteger(n.toString());
+ BigInteger x = JSON.toBigInteger(n);
String s = x.toString(16);
int l = 16 - s.length();
if (l < 0) l = 0;
diff --git a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/commands/MemoryMapWidget.java b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/commands/MemoryMapWidget.java
index 0f7c7394b..77eadcafa 100644
--- a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/commands/MemoryMapWidget.java
+++ b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/commands/MemoryMapWidget.java
@@ -152,7 +152,7 @@ public class MemoryMapWidget {
{
Number n = r.getOffset();
if (n != null) {
- BigInteger x = n instanceof BigInteger ? (BigInteger)n : new BigInteger(n.toString());
+ BigInteger x = JSON.toBigInteger(n);
String s = x.toString(16);
int l = 16 - s.length();
if (l < 0) l = 0;
diff --git a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFAnnotationManager.java b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFAnnotationManager.java
index 07f66eae7..fd0c4d6c4 100644
--- a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFAnnotationManager.java
+++ b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFAnnotationManager.java
@@ -50,6 +50,7 @@ import org.eclipse.tm.internal.tcf.debug.model.TCFSourceRef;
import org.eclipse.tm.internal.tcf.debug.ui.Activator;
import org.eclipse.tm.internal.tcf.debug.ui.ImageCache;
import org.eclipse.tm.tcf.protocol.IChannel;
+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;
@@ -332,12 +333,6 @@ public class TCFAnnotationManager {
return (Map<String,Object>)o;
}
- private BigInteger toBigInteger(Number n) {
- if (n == null) return null;
- if (n instanceof BigInteger) return (BigInteger)n;
- return new BigInteger(n.toString());
- }
-
private void addBreakpointErrorAnnotation(List<TCFAnnotation> set, TCFLaunch launch, String id, String error) {
Map<String,Object> props = launch.getBreakpointsStatus().getProperties(id);
if (props != null) {
@@ -417,7 +412,7 @@ public class TCFAnnotationManager {
if (ctx_id == null) continue;
if (!ctx_id.equals(node.id) && !ctx_id.equals(bp_group)) continue;
error = (String)m.get(IBreakpoints.INSTANCE_ERROR);
- BigInteger addr = toBigInteger((Number)m.get(IBreakpoints.INSTANCE_ADDRESS));
+ BigInteger addr = JSON.toBigInteger((Number)m.get(IBreakpoints.INSTANCE_ADDRESS));
if (addr != null) {
ILineNumbers.CodeArea area = null;
TCFDataCache<TCFSourceRef> line_cache = memory.getLineInfo(addr);
diff --git a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFNodeExecContext.java b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFNodeExecContext.java
index c3e0ee355..9b3acad8b 100644
--- a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFNodeExecContext.java
+++ b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFNodeExecContext.java
@@ -35,6 +35,7 @@ import org.eclipse.tm.internal.tcf.debug.model.TCFSourceRef;
import org.eclipse.tm.internal.tcf.debug.ui.ImageCache;
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.ILineNumbers;
import org.eclipse.tm.tcf.services.IMemory;
@@ -152,8 +153,8 @@ public class TCFNodeExecContext extends TCFNode implements ISymbolOwner {
addr_end = null;
}
else {
- addr_start = addr instanceof BigInteger ? (BigInteger)addr : new BigInteger(addr.toString());
- addr_end = addr_start.add(size instanceof BigInteger ? (BigInteger)size : new BigInteger(size.toString()));
+ addr_start = JSON.toBigInteger(addr);
+ addr_end = addr_start.add(JSON.toBigInteger(size));
}
}
@@ -526,12 +527,6 @@ public class TCFNodeExecContext extends TCFNode implements ISymbolOwner {
return signal_mask;
}
- private BigInteger toBigInteger(Number n) {
- if (n == null) return null;
- if (n instanceof BigInteger) return (BigInteger)n;
- return new BigInteger(n.toString());
- }
-
public TCFDataCache<TCFSourceRef> getLineInfo(final BigInteger addr) {
if (isDisposed()) return null;
TCFDataCache<TCFSourceRef> ref_cache;
@@ -568,8 +563,8 @@ public class TCFNodeExecContext extends TCFNode implements ISymbolOwner {
ref_data.address = addr;
if (error == null && areas != null && areas.length > 0) {
for (ILineNumbers.CodeArea area : areas) {
- BigInteger a0 = toBigInteger(area.start_address);
- BigInteger a1 = toBigInteger(area.end_address);
+ BigInteger a0 = JSON.toBigInteger(area.start_address);
+ BigInteger a1 = JSON.toBigInteger(area.end_address);
if (n0.compareTo(a0) >= 0 && n0.compareTo(a1) < 0) {
if (ref_data.area == null || area.start_line < ref_data.area.start_line) {
if (area.start_address != a0 || area.end_address != a1) {
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 84f43f402..b2813ab1a 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
@@ -36,6 +36,7 @@ import org.eclipse.tm.internal.tcf.debug.ui.Activator;
import org.eclipse.tm.internal.tcf.debug.ui.ImageCache;
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.IExpressions;
import org.eclipse.tm.tcf.services.IMemory;
@@ -1265,8 +1266,7 @@ public class TCFNodeExpression extends TCFNode implements IElementEditor, ICastT
}
Number addr = v.getAddress();
if (addr != null) {
- BigInteger i = addr instanceof BigInteger ?
- (BigInteger)addr : new BigInteger(addr.toString());
+ BigInteger i = JSON.toBigInteger(addr);
bf.append("Address: 0x");
bf.append(i.toString(16));
bf.append('\n');
diff --git a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFNodeModule.java b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFNodeModule.java
index a4888f320..a42a574a7 100644
--- a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFNodeModule.java
+++ b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFNodeModule.java
@@ -14,6 +14,7 @@ import java.math.BigInteger;
import org.eclipse.debug.internal.ui.viewers.model.provisional.ILabelUpdate;
import org.eclipse.tm.internal.tcf.debug.ui.ImageCache;
+import org.eclipse.tm.tcf.protocol.JSON;
import org.eclipse.tm.tcf.services.IMemoryMap;
/**
@@ -76,13 +77,7 @@ public class TCFNodeModule extends TCFNode {
private String toHexString(Number address) {
if (address == null) return "";
- BigInteger addr;
- if (address instanceof BigInteger) {
- addr = (BigInteger)address;
- }
- else {
- addr = new BigInteger(address.toString());
- }
+ BigInteger addr = JSON.toBigInteger(address);
String s = addr.toString(16);
int sz = s.length() <= 8 ? 8 : 16;
int l = sz - s.length();
diff --git a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFNodeStackFrame.java b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFNodeStackFrame.java
index f6c21a448..e7ee532d1 100644
--- a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFNodeStackFrame.java
+++ b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFNodeStackFrame.java
@@ -26,6 +26,7 @@ import org.eclipse.tm.internal.tcf.debug.model.TCFFunctionRef;
import org.eclipse.tm.internal.tcf.debug.model.TCFSourceRef;
import org.eclipse.tm.internal.tcf.debug.ui.ImageCache;
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.IExpressions;
import org.eclipse.tm.tcf.services.IStackTrace;
@@ -154,7 +155,7 @@ public class TCFNodeStackFrame extends TCFNode {
return true;
}
if (n != null) {
- set(null, null, toBigInteger(n));
+ set(null, null, JSON.toBigInteger(n));
return true;
}
}
@@ -220,7 +221,7 @@ public class TCFNodeStackFrame extends TCFNode {
assert Protocol.isDispatchThread();
if (!stack_trace_context.isValid()) return null;
IStackTrace.StackTraceContext ctx = stack_trace_context.getData();
- if (ctx != null) return toBigInteger(ctx.getReturnAddress());
+ if (ctx != null) return JSON.toBigInteger(ctx.getReturnAddress());
return null;
}
@@ -445,12 +446,6 @@ public class TCFNodeStackFrame extends TCFNode {
return true;
}
- private BigInteger toBigInteger(Number n) {
- if (n == null) return null;
- if (n instanceof BigInteger) return (BigInteger)n;
- return new BigInteger(n.toString());
- }
-
private String makeHexAddrString(int addr_size, BigInteger n) {
String s = n.toString(16);
int sz = (addr_size != 0 ? addr_size : 4) * 2;

Back to the top