Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
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/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
11 files changed, 509 insertions, 402 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

Back to the top