From e29a28376424d9b5488a79e60a92fedd45eff300 Mon Sep 17 00:00:00 2001 From: Benoit Perrin Date: Fri, 24 Feb 2012 09:24:14 +0100 Subject: TCF Python: Bug 372346 - Missing service support for Expressions and Symbols --- python/src/tcf/services/expressions.py | 12 ++- python/src/tcf/services/remote/MemoryProxy.py | 6 +- python/src/tcf/services/remote/SymbolsProxy.py | 49 ++++++++++- python/src/tcf/services/symbols.py | 107 +++++++++++++++++++++++-- 4 files changed, 162 insertions(+), 12 deletions(-) (limited to 'python/src') diff --git a/python/src/tcf/services/expressions.py b/python/src/tcf/services/expressions.py index 5b32a1c30..8ff7b323a 100644 --- a/python/src/tcf/services/expressions.py +++ b/python/src/tcf/services/expressions.py @@ -1,5 +1,5 @@ # ******************************************************************************* -# * Copyright (c) 2011 Wind River Systems, Inc. and others. +# * Copyright (c) 2011, 2012 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 @@ -153,6 +153,13 @@ class Value(object): """ return self._props.get(VAL_BIG_ENDIAN) + def getAddress(self): + """ + Get the value address if one exists. + @return The value address or None if none address exists for the value + """ + return self._props.get(VAL_ADDRESS) + def getValue(self): """ Get value as array of bytes. @@ -170,6 +177,9 @@ class Value(object): # Expression value property names. VAL_CLASS = "Class" VAL_TYPE = "Type" +VAL_SYMBOL = "Symbol" +VAL_REGISTER = "Register" +VAL_ADDRESS = "Address" VAL_BIG_ENDIAN = "BigEndian" class ExpressionsService(services.Service): diff --git a/python/src/tcf/services/remote/MemoryProxy.py b/python/src/tcf/services/remote/MemoryProxy.py index 3812f6bad..4c6b3941f 100644 --- a/python/src/tcf/services/remote/MemoryProxy.py +++ b/python/src/tcf/services/remote/MemoryProxy.py @@ -96,7 +96,7 @@ class MemContext(memory.MemoryContext): e = memory.MemoryError(error.message) else: assert len(args) == 2 - e = self.toMemoryError(args[0], args[1]) + e = self.toMemoryError(addr, args[0], args[1]) done.doneMemory(self.token, e) return FillCommand().token @@ -117,7 +117,7 @@ class MemContext(memory.MemoryContext): byts = channel.toByteArray(args[0]) assert len(byts) <= size buf[offs:offs+len(byts)] = byts - e = self.toMemoryError(args[1], args[2]) + e = self.toMemoryError(addr, args[1], args[2]) done.doneMemory(self.token, e) return GetCommand().token @@ -135,7 +135,7 @@ class MemContext(memory.MemoryContext): e = memory.MemoryError(error.message) else: assert len(args) == 2 - e = self.toMemoryError(args[1], args[2]) + e = self.toMemoryError(addr, args[1], args[2]) done.doneMemory(self.token, e) return SetCommand().token diff --git a/python/src/tcf/services/remote/SymbolsProxy.py b/python/src/tcf/services/remote/SymbolsProxy.py index 72c3b10fb..132999c10 100644 --- a/python/src/tcf/services/remote/SymbolsProxy.py +++ b/python/src/tcf/services/remote/SymbolsProxy.py @@ -1,5 +1,5 @@ # ******************************************************************************* -# * Copyright (c) 2011 Wind River Systems, Inc. and others. +# * Copyright (c) 2011, 2012 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 @@ -72,6 +72,38 @@ class SymbolsProxy(symbols.SymbolsService): done.doneFind(self.token, error, id) return FindCommand().token + def findByName(self, context_id, ip, name, done): + done = self._makeCallback(done) + service = self + class FindByNameCommand(Command): + def __init__(self): + super(FindByNameCommand, self).__init__(service.channel, service, "findByName", (context_id, ip, name)) + def done(self, error, args): + ids = [] + if not error: + assert len(args) >= 2 + error = self.toError(args[0]) + if not error: + ids = args[1:] + done.doneFind(self.token, error, ids) + return FindByNameCommand().token + + def findInScope(self, context_id, ip, scope_id, name, done): + done = self._makeCallback(done) + service = self + class FindInScopeCommand(Command): + def __init__(self): + super(FindInScopeCommand, self).__init__(service.channel, service, "findInScope", (context_id, ip, scope_id, name)) + def done(self, error, args): + ids = [] + if not error: + assert len(args) >= 2 + error = self.toError(args[0]) + if not error: + ids = args[1:] + done.doneFind(self.token, error, ids) + return FindInScopeCommand().token + def findByAddr(self, context_id, addr, done): done = self._makeCallback(done) service = self @@ -102,6 +134,21 @@ class SymbolsProxy(symbols.SymbolsService): done.doneList(self.token, error, lst) return ListCommand().token + def getArrayType(self, type_id, length, done): + done = self._makeCallback(done) + service = self + class GetArrayTypeCommand(Command): + def __init__(self): + super(GetArrayTypeCommand, self).__init__(service.channel, service, "getArrayType", (type_id, length)) + def done(self, error, args): + id = None + if not error: + assert len(args) == 2 + error = self.toError(args[0]) + id = args[1] + done.doneGetArrayType(self.token, error, id) + return GetArrayTypeCommand().token + def findFrameInfo(self, context_id, address, done): done = self._makeCallback(done) service = self diff --git a/python/src/tcf/services/symbols.py b/python/src/tcf/services/symbols.py index bde195f78..d0008ebd7 100644 --- a/python/src/tcf/services/symbols.py +++ b/python/src/tcf/services/symbols.py @@ -1,5 +1,5 @@ #****************************************************************************** -# * Copyright (c) 2011 Wind River Systems, Inc. and others. +# * Copyright (c) 2011, 2012 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 @@ -20,6 +20,9 @@ class SymbolClass: reference = 2 # variable data object function = 3 # function body type = 4 # a type + comp_unit = 5 # a compilation unit + block = 6 # a block of code + namespace = 7 # a namespace class TypeClass: unknown = 0 # unknown type class @@ -31,6 +34,32 @@ class TypeClass: composite = 6 # struct, union, or class. enumeration = 7 # enumeration type. function = 8 # function type. + member_ptr = 9 # a pointer on member type + +SYM_FLAG_PARAMETER = 0x000001 +SYM_FLAG_TYPEDEF = 0x000002 +SYM_FLAG_CONST_TYPE = 0x000004 +SYM_FLAG_PACKET_TYPE = 0x000008 +SYM_FLAG_SUBRANGE_TYPE = 0x000010 +SYM_FLAG_VOLATILE_TYPE = 0x000020 +SYM_FLAG_RESTRICT_TYPE = 0x000040 +SYM_FLAG_UNION_TYPE = 0x000080 +SYM_FLAG_CLASS_TYPE = 0x000100 +SYM_FLAG_INTERFACE_TYPE = 0x000200 +SYM_FLAG_SHARED_TYPE = 0x000400 +SYM_FLAG_REFERENCE = 0x000800 +SYM_FLAG_BIG_ENDIAN = 0x001000 +SYM_FLAG_LITTLE_ENDIAN = 0x002000 +SYM_FLAG_OPTIONAL = 0x004000 +SYM_FLAG_EXTERNAL = 0x008000 +SYM_FLAG_VARARG = 0x010000 +SYM_FLAG_ARTIFICIAL = 0x020000 +SYM_FLAG_TYPE_PARAMETER = 0x040000 +SYM_FLAG_PRIVATE = 0x080000 +SYM_FLAG_PROTECTED = 0x100000 +SYM_FLAG_PUBLIC = 0x200000 +SYM_FLAG_ENUM_TYPE = 0x400000 +SYM_FLAG_STRUCT_TYPE = 0x800000 # # Symbol context property names. @@ -53,6 +82,7 @@ PROP_ADDRESS = "Address" PROP_VALUE = "Value" PROP_BIG_ENDIAN = "BigEndian" PROP_REGISTER = "Register" +PROP_FLAGS = "Flags" # # Symbol context properties update policies. @@ -119,14 +149,14 @@ class Symbol(object): Get symbol class. @return symbol class. """ - return self._props.get(PROP_SYMBOL_CLASS) + return self._props.get(PROP_SYMBOL_CLASS, SymbolClass.unknown) def getTypeClass(self): """ Get symbol type class. @return type class. """ - return self._props.get(PROP_TYPE_CLASS) + return self._props.get(PROP_TYPE_CLASS, TypeClass.unknown) def getTypeID(self): """ @@ -222,6 +252,13 @@ class Symbol(object): """ return self._props.get(PROP_REGISTER) + def getFlags(self): + """ + Get symbol flags. + @return Symbol flags (see SYM_FLAG_ values). + """ + return self._props.get(PROP_FLAGS, 0) + def getProperties(self): """ Get complete map of context properties. @@ -259,7 +296,20 @@ class SymbolsService(services.Service): def find(self, context_id, ip, name, done): """ - Search symbol with given name in given context. + Search first 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 ip - instruction pointer - ignored if context_id is a stack frame ID + @param name - symbol name. + @param done - call back interface called when operation is completed. + @return - pending command handle. + """ + raise NotImplementedError("Abstract method") + + def findByName(self, context_id, ip, name, done): + """ + Search symbols with given name in given context. The context can be memory space, process, thread or stack frame. @param context_id - a search scope. @@ -282,6 +332,25 @@ class SymbolsService(services.Service): """ raise NotImplementedError("Abstract method") + def findInScope(self, context_id, ip, scope_id, name, done): + """ + Search symbols with given name in given context or in given symbol scope. + The context can be memory space, process, thread or stack frame. + The symbol scope can be any symbol. + If ip is not null, the search of the symbol name is done first in the + scope defined by @e context_id and @e ip. + If the symbol is not found, the supplied scope is then used. + + @param context_id - a search scope. + @param ip - instruction pointer. Can be null if only @e scope_id + should be used. + @param scope_id - symbol context ID. + @param name - symbol name. + @param done - call back interface called when operation is completed. + @return - pending command handle. + """ + raise NotImplementedError("Abstract method") + def list(self, context_id, done): """ List all symbols in given context. @@ -293,6 +362,18 @@ class SymbolsService(services.Service): """ raise NotImplementedError("Abstract method") + def getArrayType(self, type_id, length, done): + """ + Create an array type. + + @param type_id - symbol ID of the array cell type + @param length - length of the array. A length of 0 creates a pointer + type. + @param done - call back interface called when operation is completed. + @return - pending command handle. + """ + raise NotImplementedError("Abstract method") + def findFrameInfo(self, context_id, address, done): """ Retrieve stack tracing commands for given instruction address in a context memory. @@ -331,14 +412,14 @@ class DoneGetChildren(object): class DoneFind(object): """ - Client call back interface for find(). + Client call back interface for find(), findByName() and findInScope(). """ - def doneFind(self, token, error, symbol_id): + def doneFind(self, token, error, symbol_ids): """ Called when symbol search is done. @param token - command handle. @param error - error description if operation failed, None if succeeded. - @param symbol_id - symbol ID. + @param symbol_ids - list of symbol ID. """ pass @@ -354,6 +435,18 @@ class DoneList(object): @param symbol_ids - array of symbol IDs. """ +class DoneGetArrayType(object): + """ + Client call back interface for getArrayType(). + """ + def doneGetArrayType(self, token, error, type_id): + """ + Called when array type creation is done. + @param token - command handle. + @param error - error description if operation failed, None if succeeded. + @param type_id - array type symbol ID + """ + # # Command codes that are used to calculate frame pointer and register values during stack tracing. -- cgit v1.2.3