Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFChildren.java5
-rw-r--r--plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFChildrenExpressions.java58
-rw-r--r--plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFChildrenLocalVariables.java7
-rw-r--r--plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFChildrenSubExpressions.java95
-rw-r--r--plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFColumnPresentationExpression.java6
-rw-r--r--plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFColumnPresentationVariable.java82
-rw-r--r--plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFModel.java3
-rw-r--r--plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFNode.java6
-rw-r--r--plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFNodeExpression.java440
-rw-r--r--plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFNodeLocalVariable.java175
-rw-r--r--plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFNodeStackFrame.java34
-rw-r--r--plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/remote/ExpressionsProxy.java25
-rw-r--r--plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/remote/SymbolsProxy.java162
-rw-r--r--plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/services/IExpressions.java33
-rw-r--r--plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/services/ISymbols.java209
15 files changed, 898 insertions, 442 deletions
diff --git a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFChildren.java b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFChildren.java
index 993c934e4..75fe1c8b5 100644
--- a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFChildren.java
+++ b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFChildren.java
@@ -64,7 +64,10 @@ public abstract class TCFChildren extends TCFDataCache<Map<String,TCFNode>> {
private void addToPool(Map<String,TCFNode> data) {
assert !disposed;
- node_pool.putAll(data);
+ for (TCFNode n : data.values()) {
+ assert data.get(n.id) == n;
+ node_pool.put(n.id, n);
+ }
if (node_pool.size() > data.size() + pool_margin) {
String[] arr = node_pool.keySet().toArray(new String[node_pool.size()]);
for (String id : arr) {
diff --git a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFChildrenExpressions.java b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFChildrenExpressions.java
index 616fb2d4e..09c4f191e 100644
--- a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFChildrenExpressions.java
+++ b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFChildrenExpressions.java
@@ -7,17 +7,12 @@ import org.eclipse.debug.core.IExpressionManager;
import org.eclipse.debug.core.IExpressionsListener;
import org.eclipse.debug.core.model.IExpression;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelDelta;
-import org.eclipse.tm.internal.tcf.debug.ui.Activator;
-import org.eclipse.tm.tcf.protocol.IChannel;
-import org.eclipse.tm.tcf.protocol.IToken;
import org.eclipse.tm.tcf.protocol.Protocol;
import org.eclipse.tm.tcf.services.IExpressions;
public class TCFChildrenExpressions extends TCFChildren {
private final TCFNodeStackFrame node;
- private final HashMap<IExpression,TCFNodeExpression> map =
- new HashMap<IExpression,TCFNodeExpression>();
private final IExpressionsListener listener = new IExpressionsListener() {
@@ -47,26 +42,23 @@ public class TCFChildrenExpressions extends TCFChildren {
}
@Override
- void dispose(String id) {
+ void dispose() {
IExpressionManager m = DebugPlugin.getDefault().getExpressionManager();
m.removeExpressionListener(listener);
- TCFNode n = node.model.getNode(id);
- super.dispose(id);
- if (n instanceof TCFNodeExpression) {
- map.remove(((TCFNodeExpression)n).getExpression());
- }
- }
-
- void add(TCFNode n) {
- super.add(n);
- TCFNodeExpression e = (TCFNodeExpression)n;
- assert map.get(e.getExpression()) == null;
- map.put(e.getExpression(), e);
+ super.dispose();
}
void onSuspended() {
for (TCFNode n : getNodes()) ((TCFNodeExpression)n).onSuspended();
}
+
+ private TCFNodeExpression findScript(String text) {
+ for (TCFNode n : getNodes()) {
+ TCFNodeExpression e = (TCFNodeExpression)n;
+ if (text.equals(e.getScript())) return e;
+ }
+ return null;
+ }
@Override
protected boolean startDataRetrieval() {
@@ -78,32 +70,10 @@ public class TCFChildrenExpressions extends TCFChildren {
HashMap<String,TCFNode> data = new HashMap<String,TCFNode>();
IExpressionManager m = DebugPlugin.getDefault().getExpressionManager();
for (final IExpression e : m.getExpressions()) {
- TCFNodeExpression ne = map.get(e);
- if (ne == null) {
- assert command == null;
- command = exps.create(node.id, null, e.getExpressionText(), new IExpressions.DoneCreate() {
- public void doneCreate(IToken token, Exception error, IExpressions.Expression context) {
- if (isDisposed()) {
- IExpressions exps = channel.getRemoteService(IExpressions.class);
- exps.dispose(context.getID(), new IExpressions.DoneDispose() {
- public void doneDispose(IToken token, Exception error) {
- if (error == null) return;
- if (channel.getState() != IChannel.STATE_OPEN) return;
- Activator.log("Error disposing remote expression evaluator", error);
- }
- });
- return;
- }
- add(new TCFNodeExpression(node, error, e, context));
- if (command != token) return;
- command = null;
- run();
- }
- });
- return false;
- }
- assert ne.getExpression() == e;
- data.put(ne.id, ne);
+ String text = e.getExpressionText();
+ TCFNodeExpression n = findScript(text);
+ if (n == null) add(n = new TCFNodeExpression(node, text, null, null, -1));
+ data.put(n.id, n);
}
set(null, null, data);
return true;
diff --git a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFChildrenLocalVariables.java b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFChildrenLocalVariables.java
index d9a391528..f9ad6343b 100644
--- a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFChildrenLocalVariables.java
+++ b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFChildrenLocalVariables.java
@@ -26,7 +26,7 @@ public class TCFChildrenLocalVariables extends TCFChildren {
}
void onSuspended() {
- for (TCFNode n : getNodes()) ((TCFNodeLocalVariable)n).onSuspended();
+ for (TCFNode n : getNodes()) ((TCFNodeExpression)n).onSuspended();
reset();
}
@@ -45,9 +45,10 @@ public class TCFChildrenLocalVariables extends TCFChildren {
data = new HashMap<String,TCFNode>();
for (String id : contexts) {
TCFNode n = node.model.getNode(id);
- if (n == null) n = new TCFNodeLocalVariable(node, id);
+ if (n == null) n = new TCFNodeExpression(node, null, null, id, -1);
+ assert n.id.equals(id);
assert n.parent == node;
- data.put(id, n);
+ data.put(n.id, n);
}
}
set(token, error, data);
diff --git a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFChildrenSubExpressions.java b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFChildrenSubExpressions.java
new file mode 100644
index 000000000..4f7d7de54
--- /dev/null
+++ b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFChildrenSubExpressions.java
@@ -0,0 +1,95 @@
+package org.eclipse.tm.internal.tcf.debug.ui.model;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.tm.tcf.protocol.IToken;
+import org.eclipse.tm.tcf.services.ISymbols;
+import org.eclipse.tm.tcf.util.TCFDataCache;
+
+public class TCFChildrenSubExpressions extends TCFChildren {
+
+ private final TCFNodeExpression node;
+
+ TCFChildrenSubExpressions(final TCFNodeExpression node) {
+ super(node.model.getLaunch().getChannel(), 64);
+ this.node = node;
+ }
+
+ void onSuspended() {
+ for (TCFNode n : getNodes()) ((TCFNodeExpression)n).onSuspended();
+ }
+
+ private TCFNodeExpression findField(String id) {
+ assert id != null;
+ for (TCFNode n : getNodes()) {
+ TCFNodeExpression e = (TCFNodeExpression)n;
+ if (id.equals(e.getFieldID())) return e;
+ }
+ return null;
+ }
+
+ private TCFNodeExpression findIndex(int index) {
+ assert index >= 0;
+ for (TCFNode n : getNodes()) {
+ TCFNodeExpression e = (TCFNodeExpression)n;
+ if (e.getIndex() == index) return e;
+ }
+ return null;
+ }
+
+ @Override
+ protected boolean startDataRetrieval() {
+ assert !isDisposed();
+ final TCFDataCache<ISymbols.Symbol> type = node.getType();
+ if (!type.validate()) {
+ type.wait(this);
+ return false;
+ }
+ final ISymbols syms = node.model.getLaunch().getService(ISymbols.class);
+ final ISymbols.Symbol type_sym = type.getData();
+ if (syms == null || type_sym == null) {
+ set(null, null, new HashMap<String,TCFNode>());
+ return true;
+ }
+ ISymbols.TypeClass type_class = type_sym.getTypeClass();
+ if (type_class == ISymbols.TypeClass.composite) {
+ command = syms.getChildren(type_sym.getID(), new ISymbols.DoneGetChildren() {
+ public void doneGetChildren(IToken token, Exception error, String[] contexts) {
+ Map<String,TCFNode> data = null;
+ if (command == token && error == null) {
+ data = new HashMap<String,TCFNode>();
+ for (String id : contexts) {
+ TCFNodeExpression n = findField(id);
+ if (n == null) n = new TCFNodeExpression(node, null, id, null, -1);
+ data.put(n.id, n);
+ }
+ }
+ set(token, error, data);
+ }
+ });
+ return false;
+ }
+ if (type_class == ISymbols.TypeClass.array) {
+ Map<String,TCFNode> data = new HashMap<String,TCFNode>();
+ int length = type_sym.getLength();
+ for (int i = 0; i < length && i < 16; i++) {
+ TCFNodeExpression n = findIndex(i);
+ if (n == null) n = new TCFNodeExpression(node, null, null, null, i);
+ data.put(n.id, n);
+ }
+ set(null, null, data);
+ return true;
+ }
+ if (type_class == ISymbols.TypeClass.pointer) {
+ Map<String,TCFNode> data = new HashMap<String,TCFNode>();
+ TCFNodeExpression n = findIndex(0);
+ if (n == null) n = new TCFNodeExpression(node, null, null, null, 0);
+ data.put(n.id, n);
+ set(null, null, data);
+ return true;
+ }
+ set(null, null, new HashMap<String,TCFNode>());
+ return true;
+ }
+}
diff --git a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFColumnPresentationExpression.java b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFColumnPresentationExpression.java
index 7f966f269..88c102a66 100644
--- a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFColumnPresentationExpression.java
+++ b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFColumnPresentationExpression.java
@@ -12,21 +12,21 @@ public class TCFColumnPresentationExpression implements IColumnPresentation {
* Presentation column IDs.
*/
public static final String
- COL_TYPE = "Type",
COL_NAME = "Name",
+ COL_TYPE = "Type",
COL_HEX_VALUE = "HexValue",
COL_DEC_VALUE = "DecValue";
private static String[] cols_all = {
- COL_TYPE,
COL_NAME,
+ COL_TYPE,
COL_DEC_VALUE,
COL_HEX_VALUE,
};
private static String[] headers = {
- "Type",
"Name",
+ "Type",
"Decimal",
"Hex",
};
diff --git a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFColumnPresentationVariable.java b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFColumnPresentationVariable.java
deleted file mode 100644
index 7e92bc7be..000000000
--- a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFColumnPresentationVariable.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Wind River Systems, Inc. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tm.internal.tcf.debug.ui.model;
-
-import org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnPresentation;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
-import org.eclipse.jface.resource.ImageDescriptor;
-
-public class TCFColumnPresentationVariable implements IColumnPresentation {
-
- public static final String PRESENTATION_ID = "Variables";
-
- /**
- * Presentation column IDs.
- */
- public static final String
- COL_TYPE = "Type",
- COL_NAME = "Name",
- COL_HEX_VALUE = "HexValue",
- COL_DEC_VALUE = "DecValue";
-
- private static String[] cols_all = {
- COL_TYPE,
- COL_NAME,
- COL_DEC_VALUE,
- COL_HEX_VALUE,
- };
-
- private static String[] headers = {
- "Type",
- "Name",
- "Decimal",
- "Hex",
- };
-
- private static String[] cols_ini = {
- COL_NAME,
- COL_DEC_VALUE,
- COL_HEX_VALUE,
- };
-
- public void dispose() {
- }
-
- public String[] getAvailableColumns() {
- return cols_all;
- }
-
- public String getHeader(String id) {
- for (int i = 0; i < cols_all.length; i++) {
- if (id.equals(cols_all[i])) return headers[i];
- }
- return null;
- }
-
- public String getId() {
- return PRESENTATION_ID;
- }
-
- public ImageDescriptor getImageDescriptor(String id) {
- return null;
- }
-
- public String[] getInitialColumns() {
- return cols_ini;
- }
-
- public void init(IPresentationContext context) {
- }
-
- public boolean isOptional() {
- return false;
- }
-}
diff --git a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFModel.java b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFModel.java
index d18aac74d..d49c91b12 100644
--- a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFModel.java
+++ b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFModel.java
@@ -495,7 +495,6 @@ public class TCFModel implements IElementContentProvider, IElementLabelProvider,
String id = getColumnPresentationId(context, element);
if (id == null) return null;
if (id.equals(TCFColumnPresentationRegister.PRESENTATION_ID)) return new TCFColumnPresentationRegister();
- if (id.equals(TCFColumnPresentationVariable.PRESENTATION_ID)) return new TCFColumnPresentationVariable();
if (id.equals(TCFColumnPresentationExpression.PRESENTATION_ID)) return new TCFColumnPresentationExpression();
return null;
}
@@ -505,7 +504,7 @@ public class TCFModel implements IElementContentProvider, IElementLabelProvider,
return TCFColumnPresentationRegister.PRESENTATION_ID;
}
if (IDebugUIConstants.ID_VARIABLE_VIEW.equals(context.getId())) {
- return TCFColumnPresentationVariable.PRESENTATION_ID;
+ return TCFColumnPresentationExpression.PRESENTATION_ID;
}
if (IDebugUIConstants.ID_EXPRESSION_VIEW.equals(context.getId())) {
return TCFColumnPresentationExpression.PRESENTATION_ID;
diff --git a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFNode.java b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFNode.java
index f043dd150..0a4a42067 100644
--- a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFNode.java
+++ b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFNode.java
@@ -63,6 +63,7 @@ public abstract class TCFNode extends PlatformObject implements Comparable<TCFNo
assert Protocol.isDispatchThread();
assert parent != null;
assert id != null;
+ assert !parent.disposed;
this.parent = parent;
this.id = id;
model = parent.model;
@@ -77,7 +78,10 @@ public abstract class TCFNode extends PlatformObject implements Comparable<TCFNo
assert !disposed;
if (parent != null) parent.dispose(id);
invalidateNode();
- if (id != null) model.removeNode(id);
+ if (id != null) {
+ assert model.getNode(id) == this;
+ model.removeNode(id);
+ }
disposed = true;
}
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 8e6dcbde8..5d2c0f43a 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
@@ -2,7 +2,9 @@ package org.eclipse.tm.internal.tcf.debug.ui.model;
import java.math.BigInteger;
-import org.eclipse.debug.core.model.IExpression;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IChildrenCountUpdate;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IChildrenUpdate;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IHasChildrenUpdate;
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;
@@ -13,29 +15,169 @@ 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.services.IExpressions;
+import org.eclipse.tm.tcf.services.ISymbols;
import org.eclipse.tm.tcf.util.TCFDataCache;
public class TCFNodeExpression extends TCFNode {
- private final Exception error;
- private final IExpression local_expression;
- private final IExpressions.Expression remote_expression;
+ private final String script;
+ private final String field_id;
+ private final String var_id;
+ private final int index;
+ private final TCFDataCache<ISymbols.Symbol> field;
+ private final TCFDataCache<String> text;
+ private final TCFDataCache<IExpressions.Expression> expression;
private final TCFDataCache<IExpressions.Value> value;
+ private final TCFDataCache<ISymbols.Symbol> type;
+ private final TCFChildrenSubExpressions children;
private static int expr_cnt;
- TCFNodeExpression(TCFNode parent, Exception error,
- IExpression local_expression, IExpressions.Expression remote_expression) {
- super(parent, remote_expression == null ? "Expr" + expr_cnt++ : remote_expression.getID());
- this.error = error;
- this.local_expression = local_expression;
- this.remote_expression = remote_expression;
+ TCFNodeExpression(final TCFNode parent, final String script, final String field_id, final String var_id, final int index) {
+ super(parent, var_id != null ? var_id : "Expr" + expr_cnt++);
+ assert script != null || field_id != null || var_id != null || index >= 0;
+ this.script = script;
+ this.field_id = field_id;
+ this.var_id = var_id;
+ this.index = index;
IChannel channel = model.getLaunch().getChannel();
+ field = new TCFDataCache<ISymbols.Symbol>(channel) {
+ @Override
+ protected boolean startDataRetrieval() {
+ ISymbols syms = model.getLaunch().getService(ISymbols.class);
+ if (field_id == null || syms == null) {
+ set(null, null, null);
+ return true;
+ }
+ command = syms.getContext(field_id, new ISymbols.DoneGetContext() {
+ public void doneGetContext(IToken token, Exception error, ISymbols.Symbol sym) {
+ set(token, error, sym);
+ }
+ });
+ return false;
+ }
+ };
+ text = new TCFDataCache<String>(channel) {
+ @Override
+ protected boolean startDataRetrieval() {
+ if (script != null) {
+ set(null, null, script);
+ return true;
+ }
+ if (var_id != null) {
+ if (!expression.validate()) {
+ expression.wait(this);
+ return false;
+ }
+ if (expression.getData() == null) {
+ set(null, expression.getError(), null);
+ return true;
+ }
+ String e = expression.getData().getExpression();
+ if (e == null) {
+ set(null, new Exception("Missing 'Expression' property"), null);
+ return true;
+ }
+ set(null, null, e);
+ return true;
+ }
+ TCFDataCache<String> t = ((TCFNodeExpression)parent).getExpressionText();
+ if (!t.validate()) {
+ t.wait(this);
+ return false;
+ }
+ String e = t.getData();
+ if (e == null) {
+ set(null, t.getError(), null);
+ return true;
+ }
+ if (field_id != null) {
+ if (!field.validate()) {
+ field.wait(this);
+ return false;
+ }
+ if (field.getData() == null) {
+ set(null, field.getError(), null);
+ return true;
+ }
+ String name = field.getData().getName();
+ if (name == null) {
+ set(null, new Exception("Field nas no name"), null);
+ return true;
+ }
+ e = "(" + e + ")." + name;
+ }
+ else if (index == 0) {
+ e = "*(" + e + ")";
+ }
+ else if (index > 0) {
+ e = "(" + e + ")[" + index + "]";
+ }
+ set(null, null, e);
+ return true;
+ }
+ };
+ expression = new TCFDataCache<IExpressions.Expression>(channel) {
+ @Override
+ protected boolean startDataRetrieval() {
+ IExpressions exps = model.getLaunch().getService(IExpressions.class);
+ if (exps == null) {
+ set(null, null, null);
+ return true;
+ }
+ if (var_id != null) {
+ command = exps.getContext(var_id, new IExpressions.DoneGetContext() {
+ public void doneGetContext(IToken token, Exception error, IExpressions.Expression context) {
+ set(token, error, context);
+ }
+ });
+ }
+ else {
+ if (!text.validate()) {
+ text.wait(this);
+ return false;
+ }
+ String e = text.getData();
+ if (e == null) {
+ set(null, text.getError(), null);
+ return true;
+ }
+ TCFNode n = parent;
+ while (n instanceof TCFNodeExpression) n = n.parent;
+ command = exps.create(n.id, null, e, new IExpressions.DoneCreate() {
+ public void doneCreate(IToken token, Exception error, IExpressions.Expression context) {
+ if (isDisposed()) {
+ IExpressions exps = channel.getRemoteService(IExpressions.class);
+ exps.dispose(context.getID(), new IExpressions.DoneDispose() {
+ public void doneDispose(IToken token, Exception error) {
+ if (error == null) return;
+ if (channel.getState() != IChannel.STATE_OPEN) return;
+ Activator.log("Error disposing remote expression evaluator", error);
+ }
+ });
+ return;
+ }
+ set(token, error, context);
+ }
+ });
+ }
+ return false;
+ }
+ };
value = new TCFDataCache<IExpressions.Value>(channel) {
@Override
protected boolean startDataRetrieval() {
+ if (!expression.validate()) {
+ expression.wait(this);
+ return false;
+ }
+ final IExpressions.Expression ctx = expression.getData();
+ if (ctx == null) {
+ set(null, null, null);
+ return true;
+ }
IExpressions exps = model.getLaunch().getService(IExpressions.class);
- command = exps.evaluate(id, new IExpressions.DoneEvaluate() {
+ command = exps.evaluate(ctx.getID(), new IExpressions.DoneEvaluate() {
public void doneEvaluate(IToken token, Exception error, IExpressions.Value value) {
set(token, error, value);
}
@@ -43,97 +185,227 @@ public class TCFNodeExpression extends TCFNode {
return false;
}
};
+ type = new TCFDataCache<ISymbols.Symbol>(channel) {
+ @Override
+ protected boolean startDataRetrieval() {
+ if (!value.validate()) {
+ value.wait(this);
+ return false;
+ }
+ String id = null;
+ if (value.getData() != null) id = value.getData().getTypeID();
+ ISymbols syms = model.getLaunch().getService(ISymbols.class);
+ if (id == null || syms == null) {
+ set(null, null, null);
+ return true;
+ }
+ command = syms.getContext(id, new ISymbols.DoneGetContext() {
+ public void doneGetContext(IToken token, Exception error, ISymbols.Symbol sym) {
+ set(token, error, sym);
+ }
+ });
+ return false;
+ }
+ };
+ children = new TCFChildrenSubExpressions(this);
}
@Override
void dispose() {
+ children.dispose();
super.dispose();
+ if (!expression.isValid() || expression.getData() == null) return;
final IChannel channel = model.getLaunch().getChannel();
if (channel.getState() != IChannel.STATE_OPEN) return;
IExpressions exps = channel.getRemoteService(IExpressions.class);
- if (exps != null) {
- exps.dispose(id, new IExpressions.DoneDispose() {
- public void doneDispose(IToken token, Exception error) {
- if (error == null) return;
- if (channel.getState() != IChannel.STATE_OPEN) return;
- Activator.log("Error disposing remote expression evaluator", error);
- }
- });
- }
+ exps.dispose(expression.getData().getID(), new IExpressions.DoneDispose() {
+ public void doneDispose(IToken token, Exception error) {
+ if (error == null) return;
+ if (channel.getState() != IChannel.STATE_OPEN) return;
+ Activator.log("Error disposing remote expression evaluator", error);
+ }
+ });
+ }
+
+ @Override
+ void dispose(String id) {
+ children.dispose(id);
}
void onSuspended() {
value.reset();
- addModelDelta(IModelDelta.STATE);
+ type.reset();
+ children.reset();
+ children.onSuspended();
+ addModelDelta(IModelDelta.STATE | IModelDelta.CONTENT);
}
- IExpression getExpression() {
- return local_expression;
+ String getScript() {
+ return script;
}
- private void setLabel(ILabelUpdate result, int col, int radix) {
- Throwable error = value.getError();
- IExpressions.Value val = value.getData();
- byte[] data = val.getValue();
- if (error != null) {
- result.setForeground(new RGB(255, 0, 0), col);
- result.setLabel(local_expression.getExpressionText() + ": " + error.getMessage(), col);
+ String getFieldID() {
+ return field_id;
+ }
+
+ int getIndex() {
+ return index;
+ }
+
+ TCFDataCache<String> getExpressionText() {
+ return text;
+ }
+
+ TCFDataCache<IExpressions.Value> getValue() {
+ return value;
+ }
+
+ TCFDataCache<ISymbols.Symbol> getType() {
+ return type;
+ }
+
+ private BigInteger toBigInteger(byte[] data, boolean big_endian, boolean sign_extension) {
+ byte[] temp = null;
+ if (sign_extension) {
+ temp = new byte[data.length];
}
- else if (data != null) {
- byte[] temp = new byte[data.length + 1];
+ else {
+ temp = new byte[data.length + 1];
temp[0] = 0; // Extra byte to avoid sign extension by BigInteger
- if (val.isBigEndian()) {
- System.arraycopy(data, 0, temp, 1, data.length);
+ }
+ if (big_endian) {
+ System.arraycopy(data, 0, temp, sign_extension ? 0 : 1, data.length);
+ }
+ else {
+ for (int i = 0; i < data.length; i++) {
+ temp[temp.length - i - 1] = data[i];
}
- else {
- for (int i = 0; i < data.length; i++) {
- temp[temp.length - i - 1] = data[i];
+ }
+ return new BigInteger(temp);
+ }
+
+ private void setLabel(ILabelUpdate result, String name, int col, int radix) {
+ String s = null;
+ IExpressions.Value val = value.getData();
+ if (val != null) {
+ byte[] data = val.getValue();
+ if (data == null) s = "n/a";
+ if (s == null && data.length == 0) s = "";
+ if (s == null && radix == 10 && data.length <= 16) {
+ ISymbols.Symbol t = type.getData();
+ if (t != null) {
+ switch (t.getTypeClass()) {
+ case integer:
+ s = toBigInteger(data, val.isBigEndian(), true).toString();
+ break;
+ case real:
+ switch (t.getSize()) {
+ case 4:
+ s = Float.toString(Float.intBitsToFloat(toBigInteger(
+ data, val.isBigEndian(), true).intValue()));
+ break;
+ case 8:
+ s = Double.toString(Double.longBitsToDouble(toBigInteger(
+ data, val.isBigEndian(), true).longValue()));
+ break;
+ }
+ break;
+ }
}
}
- 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(remote_expression.getName() + " = " + s, 0);
+ if (s == null && data.length <= 16) {
+ s = toBigInteger(data, val.isBigEndian(), false).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 (s == null) s = "...";
+ if (name == null) {
+ result.setLabel(s, col);
+ }
+ else {
+ result.setLabel(name + " = " + s, col);
+ }
}
+ private void setTypeLabel(ILabelUpdate result, int col) {
+ String s = null;
+ ISymbols.Symbol t = type.getData();
+ if (t != null) {
+ s = t.getName();
+ if (s == null) {
+ switch (t.getTypeClass()) {
+ case integer:
+ s = "<Integer>";
+ break;
+ case cardinal:
+ s = "<Unsigned>";
+ break;
+ case real:
+ s = "<Float>";
+ break;
+ case pointer:
+ s = "<Pointer>";
+ break;
+ case array:
+ s = "<Array>";
+ break;
+ case composite:
+ s = "<Structure>";
+ break;
+ case function:
+ s = "<Function>";
+ break;
+ }
+ }
+ }
+ if (s == null) s = "";
+ result.setLabel(s, col);
+ }
+
@Override
protected void getData(ILabelUpdate result) {
result.setImageDescriptor(ImageCache.getImageDescriptor(getImageName()), 0);
+ String name = null;
+ if (script != null) name = script;
+ if (name == null && index >= 0) name = "[" + index + "]";
+ if (name == null && field_id != null && field.getData() != null) name = field.getData().getName();
+ if (name == null && var_id != null && expression.getData() != null) name = expression.getData().getExpression();
+ Throwable error = expression.getError();
+ if (error == null) error = value.getError();
+ if (error == null) error = type.getError();
if (error != null) {
result.setForeground(new RGB(255, 0, 0), 0);
- result.setLabel(local_expression.getExpressionText() + ": " + error.getMessage(), 0);
+ result.setLabel(name + ": " + error.getMessage(), 0);
}
else {
String[] cols = result.getColumnIds();
if (cols == null) {
- setLabel(result, -1, 16);
+ setLabel(result, name, 0, 16);
}
else {
for (int i = 0; i < cols.length; i++) {
String c = cols[i];
if (c.equals(TCFColumnPresentationExpression.COL_NAME)) {
- result.setLabel(remote_expression.getExpression(), i);
+ result.setLabel(name, i);
+ }
+ else if (c.equals(TCFColumnPresentationExpression.COL_TYPE)) {
+ setTypeLabel(result, i);
}
else if (c.equals(TCFColumnPresentationExpression.COL_HEX_VALUE)) {
- setLabel(result, i, 16);
+ setLabel(result, null, i, 16);
}
else if (c.equals(TCFColumnPresentationExpression.COL_DEC_VALUE)) {
- setLabel(result, i, 10);
+ setLabel(result, null, i, 10);
}
}
}
@@ -141,24 +413,60 @@ public class TCFNodeExpression extends TCFNode {
}
@Override
+ protected void getData(IChildrenCountUpdate result) {
+ result.setChildCount(children.size());
+ }
+
+ @Override
+ protected void getData(IChildrenUpdate result) {
+ TCFNode[] arr = children.toArray();
+ int offset = 0;
+ int r_offset = result.getOffset();
+ int r_length = result.getLength();
+ for (TCFNode n : arr) {
+ if (offset >= r_offset && offset < r_offset + r_length) {
+ result.setChild(n, offset);
+ }
+ offset++;
+ }
+ }
+
+ @Override
+ protected void getData(IHasChildrenUpdate result) {
+ result.setHasChilren(children.size() > 0);
+ }
+
+ @Override
int getRelevantModelDeltaFlags(IPresentationContext p) {
- if (IDebugUIConstants.ID_EXPRESSION_VIEW.equals(p.getId())) {
+ if (IDebugUIConstants.ID_EXPRESSION_VIEW.equals(p.getId()) ||
+ IDebugUIConstants.ID_VARIABLE_VIEW.equals(p.getId())) {
return super.getRelevantModelDeltaFlags(p);
}
return 0;
}
-
+
@Override
public void invalidateNode() {
value.reset();
+ type.reset();
+ children.reset();
}
@Override
public boolean validateNode(Runnable done) {
- if (!value.validate()) {
- value.wait(done);
- return false;
- }
- return true;
+ TCFDataCache<?> pending = null;
+ if (!field.validate()) pending = field;
+ if (!expression.validate()) pending = expression;
+ if (!value.validate()) pending = value;
+ if (!type.validate()) pending = type;
+ if (!children.validate()) pending = children;
+ if (pending == null) return true;
+ pending.wait(done);
+ return false;
+ }
+
+ @Override
+ protected String getImageName() {
+ return ImageCache.IMG_VARIABLE;
}
}
diff --git a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFNodeLocalVariable.java b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFNodeLocalVariable.java
deleted file mode 100644
index 817ea2284..000000000
--- a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFNodeLocalVariable.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Wind River Systems, Inc. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tm.internal.tcf.debug.ui.model;
-
-import java.math.BigInteger;
-
-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;
-import org.eclipse.debug.ui.IDebugUIConstants;
-import org.eclipse.swt.graphics.RGB;
-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.services.IExpressions;
-import org.eclipse.tm.tcf.util.TCFDataCache;
-
-public class TCFNodeLocalVariable extends TCFNode {
-
- private final TCFDataCache<IExpressions.Expression> context;
- private final TCFDataCache<IExpressions.Value> value;
-
- TCFNodeLocalVariable(TCFNode parent, final String id) {
- super(parent, id);
- IChannel channel = model.getLaunch().getChannel();
- context = new TCFDataCache<IExpressions.Expression>(channel) {
- @Override
- protected boolean startDataRetrieval() {
- IExpressions exps = model.getLaunch().getService(IExpressions.class);
- command = exps.getContext(id, new IExpressions.DoneGetContext() {
- public void doneGetContext(IToken token, Exception error, IExpressions.Expression context) {
- set(token, error, context);
- }
- });
- return false;
- }
- };
- value = new TCFDataCache<IExpressions.Value>(channel) {
- @Override
- protected boolean startDataRetrieval() {
- IExpressions exps = model.getLaunch().getService(IExpressions.class);
- command = exps.evaluate(id, new IExpressions.DoneEvaluate() {
- public void doneEvaluate(IToken token, Exception error, IExpressions.Value value) {
- set(token, error, value);
- }
- });
- return false;
- }
- };
- }
-
- void onSuspended() {
- value.reset();
- addModelDelta(IModelDelta.STATE);
- }
-
- private void setLabel(ILabelUpdate result, int col, int radix) {
- IExpressions.Expression ctx = context.getData();
- Throwable error = value.getError();
- IExpressions.Value val = value.getData();
- byte[] data = val.getValue();
- if (error != null) {
- 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 != null) {
- byte[] temp = new byte[data.length + 1];
- temp[0] = 0; // Extra byte to avoid sign extension by BigInteger
- if (val.isBigEndian()) {
- System.arraycopy(data, 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);
- }
- }
- }
-
- @Override
- protected void getData(ILabelUpdate result) {
- result.setImageDescriptor(ImageCache.getImageDescriptor(getImageName()), 0);
- IExpressions.Expression ctx = context.getData();
- Throwable error = context.getError();
- if (error != null) {
- result.setForeground(new RGB(255, 0, 0), 0);
- result.setLabel(id + ": " + error.getClass().getName() + ": " + error.getMessage(), 0);
- }
- else if (ctx != null) {
- String[] cols = result.getColumnIds();
- if (cols == null) {
- setLabel(result, -1, 16);
- }
- else {
- for (int i = 0; i < cols.length; i++) {
- String c = cols[i];
- if (c.equals(TCFColumnPresentationVariable.COL_NAME)) {
- result.setLabel(ctx.getName(), i);
- }
- else if (c.equals(TCFColumnPresentationVariable.COL_HEX_VALUE)) {
- setLabel(result, i, 16);
- }
- else if (c.equals(TCFColumnPresentationVariable.COL_DEC_VALUE)) {
- setLabel(result, i, 10);
- }
- }
- }
- }
- else {
- result.setLabel(id, 0);
- }
- }
-
- @Override
- int getRelevantModelDeltaFlags(IPresentationContext p) {
- if (IDebugUIConstants.ID_VARIABLE_VIEW.equals(p.getId())) {
- return super.getRelevantModelDeltaFlags(p);
- }
- return 0;
- }
-
- @Override
- public void invalidateNode() {
- context.reset();
- value.reset();
- }
-
- @Override
- public boolean validateNode(Runnable done) {
- TCFDataCache<?> pending = null;
- if (!context.validate()) pending = context;
- if (!value.validate()) pending = value;
- if (pending != null) {
- pending.wait(done);
- return false;
- }
- return true;
- }
-
- @Override
- protected String getImageName() {
- return ImageCache.IMG_VARIABLE;
- }
-}
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 f93f0e37d..f93d76bef 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
@@ -334,31 +334,15 @@ public class TCFNodeStackFrame extends TCFNode {
@Override
public boolean validateNode(Runnable done) {
- stack_trace_context.validate();
- children_regs.validate();
- children_vars.validate();
- children_exps.validate();
- if (!stack_trace_context.isValid()) {
- stack_trace_context.wait(done);
- return false;
- }
- if (!children_regs.isValid()) {
- children_regs.wait(done);
- return false;
- }
- if (!children_vars.isValid()) {
- children_vars.wait(done);
- return false;
- }
- if (!children_exps.isValid()) {
- children_exps.wait(done);
- return false;
- }
- if (!line_info.validate()) {
- line_info.wait(done);
- return false;
- }
- return true;
+ TCFDataCache<?> pending = null;
+ if (!stack_trace_context.validate()) pending = stack_trace_context;
+ if (!children_regs.validate()) pending = children_regs;
+ if (!children_vars.validate()) pending = children_vars;
+ if (!children_exps.validate()) pending = children_exps;
+ if (!line_info.validate()) pending = line_info;
+ if (pending == null) return true;
+ pending.wait(done);
+ return false;
}
@Override
diff --git a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/remote/ExpressionsProxy.java b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/remote/ExpressionsProxy.java
index 72e757aa0..5d1a2f98c 100644
--- a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/remote/ExpressionsProxy.java
+++ b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/remote/ExpressionsProxy.java
@@ -21,6 +21,7 @@ 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.services.IExpressions;
+import org.eclipse.tm.tcf.services.ISymbols.TypeClass;;
public class ExpressionsProxy implements IExpressions {
@@ -60,10 +61,6 @@ public class ExpressionsProxy implements IExpressions {
return (String)props.get(PROP_LANGUAGE);
}
- public String getName() {
- return (String)props.get(PROP_NAME);
- }
-
public String getParentID() {
return (String)props.get(PROP_PARENT_ID);
}
@@ -106,21 +103,21 @@ public class ExpressionsProxy implements IExpressions {
return value;
}
- public ValueClass getValueClass() {
+ public TypeClass getTypeClass() {
Number n = (Number)props.get(PROP_SIZE);
if (n != null) {
switch (n.intValue()) {
- case 1: return ValueClass.cardinal;
- case 2: return ValueClass.integer;
- case 3: return ValueClass.real;
- case 4: return ValueClass.pointer;
- case 5: return ValueClass.array;
- case 6: return ValueClass.composite;
- case 7: return ValueClass.enumeration;
- case 8: return ValueClass.function;
+ case 1: return TypeClass.cardinal;
+ case 2: return TypeClass.integer;
+ case 3: return TypeClass.real;
+ case 4: return TypeClass.pointer;
+ case 5: return TypeClass.array;
+ case 6: return TypeClass.composite;
+ case 7: return TypeClass.enumeration;
+ case 8: return TypeClass.function;
}
}
- return ValueClass.unknown;
+ return TypeClass.unknown;
}
public boolean isBigEndian() {
diff --git a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/remote/SymbolsProxy.java b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/remote/SymbolsProxy.java
new file mode 100644
index 000000000..b211887ac
--- /dev/null
+++ b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/internal/tcf/services/remote/SymbolsProxy.java
@@ -0,0 +1,162 @@
+package org.eclipse.tm.internal.tcf.services.remote;
+
+import java.util.Collection;
+import java.util.Map;
+
+import org.eclipse.tm.tcf.core.Base64;
+import org.eclipse.tm.tcf.core.Command;
+import org.eclipse.tm.tcf.protocol.IChannel;
+import org.eclipse.tm.tcf.protocol.IToken;
+import org.eclipse.tm.tcf.services.ISymbols;
+
+public class SymbolsProxy implements ISymbols {
+
+ private final IChannel channel;
+
+ private class Context implements Symbol {
+
+ private final byte[] value;
+ private final Map<String,Object> props;
+
+ Context(Map<String,Object> props) {
+ this.props = props;
+ String s = (String)props.get(PROP_VALUE);
+ if (s == null) {
+ value = null;
+ }
+ else {
+ value = Base64.toByteArray(s.toCharArray());
+ }
+ }
+
+ public Number getAddress() {
+ return (Number)props.get(PROP_ADDRESS);
+ }
+
+ public String getBaseTypeID() {
+ return (String)props.get(PROP_BASE_TYPE_ID);
+ }
+
+ public String getExeContextID() {
+ return (String)props.get(PROP_EXE_ID);
+ }
+
+ public String getID() {
+ return (String)props.get(PROP_ID);
+ }
+
+ public String getIndexTypeID() {
+ return (String)props.get(PROP_INDEX_TYPE_ID);
+ }
+
+ public int getLength() {
+ Number n = (Number)props.get(PROP_LENGTH);
+ if (n == null) return 0;
+ return n.intValue();
+ }
+
+ public String getName() {
+ return (String)props.get(PROP_NAME);
+ }
+
+ public int getOffset() {
+ Number n = (Number)props.get(PROP_OFFSET);
+ if (n == null) return 0;
+ return n.intValue();
+ }
+
+ public Map<String,Object> getProperties() {
+ return props;
+ }
+
+ public int getSize() {
+ Number n = (Number)props.get(PROP_SIZE);
+ if (n == null) return 0;
+ return n.intValue();
+ }
+
+ public SymbolClass getSymbolClass() {
+ Number n = (Number)props.get(PROP_SYMBOL_CLASS);
+ if (n != null) {
+ switch (n.intValue()) {
+ case 1: return SymbolClass.value;
+ case 2: return SymbolClass.reference;
+ case 3: return SymbolClass.function;
+ case 4: return SymbolClass.type;
+ }
+ }
+ return SymbolClass.unknown;
+ }
+
+ public TypeClass getTypeClass() {
+ Number n = (Number)props.get(PROP_TYPE_CLASS);
+ if (n != null) {
+ switch (n.intValue()) {
+ case 1: return TypeClass.cardinal;
+ case 2: return TypeClass.integer;
+ case 3: return TypeClass.real;
+ case 4: return TypeClass.pointer;
+ case 5: return TypeClass.array;
+ case 6: return TypeClass.composite;
+ case 7: return TypeClass.enumeration;
+ case 8: return TypeClass.function;
+ }
+ }
+ return TypeClass.unknown;
+ }
+
+ public String getTypeID() {
+ return (String)props.get(PROP_TYPE_ID);
+ }
+
+ public byte[] getValue() {
+ return value;
+ }
+ }
+
+ public SymbolsProxy(IChannel channel) {
+ this.channel = channel;
+ }
+
+ public String getName() {
+ return NAME;
+ }
+
+ public IToken getContext(String id, final DoneGetContext done) {
+ return new Command(channel, this, "getContext", new Object[]{ id }) {
+ @SuppressWarnings("unchecked")
+ @Override
+ public void done(Exception error, Object[] args) {
+ Context ctx = null;
+ if (error == null) {
+ assert args.length == 2;
+ error = toError(args[0]);
+ if (args[1] != null) ctx = new Context((Map<String,Object>)args[1]);
+ }
+ done.doneGetContext(token, error, ctx);
+ }
+ }.token;
+ }
+
+ public IToken getChildren(String parent_context_id, final DoneGetChildren done) {
+ return new Command(channel, this, "getChildren", new Object[]{ parent_context_id }) {
+ @Override
+ public void done(Exception error, Object[] args) {
+ String[] lst = null;
+ if (error == null) {
+ assert args.length == 2;
+ error = toError(args[0]);
+ lst = toStringArray(args[1]);
+ }
+ done.doneGetChildren(token, error, lst);
+ }
+ }.token;
+ }
+
+ @SuppressWarnings("unchecked")
+ private String[] toStringArray(Object o) {
+ if (o == null) return null;
+ Collection<String> c = (Collection<String>)o;
+ return (String[])c.toArray(new String[c.size()]);
+ }
+}
diff --git a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/services/IExpressions.java b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/services/IExpressions.java
index 03493ce98..dfa5f1064 100644
--- a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/services/IExpressions.java
+++ b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/services/IExpressions.java
@@ -45,14 +45,7 @@ public interface IExpressions extends IService {
* @return parent context ID.
*/
String getParentID();
-
- /**
- * Get context name.
- * Variable, field and enumerator get their names from source code.
- * @return context name or null if unknown.
- */
- String getName();
-
+
/**
* Get expression script language ID.
* @return language ID.
@@ -106,7 +99,6 @@ public interface IExpressions extends IService {
static final String
PROP_ID = "ID",
PROP_PARENT_ID = "ParentID",
- PROP_NAME = "Name",
PROP_LANGUAGE = "Language",
PROP_EXPRESSION = "Expression",
PROP_BITS = "Bits",
@@ -121,11 +113,11 @@ public interface IExpressions extends IService {
interface Value {
/**
- * get value class.
- * @see ValueClass
+ * Get value type class.
+ * @see ISymbols.TypeClass
* @return
*/
- ValueClass getValueClass();
+ ISymbols.TypeClass getTypeClass();
/**
* Get expression type ID. Symbols service can be used to get type properties.
@@ -135,7 +127,7 @@ public interface IExpressions extends IService {
/**
* Check endianess of the values.
- * Big endian means decreasing numeric significance with increasing bit number.
+ * Big endian means decreasing numeric significance with increasing byte number.
* @return true if big endian.
*/
boolean isBigEndian();
@@ -153,18 +145,6 @@ public interface IExpressions extends IService {
Map<String,Object> getProperties();
}
- enum ValueClass {
- unknown, // unknown class
- cardinal, // unsigned integer
- integer, // signed integer
- real, // float, double
- pointer, // pointer to anything.
- array, // array of anything.
- composite, // struct, union, or class.
- enumeration, // enumeration.
- function // function.
- }
-
/**
* Expression value property names.
*/
@@ -175,7 +155,7 @@ public interface IExpressions extends IService {
/**
* Retrieve expression context info for given context ID.
- * @see ExpressionContext
+ * @see Expression
*
* @param id context ID.
* @param done - call back interface called when operation is completed.
@@ -288,6 +268,7 @@ public interface IExpressions extends IService {
* Called when context dispose command is done.
* @param token - command handle
* @param error error description if operation failed, null if succeeded.
+ * @param value - expression evaluation result
*/
void doneEvaluate(IToken token, Exception error, Value value);
}
diff --git a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/services/ISymbols.java b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/services/ISymbols.java
new file mode 100644
index 000000000..0a6d24a7d
--- /dev/null
+++ b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/services/ISymbols.java
@@ -0,0 +1,209 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tm.tcf.services;
+
+import java.util.Map;
+
+import org.eclipse.tm.tcf.protocol.IService;
+import org.eclipse.tm.tcf.protocol.IToken;
+
+public interface ISymbols extends IService {
+
+ /**
+ * Service name.
+ */
+ static final String NAME = "Symbols";
+
+ enum SymbolClass {
+ unknown, // unknown symbol class
+ value, // constant value
+ reference, // variable data object
+ function, // function body
+ type // a type
+ }
+
+ enum TypeClass {
+ unknown, // unknown type class
+ cardinal, // unsigned integer
+ integer, // signed integer
+ real, // float, double
+ pointer, // pointer to anything.
+ array, // array of anything.
+ composite, // struct, union, or class.
+ enumeration, // enumeration type.
+ function // function type.
+ }
+
+ /**
+ * Symbol context interface.
+ */
+ interface Symbol {
+ /**
+ * Get symbol ID.
+ * @return symbol ID.
+ */
+ String getID();
+
+ /**
+ * Get execution context ID (thread or process) that owns this instance of a symbol.
+ * @return execution context ID.
+ */
+ String getExeContextID();
+
+ /**
+ * Get symbol name.
+ * @return symbol name or null.
+ */
+ String getName();
+
+ /**
+ * Get symbol class.
+ * @return symbol class.
+ */
+ SymbolClass getSymbolClass();
+
+ /**
+ * Get symbol type class.
+ * @return type class.
+ */
+ TypeClass getTypeClass();
+
+ /**
+ * Get type ID.
+ * If the symbol is a type and not a 'typedef', return same as getID().
+ * @return type ID.
+ */
+ String getTypeID();
+
+ /**
+ * Get base type ID.
+ * If this symbol is a
+ * pointer type - return pointed type;
+ * array type - return element type;
+ * function type - return function result type;
+ * class type - return base class;
+ * otherwise return null.
+ * @return type ID.
+ */
+ String getBaseTypeID();
+
+ /**
+ * Get index type ID.
+ * If this symbol is a
+ * array type - return array index type;
+ * otherwise return null.
+ * @return type ID.
+ */
+ String getIndexTypeID();
+
+ /**
+ * Return value size of the symbol (or type).
+ * @return size in bytes.
+ */
+ int getSize();
+
+ /**
+ * If symbol is an array type - return number of elements.
+ * @return number of elements.
+ */
+ int getLength();
+
+ /**
+ * Return offset from 'this' for member of class, struct or union.
+ * @return offset in bytes.
+ */
+ int getOffset();
+
+ /**
+ * Return address of the symbol.
+ * @return address or null.
+ */
+ Number getAddress();
+
+ /**
+ * If symbol is a constant object, return its value.
+ * @return symbol value as array of bytes.
+ */
+ byte[] getValue();
+
+ /**
+ * Get complete map of context properties.
+ * @return map of context properties.
+ */
+ Map<String,Object> getProperties();
+ }
+
+ /**
+ * Symbol context property names.
+ */
+ static final String
+ PROP_ID = "ID",
+ PROP_EXE_ID = "ExeID",
+ PROP_NAME = "Name",
+ PROP_SYMBOL_CLASS = "Class",
+ PROP_TYPE_CLASS = "TypeClass",
+ PROP_TYPE_ID = "TypeID",
+ PROP_BASE_TYPE_ID = "BaseTypeID",
+ PROP_INDEX_TYPE_ID = "IndexTypeID",
+ PROP_SIZE = "Size",
+ PROP_LENGTH = "Length",
+ PROP_OFFSET = "Offset",
+ PROP_ADDRESS = "Address",
+ PROP_VALUE = "Value";
+
+ /**
+ * Retrieve symbol context info for given symbol ID.
+ * @see Symbol
+ *
+ * @param id symbol context ID.
+ * @param done - call back interface called when operation is completed.
+ * @return - pending command handle.
+ */
+ IToken getContext(String id, DoneGetContext done);
+
+ /**
+ * Client call back interface for getContext().
+ */
+ interface DoneGetContext {
+ /**
+ * Called when context data retrieval is done.
+ * @param token - command handle
+ * @param error error description if operation failed, null if succeeded.
+ * @param context context properties.
+ */
+ void doneGetContext(IToken token, Exception error, Symbol context);
+ }
+
+ /**
+ * Retrieve children IDs for given parent ID.
+ * Meaning of the operation depends on parent kind:
+ * 1. struct, union, or class type - get fields;
+ * 2. enumeration type - get enumerators;
+ *
+ * @param parent_context_id parent symbol context ID.
+ * @param done - call back interface called when operation is completed.
+ * @return - pending command handle.
+ */
+ IToken getChildren(String parent_context_id, DoneGetChildren done);
+
+ /**
+ * Client call back interface for getChildren().
+ */
+ interface DoneGetChildren {
+ /**
+ * Called when context list retrieval is done.
+ * @param token - command handle
+ * @param error error description if operation failed, null if succeeded.
+ * @param context_ids array of available context IDs.
+ */
+ void doneGetChildren(IToken token, Exception error, String[] context_ids);
+ }
+}

Back to the top