From c12de90aa1437b8eac7b1d983e13164aa232e375 Mon Sep 17 00:00:00 2001 From: eutarass Date: Wed, 10 Mar 2010 01:18:55 +0000 Subject: TCF Agent: more symbols value-add code. --- .../internal/tcf/services/remote/SymbolsProxy.java | 46 ++++++++++++ .../src/org/eclipse/tm/tcf/protocol/JSON.java | 7 ++ .../src/org/eclipse/tm/tcf/services/IMemory.java | 2 +- .../src/org/eclipse/tm/tcf/services/ISymbols.java | 83 +++++++++++++++++++++- 4 files changed, 135 insertions(+), 3 deletions(-) (limited to 'plugins/org.eclipse.tm.tcf.core') diff --git a/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/internal/tcf/services/remote/SymbolsProxy.java b/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/internal/tcf/services/remote/SymbolsProxy.java index 7916c2255..4aa7bf4ee 100644 --- a/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/internal/tcf/services/remote/SymbolsProxy.java +++ b/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/internal/tcf/services/remote/SymbolsProxy.java @@ -23,6 +23,16 @@ public class SymbolsProxy implements ISymbols { value = JSON.toByteArray(props.get(PROP_VALUE)); } + public String getOwnerID() { + return (String)props.get(PROP_OWNER_ID); + } + + public int getUpdatePolicy() { + Number n = (Number)props.get(PROP_UPDATE_POLICY); + if (n == null) return 0; + return n.intValue(); + } + public Number getAddress() { return (Number)props.get(PROP_ADDRESS); } @@ -110,6 +120,12 @@ public class SymbolsProxy implements ISymbols { public byte[] getValue() { return value; } + + public boolean isBigEndian() { + Boolean b = (Boolean)props.get(PROP_LENGTH); + if (b == null) return false; + return b.booleanValue(); + } } public SymbolsProxy(IChannel channel) { @@ -151,6 +167,36 @@ public class SymbolsProxy implements ISymbols { }.token; } + public IToken find(String context_id, String name, final DoneFind done) { + return new Command(channel, this, "find", new Object[]{ context_id, name }) { + @Override + public void done(Exception error, Object[] args) { + String id = null; + if (error == null) { + assert args.length == 2; + error = toError(args[0]); + id = (String)args[1]; + } + done.doneFind(token, error, id); + } + }.token; + } + + public IToken list(String context_id, final DoneList done) { + return new Command(channel, this, "list", new Object[]{ 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.doneList(token, error, lst); + } + }.token; + } + @SuppressWarnings("unchecked") private String[] toStringArray(Object o) { if (o == null) return null; diff --git a/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/tcf/protocol/JSON.java b/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/tcf/protocol/JSON.java index 1762ec5f8..43cd9fe57 100644 --- a/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/tcf/protocol/JSON.java +++ b/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/tcf/protocol/JSON.java @@ -372,6 +372,13 @@ public final class JSON { if (cur_ch != 'e') error(); read(); return Boolean.TRUE; + case 'N': + read(); + if (cur_ch != 'a') error(); + read(); + if (cur_ch != 'N') error(); + read(); + return Float.NaN; default: boolean neg = cur_ch == '-'; if (neg) read(); diff --git a/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/tcf/services/IMemory.java b/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/tcf/services/IMemory.java index 794877bbe..38d426f4b 100644 --- a/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/tcf/services/IMemory.java +++ b/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/tcf/services/IMemory.java @@ -146,7 +146,7 @@ public interface IMemory extends IService { /** * Get memory endianess. - * @return true if memory id big-endian. + * @return true if memory is big-endian. */ boolean isBigEndian(); diff --git a/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/tcf/services/ISymbols.java b/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/tcf/services/ISymbols.java index 0c3dcb845..1d876564c 100644 --- a/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/tcf/services/ISymbols.java +++ b/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/tcf/services/ISymbols.java @@ -52,6 +52,23 @@ public interface ISymbols extends IService { */ String getID(); + /** + * Get symbol owner ID. + * The owner can a thread or memory space (process). + * Certain changes in owner state can invalidate cached symbol properties, + * see getUpdatePolicy() and UPDATE_*. + */ + String getOwnerID(); + + /** + * Get symbol properties update policy ID. + * Symbol properties can change during program execution. + * If a client wants to cache symbols, it should invalidate cached data + * according to update policies of cached symbols. + * @return symbol update policy ID, see UPDATE_* + */ + int getUpdatePolicy(); + /** * Get symbol name. * @return symbol name or null. @@ -140,6 +157,12 @@ public interface ISymbols extends IService { */ byte[] getValue(); + /** + * Get symbol values endianess. + * @return true if symbol is big-endian. + */ + boolean isBigEndian(); + /** * Get complete map of context properties. * @return map of context properties. @@ -152,6 +175,8 @@ public interface ISymbols extends IService { */ static final String PROP_ID = "ID", + PROP_OWNER_ID = "OwnerID", + PROP_UPDATE_POLICY = "UpdatePolicy", PROP_NAME = "Name", PROP_SYMBOL_CLASS = "Class", PROP_TYPE_CLASS = "TypeClass", @@ -164,9 +189,28 @@ public interface ISymbols extends IService { PROP_UPPER_BOUND = "UpperBound", PROP_OFFSET = "Offset", PROP_ADDRESS = "Address", - PROP_VALUE = "Value"; + PROP_VALUE = "Value", + PROP_BIG_ENDIAN = "BigEndian"; - // TODO: BigEndian property + /** + * Symbol context properties update policies. + */ + static final int + /** + * Update policy "Memory Map": symbol properties become invalid when + * memory map changes - when modules are loaded or unloaded. + * Symbol OwnerID indicates memory space (process) that is invalidation events source. + * Most static variables and types have this update policy. + */ + UPDATE_ON_MEMORY_MAP_CHANGES = 0, + + /** + * Update policy "Execution State": symbol properties become invalid when + * execution state changes - a thread is suspended, resumed or exited. + * Symbol OwnerID indicates executable context (thread) that is invalidation events source. + * Most stack (auto) variables have this update policy. + */ + UPDATE_ON_EXE_STATE_CHANGES = 1; /** * Retrieve symbol context info for given symbol ID. @@ -215,4 +259,39 @@ public interface ISymbols extends IService { */ void doneGetChildren(IToken token, Exception error, String[] context_ids); } + + /** + * Search symbol with given name in given context. + * The context can be memory space, process, thread or stack frame. + * + * @param context_id – a search scope. + * @param name – symbol name. + * @param done - call back interface called when operation is completed. + * @return - pending command handle. + */ + IToken find(String context_id, String name, DoneFind done); + + /** + * Client call back interface for find(). + */ + interface DoneFind { + void doneFind(IToken token, Exception error, String symbol_id); + } + + /** + * List all symbols in given context. + * The context can be a stack frame. + * + * @param context_id – a scope. + * @param done - call back interface called when operation is completed. + * @return - pending command handle. + */ + IToken list(String context_id, DoneList done); + + /** + * Client call back interface for list(). + */ + interface DoneList { + void doneList(IToken token, Exception error, String[] symbol_ids); + } } -- cgit v1.2.3