Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoreutarass2008-04-07 19:56:45 +0000
committereutarass2008-04-07 19:56:45 +0000
commit3008d4750370013e6e9750ddb00039df362dbb5a (patch)
tree322ea479c63ff1e54b99994585184875914d1f67 /plugins/org.eclipse.tm.tcf.debug.ui
parent3c90f4ac3612c74dd8309c85c6a96c77d860156c (diff)
downloadorg.eclipse.tcf-3008d4750370013e6e9750ddb00039df362dbb5a.tar.gz
org.eclipse.tcf-3008d4750370013e6e9750ddb00039df362dbb5a.tar.xz
org.eclipse.tcf-3008d4750370013e6e9750ddb00039df362dbb5a.zip
Bug 223520: [tcf] Registers service changes: data formatting is removed from the service.
Diffstat (limited to 'plugins/org.eclipse.tm.tcf.debug.ui')
-rw-r--r--plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/launch/TCFSelfTest.java51
-rw-r--r--plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFNodeRegister.java151
2 files changed, 84 insertions, 118 deletions
diff --git a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/launch/TCFSelfTest.java b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/launch/TCFSelfTest.java
index f3b19cbac..86e1fe85c 100644
--- a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/launch/TCFSelfTest.java
+++ b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/launch/TCFSelfTest.java
@@ -926,34 +926,31 @@ class TCFSelfTest {
for (final IRegisters.RegistersContext ctx : reg_map.values()) {
if (!ctx.isReadable()) continue;
if (ctx.isReadOnce()) continue;
- String[] fmts = ctx.getAvailableFormats();
- for (final String fmt : fmts) {
- cmds.add(ctx.get(fmt, new IRegisters.DoneGet() {
- public void doneGet(IToken token, Exception error, String value) {
- cmds.remove(token);
- if (suspended.get(sc.id) != sc) return;
- if (error != null) {
- for (IToken t : cmds) t.cancel();
- exit(error);
- return;
- }
- cmds.add(ctx.set(fmt, value, new IRegisters.DoneSet() {
- public void doneSet(IToken token, Exception error) {
- cmds.remove(token);
- if (suspended.get(sc.id) != sc) return;
- if (error != null) {
- for (IToken t : cmds) t.cancel();
- exit(error);
- return;
- }
- if (cmds.isEmpty()) {
- resume(sc);
- }
- }
- }));
+ cmds.add(ctx.get(new IRegisters.DoneGet() {
+ public void doneGet(IToken token, Exception error, byte[] value) {
+ cmds.remove(token);
+ if (suspended.get(sc.id) != sc) return;
+ if (error != null) {
+ for (IToken t : cmds) t.cancel();
+ exit(error);
+ return;
}
- }));
- }
+ cmds.add(ctx.set(value, new IRegisters.DoneSet() {
+ public void doneSet(IToken token, Exception error) {
+ cmds.remove(token);
+ if (suspended.get(sc.id) != sc) return;
+ if (error != null) {
+ for (IToken t : cmds) t.cancel();
+ exit(error);
+ return;
+ }
+ if (cmds.isEmpty()) {
+ resume(sc);
+ }
+ }
+ }));
+ }
+ }));
}
if (cmds.isEmpty()) {
resume(sc);
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 575d3ea14..50a3e44e5 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
@@ -10,6 +10,9 @@
*******************************************************************************/
package org.eclipse.tm.internal.tcf.debug.ui.model;
+import java.math.BigInteger;
+import java.util.Arrays;
+
import org.eclipse.debug.internal.ui.viewers.model.provisional.ILabelUpdate;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelDelta;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
@@ -43,8 +46,7 @@ public class TCFNodeRegister extends TCFNode {
private final TCFDataCache<IRegisters.RegistersContext> context;
- private final TCFDataCache<String> hex_value;
- private final TCFDataCache<String> dec_value;
+ private final TCFDataCache<byte[]> value;
TCFNodeRegister(TCFNode parent, final String id) {
super(parent, id);
@@ -61,7 +63,7 @@ public class TCFNodeRegister extends TCFNode {
return false;
}
};
- hex_value = new TCFDataCache<String>(channel) {
+ value = new TCFDataCache<byte[]>(channel) {
@Override
protected boolean startDataRetrieval() {
if (!context.validate()) {
@@ -73,46 +75,8 @@ public class TCFNodeRegister extends TCFNode {
set(null, null, null);
return true;
}
- String[] fmts = ctx.getAvailableFormats();
- String fmt = null;
- for (String s : fmts) {
- if (s.equals(IRegisters.FORMAT_HEX)) fmt = s;
- }
- if (fmt == null) {
- set(null, null, null);
- return true;
- }
- command = ctx.get(fmt, new IRegisters.DoneGet() {
- public void doneGet(IToken token, Exception error, String value) {
- set(token, error, value);
- }
- });
- return false;
- }
- };
- dec_value = new TCFDataCache<String>(channel) {
- @Override
- protected boolean startDataRetrieval() {
- if (!context.validate()) {
- context.wait(this);
- return false;
- }
- IRegisters.RegistersContext ctx = context.getData();
- if (ctx == null) {
- set(null, null, null);
- return true;
- }
- String[] fmts = ctx.getAvailableFormats();
- String fmt = null;
- for (String s : fmts) {
- if (s.equals(IRegisters.FORMAT_DECIMAL)) fmt = s;
- }
- if (fmt == null) {
- set(null, null, null);
- return true;
- }
- command = ctx.get(fmt, new IRegisters.DoneGet() {
- public void doneGet(IToken token, Exception error, String value) {
+ command = ctx.get(new IRegisters.DoneGet() {
+ public void doneGet(IToken token, Exception error, byte[] value) {
set(token, error, value);
}
});
@@ -133,14 +97,14 @@ public class TCFNodeRegister extends TCFNode {
else if (ctx != null) {
String[] cols = result.getColumnIds();
if (cols == null) {
- result.setLabel(ctx.getName() + " = " + hex_value.getData(), 0);
+ setLabel(result, -1, 16);
}
else {
for (int i = 0; i < cols.length; i++) {
String c = cols[i];
if (c.equals(COL_NAME)) result.setLabel(ctx.getName(), i);
- else if (c.equals(COL_HEX_VALUE)) setLabel(result, hex_value, i);
- else if (c.equals(COL_DEC_VALUE)) result.setLabel(dec_value.getData(), i);
+ else if (c.equals(COL_HEX_VALUE)) setLabel(result, i, 16);
+ else if (c.equals(COL_DEC_VALUE)) setLabel(result, i, 10);
else if (c.equals(COL_DESCRIPTION)) result.setLabel(ctx.getDescription(), i);
else if (c.equals(COL_READBLE)) result.setLabel(bool(ctx.isReadable()), i);
else if (c.equals(COL_READ_ONCE)) result.setLabel(bool(ctx.isReadOnce()), i);
@@ -158,14 +122,48 @@ public class TCFNodeRegister extends TCFNode {
}
}
- private void setLabel(ILabelUpdate result, TCFDataCache<String> data, int pos) {
- Throwable error = data.getError();
+ private void setLabel(ILabelUpdate result, int col, int radix) {
+ IRegisters.RegistersContext ctx = context.getData();
+ Throwable error = value.getError();
+ byte[] data = value.getData();
if (error != null) {
- result.setForeground(new RGB(255, 0, 0), pos);
- result.setLabel(error.getClass().getName() + ": " + error.getMessage(), pos);
+ if (col >= 0) {
+ result.setForeground(new RGB(255, 0, 0), col);
+ result.setLabel(error.getMessage(), col);
+ }
+ else {
+ result.setLabel(ctx.getName() + ": " + error.getMessage(), 0);
+ }
}
- else if (data.getData() != null) {
- result.setLabel(data.getData(), pos);
+ else if (data != null) {
+ byte[] temp = new byte[data.length + 1];
+ temp[0] = 0; // Extra byte to avoid sign extension by BigInteger
+ if (ctx.isBigEndian()) {
+ System.arraycopy(value, 0, temp, 1, data.length);
+ }
+ else {
+ for (int i = 0; i < data.length; i++) {
+ temp[temp.length - i - 1] = data[i];
+ }
+ }
+ String s = new BigInteger(temp).toString(radix);
+ switch (radix) {
+ case 8:
+ if (!s.startsWith("0")) s = "0" + s;
+ break;
+ case 16:
+ int l = data.length * 2 - s.length();
+ if (l < 0) l = 0;
+ if (l > 16) l = 16;
+ s = "0000000000000000".substring(0, l) + s;
+ break;
+ }
+ if (col >= 0) {
+ result.setLabel(s, col);
+ }
+ else {
+ result.setLabel(ctx.getName() + " = " + s, 0);
+ }
}
}
@@ -174,29 +172,11 @@ public class TCFNodeRegister extends TCFNode {
}
private String getMnemonic(IRegisters.RegistersContext ctx) {
- if (dec_value.getData() != null) {
+ if (value.getData() != null) {
IRegisters.NamedValue[] arr = ctx.getNamedValues();
if (arr != null) {
- if (ctx.isFloat()) {
- double v = Double.parseDouble(dec_value.getData());
- for (IRegisters.NamedValue n : arr) {
- if (n.getValue().doubleValue() == v) return n.getName();
- }
- }
- else {
- long v = Long.parseLong(dec_value.getData());
- for (IRegisters.NamedValue n : arr) {
- if (n.getValue().longValue() == v) return n.getName();
- }
- }
- }
- }
- else if (!ctx.isFloat() && hex_value.getData() != null) {
- IRegisters.NamedValue[] arr = ctx.getNamedValues();
- if (arr != null) {
- long v = Long.parseLong(hex_value.getData(), 16);
for (IRegisters.NamedValue n : arr) {
- if (n.getValue().longValue() == v) return n.getName();
+ if (Arrays.equals(n.getValue(), value.getData())) return n.getName();
}
}
}
@@ -218,40 +198,29 @@ public class TCFNodeRegister extends TCFNode {
* Invalidate register value only, keep cached register attributes.
*/
void onSuspended() {
- hex_value.reset();
- dec_value.reset();
+ value.reset();
makeModelDelta(IModelDelta.STATE);
}
void onRegistersChanged() {
context.reset();
- hex_value.reset();
- dec_value.reset();
+ value.reset();
makeModelDelta(IModelDelta.STATE | IModelDelta.CONTENT);
}
@Override
public void invalidateNode() {
context.reset();
- hex_value.reset();
- dec_value.reset();
+ value.reset();
}
@Override
public boolean validateNode(Runnable done) {
- boolean ctx_valid = context.validate();
- boolean dec_valid = dec_value.validate();
- boolean hex_valid = hex_value.validate();
- if (!ctx_valid) {
- if (done != null) context.wait(done);
- return false;
- }
- if (!dec_valid) {
- if (done != null) dec_value.wait(done);
- return false;
- }
- if (!hex_valid) {
- if (done != null) hex_value.wait(done);
+ TCFDataCache<?> pending = null;
+ if (!context.validate()) pending = context;
+ if (!value.validate()) pending = value;
+ if (pending != null) {
+ pending.wait(done);
return false;
}
return true;

Back to the top