diff options
author | eutarass | 2011-08-01 21:28:46 +0000 |
---|---|---|
committer | eutarass | 2011-08-01 21:28:46 +0000 |
commit | 8e7e156b390f41e7bee414e9d5b82369083768ee (patch) | |
tree | d972b3d841652f5ade30d1227492a695287d8279 /plugins/org.eclipse.tm.tcf.debug.ui | |
parent | bf677094a7b8c146e2ab66e374257246e19de7ff (diff) | |
download | org.eclipse.tcf-8e7e156b390f41e7bee414e9d5b82369083768ee.tar.gz org.eclipse.tcf-8e7e156b390f41e7bee414e9d5b82369083768ee.tar.xz org.eclipse.tcf-8e7e156b390f41e7bee414e9d5b82369083768ee.zip |
TCF Debugger: implemented display of function argument names and values in stack traces.
Diffstat (limited to 'plugins/org.eclipse.tm.tcf.debug.ui')
3 files changed, 161 insertions, 71 deletions
diff --git a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFModelProxy.java b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFModelProxy.java index 4ad30e279..b31e980d9 100644 --- a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFModelProxy.java +++ b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFModelProxy.java @@ -429,11 +429,13 @@ public class TCFModelProxy extends AbstractModelProxy implements IModelProxy, Ru last_update_time = System.currentTimeMillis(); while (!selection.isEmpty()) { TCFNode node = selection.getFirst(); - root = new ModelDelta(input, IModelDelta.NO_CHANGE); - makeDelta(root, node, node); - node2delta.clear(); - if (pending_node != null) break; - postDelta(root); + if (!node.isDisposed()) { + root = new ModelDelta(input, IModelDelta.NO_CHANGE); + makeDelta(root, node, node); + node2delta.clear(); + if (pending_node != null) break; + postDelta(root); + } selection.remove(node); } } 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 0ceeea760..80e1d4554 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 @@ -54,7 +54,7 @@ public class TCFNodeExpression extends TCFNode implements IElementEditor, ICastT private final boolean deref; private final String field_id; private final TCFData<IExpressions.Expression> var_expression; - private final TCFData<String> text; + private final TCFData<String> base_text; private final TCFData<Expression> expression; private final TCFData<IExpressions.Value> value; private final TCFData<ISymbols.Symbol> type; @@ -119,7 +119,7 @@ public class TCFNodeExpression extends TCFNode implements IElementEditor, ICastT return false; } }; - text = new TCFData<String>(channel) { + base_text = new TCFData<String>(channel) { @Override protected boolean startDataRetrieval() { /* Compute expression script, not including type cast */ @@ -143,7 +143,7 @@ public class TCFNodeExpression extends TCFNode implements IElementEditor, ICastT } TCFNode n = parent; while (n instanceof TCFNodeArrayPartition) n = n.parent; - TCFDataCache<String> t = ((TCFNodeExpression)n).text; + TCFDataCache<String> t = ((TCFNodeExpression)n).base_text; if (!t.validate(this)) return false; String e = t.getData(); if (e == null) { @@ -165,6 +165,68 @@ public class TCFNodeExpression extends TCFNode implements IElementEditor, ICastT return true; } }; + expression_text = new TCFData<String>(channel) { + @Override + protected boolean startDataRetrieval() { + /* Compute human readable expression script, + * including type cast, and using variable names instead of IDs */ + String expr_text = null; + if (script != null) { + expr_text = script; + } + else if (var_id != null) { + if (!var_expression.validate(this)) return false; + IExpressions.Expression e = var_expression.getData(); + if (e != null) { + TCFDataCache<ISymbols.Symbol> var = model.getSymbolInfoCache(e.getSymbolID()); + if (var != null) { + if (!var.validate(this)) return false; + if (var.getData() != null) expr_text = var.getData().getName(); + } + } + } + else { + TCFDataCache<?> pending = null; + TCFDataCache<ISymbols.Symbol> field = model.getSymbolInfoCache(field_id); + if (field != null && !field.validate()) pending = field; + if (!base_text.validate()) pending = base_text; + if (pending != null) { + pending.wait(this); + return false; + } + String parent_text = ""; + TCFNode n = parent; + while (n instanceof TCFNodeArrayPartition) n = n.parent; + TCFDataCache<String> parent_text_cache = ((TCFNodeExpression)n).expression_text; + if (!parent_text_cache.validate(this)) return false; + if (parent_text_cache.getData() != null) { + parent_text = parent_text_cache.getData(); + // surround with parentheses if not a simple identifier + if (!parent_text.matches("\\w*")) { + parent_text = '(' + parent_text + ')'; + } + } + if (index >= 0) { + if (index == 0 && deref) { + expr_text = "*" + parent_text; + } + else { + expr_text = parent_text + "[" + index + "]"; + } + } + if (expr_text == null && field != null && field.getData() != null) { + expr_text = parent_text + (deref ? "->" : ".") + field.getData().getName(); + } + if (expr_text == null && base_text.getData() != null) expr_text = base_text.getData(); + } + if (expr_text != null) { + String cast = model.getCastToType(id); + if (cast != null) expr_text = "(" + cast + ")(" + expr_text + ")"; + } + set(null, null, expr_text); + return true; + } + }; expression = new TCFData<Expression>(channel) { @Override protected boolean startDataRetrieval() { @@ -181,10 +243,10 @@ public class TCFNodeExpression extends TCFNode implements IElementEditor, ICastT set(null, var_expression.getError(), exp); return true; } - if (!text.validate(this)) return false; - String e = text.getData(); + if (!base_text.validate(this)) return false; + String e = base_text.getData(); if (e == null) { - set(null, text.getError(), null); + set(null, base_text.getError(), null); return true; } if (cast != null) e = "(" + cast + ")(" + e + ")"; @@ -420,62 +482,6 @@ public class TCFNodeExpression extends TCFNode implements IElementEditor, ICastT return true; } }; - expression_text = new TCFData<String>(channel) { - @Override - protected boolean startDataRetrieval() { - TCFDataCache<ISymbols.Symbol> field = model.getSymbolInfoCache(field_id); - TCFDataCache<?> pending = null; - if (field != null && !field.validate()) pending = field; - if (!var_expression.validate()) pending = var_expression; - if (!text.validate()) pending = text; - if (pending != null) { - pending.wait(this); - return false; - } - String parentName = ""; - if (parent instanceof TCFNodeExpression) { - TCFDataCache<String> parentText = ((TCFNodeExpression)parent).getExpressionText(); - if (!parentText.validate(this)) return false; - if (parentText.getData() != null) { - parentName = parenthesize(parentText.getData()); - } - } - String name = null; - if (index >= 0) { - if (index == 0 && deref) { - name = "*" + parentName; - } - else { - name = parentName + "[" + index + "]"; - } - } - if (name == null && field != null && field.getData() != null) { - name = parentName + (deref ? "->" : ".") + field.getData().getName(); - } - if (name == null && var_expression.getData() != null) { - TCFDataCache<ISymbols.Symbol> var = model.getSymbolInfoCache(var_expression.getData().getSymbolID()); - if (var != null) { - if (!var.validate(this)) return false; - if (var.getData() != null) name = var.getData().getName(); - } - } - if (name == null && text.getData() != null) name = text.getData(); - if (name != null) { - String cast = model.getCastToType(id); - if (cast != null) name = "(" + cast + ")(" + name + ")"; - } - set(null, null, name); - return true; - } - - private String parenthesize(String expr) { - // surround with parentheses if not a simple identifier - if (!expr.matches("\\w*")) { - return '(' + expr + ')'; - } - return expr; - } - }; children = new TCFChildrenSubExpressions(this, 0, 0, 0); } @@ -554,6 +560,7 @@ public class TCFNodeExpression extends TCFNode implements IElementEditor, ICastT type.cancel(); type_name.cancel(); string.cancel(); + expression_text.cancel(); children.onCastToTypeChanged(); postAllChangedDelta(); } @@ -578,10 +585,27 @@ public class TCFNodeExpression extends TCFNode implements IElementEditor, ICastT this.sort_pos = sort_pos; } + /** + * Get expression properties cache. + * The cache is empty is the expression does not represent a variable. + * @return The expression properties cache. + */ + public TCFDataCache<IExpressions.Expression> getVariable() { + return var_expression; + } + + /** + * Get expression value cache. + * @return The expression value cache. + */ public TCFDataCache<IExpressions.Value> getValue() { return value; } + /** + * Get expression type cache. + * @return The expression type cache. + */ public TCFDataCache<ISymbols.Symbol> getType() { return type; } @@ -843,7 +867,7 @@ public class TCFNodeExpression extends TCFNode implements IElementEditor, ICastT TCFDataCache<?> pending = null; if (field != null && !field.validate()) pending = field; if (!var_expression.validate()) pending = var_expression; - if (!text.validate()) pending = text; + if (!base_text.validate()) pending = base_text; if (!value.validate()) pending = value; if (!type.validate()) pending = type; if (pending != null) { @@ -867,12 +891,12 @@ public class TCFNodeExpression extends TCFNode implements IElementEditor, ICastT if (var.getData() != null) name = var.getData().getName(); } } - if (name == null && text.getData() != null) name = text.getData(); + if (name == null && base_text.getData() != null) name = base_text.getData(); if (name != null) { String cast = model.getCastToType(id); if (cast != null) name = "(" + cast + ")(" + name + ")"; } - Throwable error = text.getError(); + Throwable error = base_text.getError(); if (error == null) error = value.getError(); String[] cols = result.getColumnIds(); if (error != null) { @@ -1225,6 +1249,22 @@ public class TCFNodeExpression extends TCFNode implements IElementEditor, ICastT return bf.toString(); } + String getValueText(Runnable done) { + if (!expression.validate(done)) return null; + if (!value.validate(done)) return null; + StringBuffer bf = new StringBuffer(); + IExpressions.Value v = value.getData(); + if (v != null) { + byte[] data = v.getValue(); + if (data != null) { + boolean big_endian = v.isBigEndian(); + if (!appendValueText(bf, 1, v.getTypeID(), + data, 0, data.length, big_endian, done)) return null; + } + } + return bf.toString(); + } + @Override protected boolean getData(IChildrenCountUpdate result, Runnable done) { if (!children.validate(done)) return false; 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 de8809523..9616626bb 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 @@ -27,6 +27,7 @@ import org.eclipse.tm.internal.tcf.debug.model.TCFSourceRef; import org.eclipse.tm.internal.tcf.debug.ui.ImageCache; import org.eclipse.tm.tcf.protocol.IToken; import org.eclipse.tm.tcf.protocol.Protocol; +import org.eclipse.tm.tcf.services.IExpressions; import org.eclipse.tm.tcf.services.IStackTrace; import org.eclipse.tm.tcf.services.ISymbols; import org.eclipse.tm.tcf.util.TCFDataCache; @@ -288,6 +289,8 @@ public class TCFNodeStackFrame extends TCFNode { result.setLabel("<select to see more frames>", 0); } else { + boolean show_arg_names = model.getShowFunctionArgNames(); + boolean show_arg_values = model.getShowFunctionArgValues(); TCFDataCache<TCFContextState> state_cache = ((TCFNodeExecContext)parent).getState(); TCFDataCache<TCFNodeExecContext> mem_cache = ((TCFNodeExecContext)parent).getMemoryNode(); TCFDataCache<?> pending = null; @@ -297,6 +300,17 @@ public class TCFNodeStackFrame extends TCFNode { if (!address.validate()) pending = address; if (!line_info.validate()) pending = line_info; if (!func_info.validate()) pending = func_info; + if (show_arg_names || show_arg_values) { + if (!children_vars.validate()) { + pending = children_vars; + } + else { + for (TCFNode n : children_vars.toArray()) { + TCFNodeExpression e = (TCFNodeExpression)n; + if (!e.getVariable().validate()) pending = e.getVariable(); + } + } + } if (pending != null) { pending.wait(done); return false; @@ -341,7 +355,41 @@ public class TCFNodeStackFrame extends TCFNode { if (sym_data != null && sym_data.getName() != null) { bf.append(" "); bf.append(sym_data.getName()); - bf.append("()"); + bf.append('('); + if (show_arg_names || show_arg_values) { + if (children_vars.getError() != null) { + bf.append('?'); + } + else { + int cnt = 0; + for (TCFNode n : children_vars.toArray()) { + ISymbols.Symbol sym = null; + TCFNodeExpression expr_node = (TCFNodeExpression)n; + IExpressions.Expression expr_props = expr_node.getVariable().getData(); + if (expr_props != null) { + TCFDataCache<ISymbols.Symbol> s = model.getSymbolInfoCache(expr_props.getSymbolID()); + if (!s.validate(done)) return false; + sym = s.getData(); + } + if (sym == null) continue; + if ((sym.getFlags() & ISymbols.SYM_FLAG_PARAMETER) == 0) continue; + if (cnt > 0) bf.append(','); + if (show_arg_names) { + String name = "?"; + if (sym != null && sym.getName() != null) name = sym.getName(); + bf.append(name); + if (show_arg_values) bf.append('='); + } + if (show_arg_values) { + String s = expr_node.getValueText(done); + if (s == null) return false; + bf.append(s.length() == 0 ? "?" : s); + } + cnt++; + } + } + } + bf.append(')'); } } if (sref != null && sref.area != null && sref.area.file != null) { |