Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
authoraleherbau2011-05-19 12:48:10 +0000
committeraleherbau2011-05-19 12:48:10 +0000
commita1dfa9cc409eb736911e0be32b45f57a866e34c5 (patch)
tree97b7fa6c87076479630bdbc6a098d454264798e5 /python
parent506dcea466abc2e93a508ddfbe2814d1046f3635 (diff)
downloadorg.eclipse.tcf-a1dfa9cc409eb736911e0be32b45f57a866e34c5.tar.gz
org.eclipse.tcf-a1dfa9cc409eb736911e0be32b45f57a866e34c5.tar.xz
org.eclipse.tcf-a1dfa9cc409eb736911e0be32b45f57a866e34c5.zip
TCF Python: Implemented Memory and MemoryMap service proxies, code cleanup
Diffstat (limited to 'python')
-rw-r--r--python/src/tcf/EventQueue.py4
-rw-r--r--python/src/tcf/__init__.py4
-rw-r--r--python/src/tcf/channel/AbstractChannel.py7
-rw-r--r--python/src/tcf/channel/ChannelProxy.py9
-rw-r--r--python/src/tcf/channel/ChannelTCP.py6
-rw-r--r--python/src/tcf/channel/Command.py22
-rw-r--r--python/src/tcf/channel/StreamChannel.py6
-rw-r--r--python/src/tcf/channel/__init__.py8
-rw-r--r--python/src/tcf/errors.py4
-rw-r--r--python/src/tcf/peer.py44
-rw-r--r--python/src/tcf/protocol.py30
-rw-r--r--python/src/tcf/services/__init__.py12
-rw-r--r--python/src/tcf/services/breakpoints.py29
-rw-r--r--python/src/tcf/services/expressions.py25
-rw-r--r--python/src/tcf/services/filesystem.py97
-rw-r--r--python/src/tcf/services/linenumbers.py5
-rw-r--r--python/src/tcf/services/local/LocatorService.py26
-rw-r--r--python/src/tcf/services/locator.py17
-rw-r--r--python/src/tcf/services/memory.py303
-rw-r--r--python/src/tcf/services/memorymap.py188
-rw-r--r--python/src/tcf/services/processes.py33
-rw-r--r--python/src/tcf/services/registers.py29
-rw-r--r--python/src/tcf/services/remote/BreakpointsProxy.py3
-rw-r--r--python/src/tcf/services/remote/ExpressionsProxy.py3
-rw-r--r--python/src/tcf/services/remote/FileSystemProxy.py4
-rw-r--r--python/src/tcf/services/remote/LineNumbersProxy.py4
-rw-r--r--python/src/tcf/services/remote/LocatorProxy.py19
-rw-r--r--python/src/tcf/services/remote/MemoryMapProxy.py84
-rw-r--r--python/src/tcf/services/remote/MemoryProxy.py249
-rw-r--r--python/src/tcf/services/remote/ProcessesProxy.py5
-rw-r--r--python/src/tcf/services/remote/RegistersProxy.py5
-rw-r--r--python/src/tcf/services/remote/RunControlProxy.py13
-rw-r--r--python/src/tcf/services/runcontrol.py31
-rw-r--r--python/src/tcf/services/stacktrace.py23
-rw-r--r--python/src/tcf/services/symbols.py31
-rw-r--r--python/src/tcf/shell.py2
-rw-r--r--python/src/tcf/tests/BasicTests.py75
-rw-r--r--python/src/tcf/transport.py30
-rw-r--r--python/src/tcf/util/cache.py12
-rw-r--r--python/src/tcf/util/event.py6
-rw-r--r--python/src/tcf/util/logging.py2
-rw-r--r--python/src/tcf/util/sync.py8
-rw-r--r--python/src/tcf/util/task.py34
-rw-r--r--python/todo.twiki5
44 files changed, 1213 insertions, 343 deletions
diff --git a/python/src/tcf/EventQueue.py b/python/src/tcf/EventQueue.py
index 546991b8f..c3084dde2 100644
--- a/python/src/tcf/EventQueue.py
+++ b/python/src/tcf/EventQueue.py
@@ -33,7 +33,7 @@ class EventQueue(object):
self.__is_waiting = False
self.__lock.notifyAll()
self.__thread.join()
- except BaseException as e:
+ except Exception as e:
protocol.log("Failed to shutdown TCF event dispatch thread", e)
def isShutdown(self):
@@ -53,7 +53,7 @@ class EventQueue(object):
self.__lock.wait()
r, args, kwargs = self.__queue.pop(0)
r(*args, **kwargs)
- except BaseException as x:
+ except Exception as x:
self.__error(x)
def invokeLater(self, r, *args, **kwargs):
diff --git a/python/src/tcf/__init__.py b/python/src/tcf/__init__.py
index 9c0c5a472..5918652db 100644
--- a/python/src/tcf/__init__.py
+++ b/python/src/tcf/__init__.py
@@ -13,7 +13,7 @@
TCF - Target Communication Framework
"""
-import types, exceptions
+import types
import protocol, peer, channel
from util import task
@@ -25,7 +25,7 @@ def connect(params, wait=True):
if type(params) is types.StringType:
params = _parse_params(params)
elif type(params) is not types.DictType:
- raise exceptions.TypeError("Expected string or dict")
+ raise TypeError("Expected string or dict")
p = peer.TransientPeer(params)
if wait:
c = task.Task(_openChannel, p).get()
diff --git a/python/src/tcf/channel/AbstractChannel.py b/python/src/tcf/channel/AbstractChannel.py
index f343d58ef..d8991e383 100644
--- a/python/src/tcf/channel/AbstractChannel.py
+++ b/python/src/tcf/channel/AbstractChannel.py
@@ -10,7 +10,6 @@
# *******************************************************************************
import sys, threading, time, types
-from exceptions import Exception, IOError
from tcf import protocol, transport, services, peer, errors
from tcf.services import locator
from tcf.channel import STATE_CLOSED, STATE_OPEN, STATE_OPENING
@@ -43,7 +42,7 @@ class ReaderThread(threading.Thread):
self.buf = bytearray()
self.eos_err_report = None
self.daemon = True
-
+
def error(self):
raise IOError("Protocol syntax error")
@@ -128,7 +127,7 @@ class AbstractChannel(object):
"""
AbstractChannel implements communication link connecting two end points (peers).
The channel asynchronously transmits messages: commands, results and events.
-
+
Clients can subclass AbstractChannel to support particular transport (wire) protocol.
Also, see StreamChannel for stream oriented transport protocols.
"""
@@ -163,7 +162,7 @@ class AbstractChannel(object):
self.local_congestion_time = 0
self.local_service_by_class = {}
self.trace_listeners = []
-
+
def __write_output(self):
try:
while True:
diff --git a/python/src/tcf/channel/ChannelProxy.py b/python/src/tcf/channel/ChannelProxy.py
index b95eaeb11..eca426e3c 100644
--- a/python/src/tcf/channel/ChannelProxy.py
+++ b/python/src/tcf/channel/ChannelProxy.py
@@ -14,7 +14,6 @@ ChannelProxy implements forwarding of TCF messages between two channels.
The class is used to implement Locator service "redirect" command.
"""
-import exceptions
from tcf import channel
class ProxyCommandListener(channel.CommandListener):
@@ -27,7 +26,7 @@ class ProxyCommandListener(channel.CommandListener):
self.ch.sendResult(self.tokens.pop(token, None), data)
def terminated(self, token, error):
self.ch.rejectCommand(self.tokens.pop(token, None))
-
+
class ChannelProxy(object):
def __init__(self, x, y):
#assert not isinstance(x, ChannelLoop)
@@ -41,7 +40,7 @@ class ChannelProxy(object):
cmd_listener_x = ProxyCommandListener(self.ch_x, self.tokens_x)
cmd_listener_y = ProxyCommandListener(self.ch_y, self.tokens_y)
proxy = self
-
+
class ProxyX(channel.Proxy):
def onChannelClosed(self, error):
proxy.closed_x = True
@@ -58,7 +57,7 @@ class ChannelProxy(object):
s = proxy.ch_x.getRemoteService(service)
if not s: proxy.ch_x.terminate(IOError("Invalid service name"))
elif not proxy.closed_y: proxy.ch_y.sendEvent(s, name, data)
-
+
class ProxyY(channel.Proxy):
def onChannelClosed(self, error):
proxy.closed_y = True
@@ -84,7 +83,7 @@ class ChannelProxy(object):
class ChannelListener(channel.ChannelListener):
def onChannelClosed(self, error):
proxy.ch_y.removeChannelListener(self)
- if error is None: error = exceptions.Exception("Channel closed")
+ if error is None: error = Exception("Channel closed")
def onChannelOpened(self):
proxy.ch_y.removeChannelListener(self)
try:
diff --git a/python/src/tcf/channel/ChannelTCP.py b/python/src/tcf/channel/ChannelTCP.py
index 1538ca067..ae020237b 100644
--- a/python/src/tcf/channel/ChannelTCP.py
+++ b/python/src/tcf/channel/ChannelTCP.py
@@ -30,9 +30,9 @@ class ChannelTCP(StreamChannel):
channel.socket = sock
channel._onSocketConnected(None)
protocol.invokeLater(CreateSocket())
-
+
def _onSocketConnected(self, x):
- if x:
+ if x:
self.terminate(x)
self.closed = True
if self.closed:
@@ -44,7 +44,7 @@ class ChannelTCP(StreamChannel):
else:
self.started = True
self.start()
-
+
def get(self):
if self.closed: return -1
try:
diff --git a/python/src/tcf/channel/Command.py b/python/src/tcf/channel/Command.py
index c22484db4..53256f0aa 100644
--- a/python/src/tcf/channel/Command.py
+++ b/python/src/tcf/channel/Command.py
@@ -9,7 +9,7 @@
# * Wind River Systems - initial API and implementation
# *******************************************************************************
-import exceptions, cStringIO
+import cStringIO
from tcf import protocol, errors, services
from tcf.channel import Token, toJSONSequence, fromJSONSequence, dumpJSONObject
@@ -18,17 +18,17 @@ class Command(object):
This is utility class that helps to implement sending a command and receiving
command result over TCF communication channel. The class uses JSON to encode
command arguments and to decode result data.
-
+
The class also provides support for TCF standard error report encoding.
-
+
Clients are expected to subclass <code>Command</code> and override <code>done</code> method.
-
+
Note: most clients don't need to handle protocol commands directly and
can use service APIs instead. Service API does all command encoding/decoding
for a client.
-
+
Typical usage example:
-
+
def getContext(self, id, done):
class GetContextCommand(Command):
def done(self, error, args):
@@ -54,7 +54,7 @@ class Command(object):
# TODO zero_copy
#zero_copy = channel.isZeroCopySupported()
t = channel.sendCommand(service, command, toJSONSequence(args), self)
- except exceptions.Exception as y:
+ except Exception as y:
t = Token()
protocol.invokeLater(self._error, y)
self.token = t
@@ -63,7 +63,7 @@ class Command(object):
assert not self.__done
self.__done = True
self.done(error, None)
-
+
def progress(self, token, data):
assert self.token is token
@@ -73,7 +73,7 @@ class Command(object):
args = None
try:
args = fromJSONSequence(data)
- except exceptions.Exception as e:
+ except Exception as e:
error = e
assert not self.__done
self.__done = True
@@ -86,7 +86,7 @@ class Command(object):
self.done(error, None)
def done(self, error, args):
- raise exceptions.NotImplementedError("Abstract method")
+ raise NotImplementedError("Abstract method")
def getCommandString(self):
buf = cStringIO.StringIO()
@@ -103,7 +103,7 @@ class Command(object):
i += 1
try:
dumpJSONObject(arg, buf)
- except exceptions.Exception as x:
+ except Exception as x:
buf.write("***")
buf.write(x.message)
buf.write("***")
diff --git a/python/src/tcf/channel/StreamChannel.py b/python/src/tcf/channel/StreamChannel.py
index 1b409c7a3..a572f83ac 100644
--- a/python/src/tcf/channel/StreamChannel.py
+++ b/python/src/tcf/channel/StreamChannel.py
@@ -17,12 +17,12 @@ ESC = 3
class StreamChannel(AbstractChannel):
"""
Abstract channel implementation for stream oriented transport protocols.
-
+
StreamChannel implements communication link connecting two end points (peers).
The channel asynchronously transmits messages: commands, results and events.
-
+
StreamChannel uses escape sequences to represent End-Of-Message and End-Of-Stream markers.
-
+
Clients can subclass StreamChannel to support particular stream oriented transport (wire) protocol.
Also, see ChannelTCP for a concrete IChannel implementation that works on top of TCP sockets as a transport.
"""
diff --git a/python/src/tcf/channel/__init__.py b/python/src/tcf/channel/__init__.py
index dc040aa98..b66708adb 100644
--- a/python/src/tcf/channel/__init__.py
+++ b/python/src/tcf/channel/__init__.py
@@ -9,7 +9,7 @@
# * Wind River Systems - initial API and implementation
# *******************************************************************************
-import cStringIO, json, binascii, types, exceptions
+import cStringIO, json, binascii, types
# channel states
STATE_OPENING = 0
@@ -166,7 +166,7 @@ def fromJSONSequence(bytes):
def dumpJSONObject(object, buf):
json.dump(object, buf, separators=(',', ':'), cls=TCFJSONEncoder)
-
+
def toByteArray(data):
if data is None: return None
t = type(data)
@@ -175,12 +175,14 @@ def toByteArray(data):
return binascii.a2b_base64(data)
elif t is unicode:
return binascii.a2b_base64(str(data))
- raise exceptions.TypeError(str(t))
+ raise TypeError(str(t))
class TCFJSONEncoder(json.JSONEncoder):
def default(self, o):
if isinstance(o, bytearray):
return binascii.b2a_base64(o)[:-1]
+ elif hasattr(o, '__json__'):
+ return o.__json__()
elif hasattr(o, '__iter__'):
return tuple(o)
else:
diff --git a/python/src/tcf/errors.py b/python/src/tcf/errors.py
index 53c856000..bac4b5be3 100644
--- a/python/src/tcf/errors.py
+++ b/python/src/tcf/errors.py
@@ -9,7 +9,7 @@
# * Wind River Systems - initial API and implementation
# *******************************************************************************
-import exceptions, cStringIO, time, types
+import cStringIO, time, types
# Error report attribute names
ERROR_CODE = "Code" # integer
@@ -72,7 +72,7 @@ TCF_ERROR_NOT_ACTIVE = 28
_timestamp_format = "%Y-%m-%d %H:%M:%S"
-class ErrorReport(exceptions.Exception):
+class ErrorReport(Exception):
def __init__(self, msg, attrs):
super(ErrorReport, self).__init__(msg)
if type(attrs) is types.IntType:
diff --git a/python/src/tcf/peer.py b/python/src/tcf/peer.py
index 0863404d1..15596db03 100644
--- a/python/src/tcf/peer.py
+++ b/python/src/tcf/peer.py
@@ -24,41 +24,41 @@ service manger would create a peer for every subnet it wants to participate in.
All peers of particular service manager represent identical sets of services.
"""
-import os, exceptions, time, json
+import os, time, json
from tcf import protocol, transport, services
from tcf.services import locator
-# Peer unique ID
+# Peer unique ID
ATTR_ID = "ID"
-# Unique ID of service manager that is represented by this peer
+# Unique ID of service manager that is represented by this peer
ATTR_SERVICE_MANAGER_ID = "ServiceManagerID"
-# Agent unique ID
+# Agent unique ID
ATTR_AGENT_ID = "AgentID"
-# Peer name
+# Peer name
ATTR_NAME = "Name"
-# Name of the peer operating system
+# Name of the peer operating system
ATTR_OS_NAME = "OSName"
-# Transport name, for example TCP, SSL
+# Transport name, for example TCP, SSL
ATTR_TRANSPORT_NAME = "TransportName"
-# If present, indicates that the peer can forward traffic to other peers
+# If present, indicates that the peer can forward traffic to other peers
ATTR_PROXY = "Proxy"
-# Host DNS name or IP address
+# Host DNS name or IP address
ATTR_IP_HOST = "Host"
-# Optional list of host aliases
+# Optional list of host aliases
ATTR_IP_ALIASES = "Aliases"
-# Optional list of host addresses
+# Optional list of host addresses
ATTR_IP_ADDRESSES = "Addresses"
-# IP port number, must be decimal number
+# IP port number, must be decimal number
ATTR_IP_PORT = "Port"
@@ -106,7 +106,7 @@ class Peer(object):
channel = peer.openChannel()
channel.addChannelListener(...)
"""
- raise exceptions.RuntimeError("Abstract method")
+ raise RuntimeError("Abstract method")
class TransientPeer(Peer):
@@ -136,7 +136,7 @@ class LocalPeer(TransientPeer):
"""
def __init__(self):
super(LocalPeer, self).__init__(self.createAttributes())
-
+
def createAttributes(self):
attrs = {
ATTR_ID : "TCFLocal",
@@ -202,24 +202,24 @@ class AbstractPeer(TransientPeer):
for l in protocol.getLocator().getListeners():
try:
l.peerChanged(self)
- except exceptions.Exception as x:
+ except Exception as x:
protocol.log("Unhandled exception in Locator listener", x)
try:
args = [self.rw_attrs]
protocol.sendEvent(locator.NAME, "peerChanged", json.dumps(args))
- except exceptions.IOError as x:
+ except IOError as x:
protocol.log("Locator: failed to send 'peerChanged' event", x)
self.last_heart_beat_time = timeVal
elif self.last_heart_beat_time + locator.DATA_RETENTION_PERIOD / 4 < timeVal:
for l in protocol.getLocator().getListeners():
try:
l.peerHeartBeat(attrs.get(ATTR_ID))
- except exceptions.Exception as x:
+ except Exception as x:
protocol.log("Unhandled exception in Locator listener", x)
try:
args = [self.rw_attrs.get(ATTR_ID)]
protocol.sendEvent(locator.NAME, "peerHeartBeat", json.dumps(args))
- except exceptions.IOError as x:
+ except IOError as x:
protocol.log("Locator: failed to send 'peerHeartBeat' event", x)
self.last_heart_beat_time = timeVal
@@ -227,12 +227,12 @@ class AbstractPeer(TransientPeer):
for l in protocol.getLocator().getListeners():
try:
l.peerAdded(self)
- except exceptions.Exception as x:
+ except Exception as x:
protocol.log("Unhandled exception in Locator listener", x)
try:
args = [self.rw_attrs]
protocol.sendEvent(locator.NAME, "peerAdded", json.dumps(args))
- except exceptions.IOError as x:
+ except IOError as x:
protocol.log("Locator: failed to send 'peerAdded' event", x)
self.last_heart_beat_time = int(time.time())
@@ -240,12 +240,12 @@ class AbstractPeer(TransientPeer):
for l in protocol.getLocator().getListeners():
try:
l.peerRemoved(self.rw_attrs.get(ATTR_ID))
- except exceptions.Exception as x:
+ except Exception as x:
protocol.log("Unhandled exception in Locator listener", x)
try:
args = [self.rw_attrs.get(ATTR_ID)]
protocol.sendEvent(locator.NAME, "peerRemoved", json.dumps(args))
- except exceptions.IOError as x:
+ except IOError as x:
protocol.log("Locator: failed to send 'peerRemoved' event", x)
diff --git a/python/src/tcf/protocol.py b/python/src/tcf/protocol.py
index 8aa37dbd6..9dfcf558e 100644
--- a/python/src/tcf/protocol.py
+++ b/python/src/tcf/protocol.py
@@ -19,7 +19,7 @@ It also provides utility methods for posting asynchronous events,
including delayed events (timers).
"""
-import sys, uuid, threading, exceptions
+import sys, uuid, threading
from EventQueue import EventQueue
_event_queue = None
@@ -43,7 +43,7 @@ def isDispatchThread():
Returns true if the calling thread is the TCF event dispatch thread.
Use this call to ensure that a given task is being executed (or not being)
on dispatch thread.
-
+
@return true if running on the dispatch thread.
"""
return _event_queue is not None and _event_queue.isDispatchThread()
@@ -56,9 +56,9 @@ def invokeLater(callable, *args, **kwargs):
If invokeLater is called from the dispatching thread
the callable will still be deferred until
all pending events have been processed.
-
+
This method can be invoked from any thread.
-
+
@param callable the callable to be executed asynchronously
"""
_event_queue.invokeLater(callable, *args, **kwargs)
@@ -67,9 +67,9 @@ def invokeLaterWithDelay(delay, callable, *args, **kwargs):
"""
Causes callable event to called in the dispatch thread of the framework.
The event is dispatched after given delay.
-
+
This method can be invoked from any thread.
-
+
@param delay milliseconds to delay event dispatch.
If delay <= 0 the event is posted into the
"ready" queue without delay.
@@ -79,7 +79,7 @@ def invokeLaterWithDelay(delay, callable, *args, **kwargs):
_event_queue.invokeLater(callable, *args, **kwargs)
else:
# TODO timer_queue
- raise exceptions.NotImplementedError("Implement invokeLaterWithDelay")
+ raise NotImplementedError("Implement invokeLaterWithDelay")
# synchronized (timer_queue) {
# timer_queue.add(new Timer(System.currentTimeMillis() + delay, runnable))
# timer_queue.notify()
@@ -90,9 +90,9 @@ def invokeAndWait(callable, *args, **kwargs):
Calling thread is suspended until the method is executed.
If invokeAndWait is called from the dispatching thread
the callable is executed immediately.
-
+
This method can be invoked from any thread.
-
+
@param runnable the callable to be executed on dispatch thread.
"""
if _event_queue.isDispatchThread():
@@ -122,7 +122,7 @@ def setLogger(logger):
"""
Set framework logger.
By default sys.stderr is used.
-
+
@param logger - an object implementing Logger interface.
"""
global _logger
@@ -175,7 +175,7 @@ class ChannelOpenListener(object):
"""
Interface to be implemented by clients willing to be notified when
new TCF communication channel is opened.
-
+
The interface allows a client to get pointers to channel objects
that were opened by somebody else. If a client open a channel itself, it already has
the pointer and does not need Protocol.ChannelOpenListener. If a channel is created,
@@ -217,10 +217,10 @@ def sync(done):
Call back after all TCF messages sent by this host up to this moment are delivered
to their intended target. This method is intended for synchronization of messages
across multiple channels.
-
+
Note: Cross channel synchronization can reduce performance and throughput.
Most clients don't need cross channel synchronization and should not call this method.
-
+
@param done will be executed by dispatch thread after pending communication
messages are delivered to corresponding targets.
"""
@@ -245,7 +245,7 @@ class CongestionMonitor(object):
@return integer value in range -100..100, where -100 means all resources are free,
0 means optimal load, and positive numbers indicate level of congestion.
"""
- raise exceptions.NotImplementedError("Abstract method")
+ raise NotImplementedError("Abstract method")
_congestion_monitors = []
def addCongestionMonitor(monitor):
@@ -267,7 +267,7 @@ def removeCongestionMonitor(monitor):
def getCongestionLevel():
"""
Get current level of local traffic congestion.
-
+
@return integer value in range -100..100, where -100 means no pending
messages (no traffic), 0 means optimal load, and positive numbers
indicate level of congestion.
diff --git a/python/src/tcf/services/__init__.py b/python/src/tcf/services/__init__.py
index 9febd3f00..dc7a1c050 100644
--- a/python/src/tcf/services/__init__.py
+++ b/python/src/tcf/services/__init__.py
@@ -9,7 +9,7 @@
# * Wind River Systems - initial API and implementation
# *******************************************************************************
-import threading, exceptions, collections
+import threading, collections
from tcf import protocol
_providers = []
@@ -45,7 +45,7 @@ def onChannelCreated(channel, services_by_name):
for service in arr:
if services_by_name.has_key(service.getName()): continue
services_by_name[service.getName()] = service
- except exceptions.Exception as x:
+ except Exception as x:
protocol.log("Error calling TCF service provider", x);
def onChannelOpened(channel, service_names, services_by_name):
@@ -57,7 +57,7 @@ def onChannelOpened(channel, service_names, services_by_name):
if not service: continue
services_by_name[name] = service
break
- except exceptions.Exception as x:
+ except Exception as x:
protocol.log("Error calling TCF service provider", x)
if services_by_name.has_key(name): continue
services_by_name[name] = GenericProxy(channel, name)
@@ -76,7 +76,7 @@ class GenericCallback(object):
class Service(object):
def getName(self):
- raise exceptions.NotImplementedError("Abstract method")
+ raise NotImplementedError("Abstract method")
def __str__(self):
return self.getName()
def _makeCallback(self, done):
@@ -118,9 +118,9 @@ class DefaultServiceProvider(ServiceProvider):
cls = clsModule.__dict__.get(clsName)
service = cls(channel)
assert service_name == service.getName()
- except exceptions.ImportError:
+ except ImportError:
pass
- except exceptions.Exception as x:
+ except Exception as x:
protocol.log("Cannot instantiate service proxy for "+service_name, x)
return service
diff --git a/python/src/tcf/services/breakpoints.py b/python/src/tcf/services/breakpoints.py
index 05481d0b4..0ca646119 100644
--- a/python/src/tcf/services/breakpoints.py
+++ b/python/src/tcf/services/breakpoints.py
@@ -23,7 +23,6 @@ persistent and represent user input, breakpoint status reflects dynamic target a
about breakpoint current state, like actual addresses where breakpoint is planted or planting errors.
"""
-import exceptions
from tcf import services
# Service name.
@@ -98,7 +97,7 @@ CAPABILITY_ACCESSMODE = "AccessMode" # Number
class BreakpointsService(services.Service):
def getName(self):
return NAME
-
+
def set(self, properties, done):
"""
Download breakpoints data to target agent.
@@ -106,13 +105,13 @@ class BreakpointsService(services.Service):
when communication channel is open. After that, host should
notify target about (incremental) changes in breakpoint data by sending
add, change and remove commands.
-
+
@param properties - array of breakpoints.
@param done - command result call back object.
@return - pending command handle.
@see DoneCommand
"""
- raise exceptions.NotImplementedError("Abstract method")
+ raise NotImplementedError("Abstract method")
def add(self, properties, done):
"""
@@ -122,7 +121,7 @@ class BreakpointsService(services.Service):
@return - pending command handle.
@see DoneCommand
"""
- raise exceptions.NotImplementedError("Abstract method")
+ raise NotImplementedError("Abstract method")
def change(self, properties, done):
"""
@@ -132,7 +131,7 @@ class BreakpointsService(services.Service):
@return - pending command handle.
@see DoneCommand
"""
- raise exceptions.NotImplementedError("Abstract method")
+ raise NotImplementedError("Abstract method")
def enable(self, ids, done):
"""
@@ -142,7 +141,7 @@ class BreakpointsService(services.Service):
@return - pending command handle.
@see DoneCommand
"""
- raise exceptions.NotImplementedError("Abstract method")
+ raise NotImplementedError("Abstract method")
def disable(self, ids, done):
"""
@@ -152,7 +151,7 @@ class BreakpointsService(services.Service):
@return - pending command handle.
@see DoneCommand
"""
- raise exceptions.NotImplementedError("Abstract method")
+ raise NotImplementedError("Abstract method")
def remove(self, ids, done):
"""
@@ -162,7 +161,7 @@ class BreakpointsService(services.Service):
@return - pending command handle.
@see DoneCommand
"""
- raise exceptions.NotImplementedError("Abstract method")
+ raise NotImplementedError("Abstract method")
def getIDs(self, done):
"""
@@ -171,7 +170,7 @@ class BreakpointsService(services.Service):
@return - pending command handle.
@see DoneGetIDs
"""
- raise exceptions.NotImplementedError("Abstract method")
+ raise NotImplementedError("Abstract method")
def getProperties(self, id, done):
"""
@@ -180,7 +179,7 @@ class BreakpointsService(services.Service):
@param done - command result call back object.
@see DoneGetProperties
"""
- raise exceptions.NotImplementedError("Abstract method")
+ raise NotImplementedError("Abstract method")
def getStatus(self, id, done):
"""
@@ -190,7 +189,7 @@ class BreakpointsService(services.Service):
@return - pending command handle.
@see DoneGetStatus
"""
- raise exceptions.NotImplementedError("Abstract method")
+ raise NotImplementedError("Abstract method")
def getCapabilities(self, id, done):
"""
@@ -205,21 +204,21 @@ class BreakpointsService(services.Service):
@return - pending command handle.
@see DoneGetCapabilities
"""
- raise exceptions.NotImplementedError("Abstract method")
+ raise NotImplementedError("Abstract method")
def addListener(self, listener):
"""
Add breakpoints service event listener.
@param listener - object that implements BreakpointsListener interface.
"""
- raise exceptions.NotImplementedError("Abstract method")
+ raise NotImplementedError("Abstract method")
def removeListener(self, listener):
"""
Remove breakpoints service event listener.
@param listener - object that implements BreakpointsListener interface.
"""
- raise exceptions.NotImplementedError("Abstract method")
+ raise NotImplementedError("Abstract method")
class DoneCommand(object):
diff --git a/python/src/tcf/services/expressions.py b/python/src/tcf/services/expressions.py
index 46de26002..8da3b61e6 100644
--- a/python/src/tcf/services/expressions.py
+++ b/python/src/tcf/services/expressions.py
@@ -14,7 +14,6 @@ Expressions service allows TCF client to perform expression evaluation on remote
The service can be used to retrieve or modify values of variables or any data structures in remote target memory.
"""
-import exceptions
from tcf import services
# Service name.
@@ -176,17 +175,17 @@ VAL_BIG_ENDIAN = "BigEndian"
class ExpressionsService(services.Service):
def getName(self):
return NAME
-
+
def getContext(self, id, done):
"""
Retrieve expression context info for given context ID.
@see Expression
-
+
@param id - context ID.
@param done - call back interface called when operation is completed.
@return - pending command handle.
"""
- raise exceptions.NotImplementedError("Abstract method")
+ raise NotImplementedError("Abstract method")
def getChildren(self, parent_context_id, done):
"""
@@ -198,15 +197,15 @@ class ExpressionsService(services.Service):
4. stack frame - function arguments and local variables
5. thread - top stack frame function arguments and local variables
6. process - global variables
-
+
Children list *does not* include IDs of expressions that were created by clients
using "create" command.
-
+
@param parent_context_id - parent context ID.
@param done - call back interface called when operation is completed.
@return - pending command handle.
"""
- raise exceptions.NotImplementedError("Abstract method")
+ raise NotImplementedError("Abstract method")
def create(self, parent_id, language, expression, done):
"""
@@ -218,7 +217,7 @@ class ExpressionsService(services.Service):
@param done - call back interface called when operation is completed.
@return - pending command handle.
"""
- raise exceptions.NotImplementedError("Abstract method")
+ raise NotImplementedError("Abstract method")
def dispose(self, id, done):
"""
@@ -227,7 +226,7 @@ class ExpressionsService(services.Service):
@param done - call back interface called when operation is completed.
@return - pending command handle.
"""
- raise exceptions.NotImplementedError("Abstract method")
+ raise NotImplementedError("Abstract method")
def evaluate(self, id, done):
"""
@@ -236,7 +235,7 @@ class ExpressionsService(services.Service):
@param done - call back interface called when operation is completed.
@return - pending command handle.
"""
- raise exceptions.NotImplementedError("Abstract method")
+ raise NotImplementedError("Abstract method")
def assign(self, id, value, done):
"""
@@ -246,21 +245,21 @@ class ExpressionsService(services.Service):
@param done - call back interface called when operation is completed.
@return - pending command handle.
"""
- raise exceptions.NotImplementedError("Abstract method")
+ raise NotImplementedError("Abstract method")
def addListener(self, listener):
"""
Add expressions service event listener.
@param listener - event listener implementation.
"""
- raise exceptions.NotImplementedError("Abstract method")
+ raise NotImplementedError("Abstract method")
def removeListener(self, listener):
"""
Remove expressions service event listener.
@param listener - event listener implementation.
"""
- raise exceptions.NotImplementedError("Abstract method")
+ raise NotImplementedError("Abstract method")
class DoneGetContext(object):
"""
diff --git a/python/src/tcf/services/filesystem.py b/python/src/tcf/services/filesystem.py
index d4b3f6502..3bba2c0fd 100644
--- a/python/src/tcf/services/filesystem.py
+++ b/python/src/tcf/services/filesystem.py
@@ -69,7 +69,6 @@ splice path name components returned by readdir() together
using a slash ('/') as the separator, and that will work as expected.
"""
-import exceptions
from tcf import services
# Service name.
@@ -146,7 +145,7 @@ class FileAttrs(object):
def isFile(self):
"""
Determines if the file system object is a file on the remote file system.
-
+
@return True if and only if the object on the remote system can be considered to have "contents" that
have the potential to be read and written as a byte stream.
"""
@@ -156,7 +155,7 @@ class FileAttrs(object):
def isDirectory(self):
"""
Determines if the file system object is a directory on the remote file system.
-
+
@return True if and only if the object on the remote system is a directory.
That is, it contains entries that can be interpreted as other files.
"""
@@ -190,7 +189,7 @@ S_IXOTH = 00001 # others have execute permission
class DirEntry(object):
"""
- Directory entry.
+ Directory entry.
Fields:
'filename' is a file name being returned. It is a relative name within
the directory, without any path components
@@ -235,14 +234,14 @@ STATUS_NO_SUCH_FILE = 0x10002
# permissions to perform the operation.
STATUS_PERMISSION_DENIED = 0x10003
-class FileSystemException(exceptions.IOError):
+class FileSystemException(IOError):
"""
The class to represent File System error reports.
"""
def __init__(self, message_or_exception):
if isinstance(message_or_exception, str):
super(FileSystemException, self).__init__(message_or_exception)
- elif isinstance(message_or_exception, exceptions.Exception):
+ elif isinstance(message_or_exception, Exception):
self.caused_by = message_or_exception
def getStatus(self):
"""
@@ -250,16 +249,16 @@ class FileSystemException(exceptions.IOError):
one of service specific codes, see STATUS_*.
@return error code.
"""
- raise exceptions.NotImplementedError("Abstract methods")
+ raise NotImplementedError("Abstract methods")
class FileSystemService(services.Service):
def getName(self):
return NAME
-
+
def open(self, file_name, flags, attrs, done):
"""
Open or create a file on a remote system.
-
+
@param file_name specifies the file name. See 'File Names' for more information.
@param flags is a bit mask of TCF_O_* flags.
@param attrs specifies the initial attributes for the file.
@@ -267,18 +266,18 @@ class FileSystemService(services.Service):
@param done is call back object.
@return pending command handle.
"""
- raise exceptions.NotImplementedError("Abstract methods")
+ raise NotImplementedError("Abstract methods")
def close(self, handle, done):
"""
Close a file on a remote system.
-
+
@param handle is a handle previously returned in the response to
open() or opendir().
@param done is call back object.
@return pending command handle.
"""
- raise exceptions.NotImplementedError("Abstract methods")
+ raise NotImplementedError("Abstract methods")
def read(self, handle, offset, len, done):
"""
@@ -291,7 +290,7 @@ class FileSystemService(services.Service):
True in case of EOF. For normal disk files, it is guaranteed
that this will read the specified number of bytes, or up to end of file
or error. For e.g. device files this may return fewer bytes than requested.
-
+
@param handle is an open file handle returned by open().
@param offset is the offset (in bytes) relative
to the beginning of the file from where to start reading.
@@ -300,7 +299,7 @@ class FileSystemService(services.Service):
@param done is call back object.
@return pending command handle.
"""
- raise exceptions.NotImplementedError("Abstract methods")
+ raise NotImplementedError("Abstract methods")
def write(self, handle, offset, data, data_pos, data_size, done):
"""
@@ -309,7 +308,7 @@ class FileSystemService(services.Service):
It is legal to write way beyond the end of the file the semantics
are to write zeroes from the end of the file to the specified offset
and then the data.
-
+
@param handle is an open file handle returned by open().
@param offset is the offset (in bytes) relative
to the beginning of the file from where to start writing.
@@ -320,40 +319,40 @@ class FileSystemService(services.Service):
@param done is call back object.
@return pending command handle.
"""
- raise exceptions.NotImplementedError("Abstract methods")
+ raise NotImplementedError("Abstract methods")
def stat(self, path, done):
"""
Retrieve file attributes.
-
+
@param path - specifies the file system object for which
status is to be returned.
@param done is call back object.
@return pending command handle.
"""
- raise exceptions.NotImplementedError("Abstract methods")
+ raise NotImplementedError("Abstract methods")
def lstat(self, path, done):
"""
Retrieve file attributes.
Unlike 'stat()', 'lstat()' does not follow symbolic links.
-
+
@param path - specifies the file system object for which
status is to be returned.
@param done is call back object.
@return pending command handle.
"""
- raise exceptions.NotImplementedError("Abstract methods")
+ raise NotImplementedError("Abstract methods")
def fstat(self, handle, done):
"""
Retrieve file attributes for an open file (identified by the file handle).
-
+
@param handle is a file handle returned by 'open()'.
@param done is call back object.
@return pending command handle.
"""
- raise exceptions.NotImplementedError("Abstract methods")
+ raise NotImplementedError("Abstract methods")
def setstat(self, path, attrs, done):
"""
@@ -363,27 +362,27 @@ class FileSystemService(services.Service):
An error will be returned if the specified file system object does
not exist or the user does not have sufficient rights to modify the
specified attributes.
-
+
@param path specifies the file system object (e.g. file or directory)
whose attributes are to be modified.
@param attrs specifies the modifications to be made to file attributes.
@param done is call back object.
@return pending command handle.
"""
- raise exceptions.NotImplementedError("Abstract methods")
+ raise NotImplementedError("Abstract methods")
def fsetstat(self, handle, attrs, done):
"""
Set file attributes for an open file (identified by the file handle).
This request is used for operations such as changing the ownership,
permissions or access times, as well as for truncating a file.
-
+
@param handle is a file handle returned by 'open()'.
@param attrs specifies the modifications to be made to file attributes.
@param done is call back object.
@return pending command handle.
"""
- raise exceptions.NotImplementedError("Abstract methods")
+ raise NotImplementedError("Abstract methods")
def opendir(self, path, done):
"""
@@ -393,12 +392,12 @@ class FileSystemService(services.Service):
When the client no longer wishes to read more names from the
directory, it SHOULD call close() for the handle. The handle
should be closed regardless of whether an error has occurred or not.
-
+
@param path - name of the directory to be listed (without any trailing slash).
@param done - result call back object.
@return pending command handle.
"""
- raise exceptions.NotImplementedError("Abstract methods")
+ raise NotImplementedError("Abstract methods")
def readdir(self, handle, done):
"""
@@ -415,18 +414,18 @@ class FileSystemService(services.Service):
@param done - result call back object.
@return pending command handle.
"""
- raise exceptions.NotImplementedError("Abstract methods")
+ raise NotImplementedError("Abstract methods")
def mkdir(self, path, attrs, done):
"""
Create a directory on the server.
-
+
@param path - specifies the directory to be created.
@param attrs - new directory attributes.
@param done - result call back object.
@return pending command handle.
"""
- raise exceptions.NotImplementedError("Abstract methods")
+ raise NotImplementedError("Abstract methods")
def rmdir(self, path, done):
"""
@@ -435,12 +434,12 @@ class FileSystemService(services.Service):
with the specified path exists, or if the specified directory is not
empty, or if the path specified a file system object other than a
directory.
-
+
@param path - specifies the directory to be removed.
@param done - result call back object.
@return pending command handle.
"""
- raise exceptions.NotImplementedError("Abstract methods")
+ raise NotImplementedError("Abstract methods")
def roots(self, done):
"""
@@ -451,34 +450,34 @@ class FileSystemService(services.Service):
the service must use forward slash as directory separator, and must start
absolute path with "/". Server should implement proper translation of
protocol file names to OS native names and back.
-
+
@param done - result call back object.
@return pending command handle.
"""
- raise exceptions.NotImplementedError("Abstract methods")
+ raise NotImplementedError("Abstract methods")
def remove(self, file_name, done):
"""
Remove a file or symbolic link.
This request cannot be used to remove directories.
-
+
@param file_name is the name of the file to be removed.
@param done - result call back object.
@return pending command handle.
"""
- raise exceptions.NotImplementedError("Abstract methods")
+ raise NotImplementedError("Abstract methods")
def realpath(self, path, done):
"""
Canonicalize any given path name to an absolute path.
This is useful for converting path names containing ".." components or
relative pathnames without a leading slash into absolute paths.
-
+
@param path specifies the path name to be canonicalized.
@param done - result call back object.
@return pending command handle.
"""
- raise exceptions.NotImplementedError("Abstract methods")
+ raise NotImplementedError("Abstract methods")
def rename(self, old_path, new_path, done):
"""
@@ -487,39 +486,39 @@ class FileSystemService(services.Service):
with the name specified by 'new_path'. The server may also fail rename
requests in other situations, for example if 'old_path' and 'new_path'
point to different file systems on the server.
-
+
@param old_path is the name of an existing file or directory.
@param new_path is the new name for the file or directory.
@param done - result call back object.
@return pending command handle.
"""
- raise exceptions.NotImplementedError("Abstract methods")
+ raise NotImplementedError("Abstract methods")
def readlink(self, path, done):
"""
Read the target of a symbolic link.
-
+
@param path specifies the path name of the symbolic link to be read.
@param done - result call back object.
@return pending command handle.
"""
- raise exceptions.NotImplementedError("Abstract methods")
+ raise NotImplementedError("Abstract methods")
def symlink(self, link_path, target_path, done):
"""
Create a symbolic link on the server.
-
+
@param link_path specifies the path name of the symbolic link to be created.
@param target_path specifies the target of the symbolic link.
@param done - result call back object.
@return pending command handle.
"""
- raise exceptions.NotImplementedError("Abstract methods")
+ raise NotImplementedError("Abstract methods")
def copy(self, src_path, dst_path, copy_permissions, copy_ownership, done):
"""
Copy a file on remote system.
-
+
@param src_path specifies the path name of the file to be copied.
@param dst_path specifies destination file name.
@param copy_permissions - if True then copy source file permissions.
@@ -527,17 +526,17 @@ class FileSystemService(services.Service):
@param done - result call back object.
@return pending command handle.
"""
- raise exceptions.NotImplementedError("Abstract methods")
+ raise NotImplementedError("Abstract methods")
def user(self, done):
"""
Retrieve information about user account, which is used by server
to access file system on behalf of the client.
-
+
@param done - result call back object.
@return pending command handle.
"""
- raise exceptions.NotImplementedError("Abstract methods")
+ raise NotImplementedError("Abstract methods")
class DoneOpen(object):
def doneOpen(self, token, error, handle):
diff --git a/python/src/tcf/services/linenumbers.py b/python/src/tcf/services/linenumbers.py
index 65d1b84ab..410e8d2b4 100644
--- a/python/src/tcf/services/linenumbers.py
+++ b/python/src/tcf/services/linenumbers.py
@@ -14,7 +14,6 @@ Line numbers service associates locations in the source files with the correspon
machine instruction addresses in the executable object.
"""
-import exceptions
from tcf import services
NAME = "LineNumbers"
@@ -119,10 +118,10 @@ class LineNumbersService(services.Service):
return NAME
def mapToSource(self, context_id, start_address, end_address, done):
- raise exceptions.NotImplementedError("Abstract method")
+ raise NotImplementedError("Abstract method")
def mapToMemory(self, context_id, file, line, column, done):
- raise exceptions.NotImplementedError("Abstract method")
+ raise NotImplementedError("Abstract method")
class DoneMapToSource(object):
def doneMapToSource(self, token, error, areas):
diff --git a/python/src/tcf/services/local/LocatorService.py b/python/src/tcf/services/local/LocatorService.py
index aa5550e1e..e11f37868 100644
--- a/python/src/tcf/services/local/LocatorService.py
+++ b/python/src/tcf/services/local/LocatorService.py
@@ -123,13 +123,13 @@ class LocatorService(locator.LocatorService):
listeners = [] # list of LocatorListener
error_log = set() # set of str
_error_log_lock = threading.RLock()
-
+
addr_cache = {} # str->AddressCacheItem
_addr_cache_lock = threading.Condition()
addr_request = False
local_peer = None
last_master_packet_time = 0
-
+
def __init__(self):
self.subnets = set()
self.slaves = []
@@ -184,7 +184,7 @@ class LocatorService(locator.LocatorService):
a.address = InetAddress(a.host, addr)
a.time_stamp = time
a.used = False
- except BaseException as x:
+ except Exception as x:
service._log("Unhandled exception in TCF discovery DNS lookup thread", x)
self.dns_lookup_thread = DNSLookupThread()
class InputThread(threading.Thread):
@@ -204,12 +204,12 @@ class LocatorService(locator.LocatorService):
return
except socket.error as x:
if sock != service.socket: continue
- # frequent error on windows, unknown reason
+ # frequent error on windows, unknown reason
if x.errno == 10054: continue
port = sock.getsockname()[1]
service._log("Cannot read from datagram socket at port %d" % port, x)
time.sleep(2)
- except BaseException as x:
+ except Exception as x:
service._log("Unhandled exception in socket reading thread", x)
self.input_thread = InputThread(self.__handleDatagramPacket)
try:
@@ -284,7 +284,7 @@ class LocatorService(locator.LocatorService):
channel.sendResult(token, toJSONSequence((None, arr)))
else:
channel.rejectCommand(token)
- except BaseException as x:
+ except Exception as x:
channel.terminate(x)
def _log(self, msg, x):
@@ -375,7 +375,7 @@ class LocatorService(locator.LocatorService):
subNetSet = set()
try:
self.__getSubNetList(subNetSet)
- except BaseException as x:
+ except Exception as x:
self._log("Cannot get list of network interfaces", x)
for s in tuple(self.subnets):
if s in subNetSet: continue
@@ -428,7 +428,7 @@ class LocatorService(locator.LocatorService):
if self.out_buf[4] == locator.CONF_PEER_INFO:
map = self.__parsePeerAttributes(self.out_buf, 8)
self.__traceDiscoveryPacket(False, self.packetTypes[self.out_buf[4]], map, addr, port)
- except BaseException as x:
+ except Exception as x:
self._log("Cannot send datagram packet to %s" % addr, x)
return False
return True
@@ -436,7 +436,7 @@ class LocatorService(locator.LocatorService):
def __parsePeerAttributes(self, data, size):
"""
Parse peer attributes in CONF_INFO_PEER packet data
-
+
@param data
the packet section that contain the peer attributes
@param size
@@ -592,7 +592,7 @@ class LocatorService(locator.LocatorService):
subnet.last_slaves_req_time = tm
if subnet.address == remote_address and remote_port == DISCOVEY_PORT:
self.last_master_packet_time = tm
- except BaseException as x:
+ except Exception as x:
self._log("Invalid datagram packet received from %s/%s" % (p.getAddress(), p.getPort()), x)
def __handlePeerInfoPacket(self, p):
@@ -617,7 +617,7 @@ class LocatorService(locator.LocatorService):
_peer.updateAttributes(map)
elif _peer is None:
peer.RemotePeer(map)
- except BaseException as x:
+ except Exception as x:
self._log("Invalid datagram packet received from %s/%s" % (p.getAddress(), p.getPort()), x)
def __handleReqInfoPacket(self, p, sl, tm):
@@ -679,7 +679,7 @@ class LocatorService(locator.LocatorService):
self.__addSlave(addr, port, time_val, time_now)
if __TRACE_DISCOVERY__:
self.__traceDiscoveryPacket(True, "CONF_SLAVES_INFO", trace_map, p)
- except BaseException as x:
+ except Exception as x:
self._log("Invalid datagram packet received from %s/%s" % (p.getAddress(), p.getPort()), x)
def __handleReqSlavesPacket(self, p, sl, tm):
@@ -717,7 +717,7 @@ class LocatorService(locator.LocatorService):
Log that a TCF Discovery packet has be sent or received. The trace is
sent to stdout. This should be called only if the tracing has been turned
on.
-
+
@param received
True if the packet was sent, otherwise it was received
@param type
diff --git a/python/src/tcf/services/locator.py b/python/src/tcf/services/locator.py
index 3804bb8de..8ffe42be2 100644
--- a/python/src/tcf/services/locator.py
+++ b/python/src/tcf/services/locator.py
@@ -20,7 +20,6 @@ Clients should use protocol.getLocator() to obtain local instance of locator,
then locator.getPeers() can be used to get list of available peers (hosts and targets).
"""
-import exceptions
from tcf import services
# Peer data retention period in milliseconds.
@@ -46,34 +45,34 @@ class LocatorService(services.Service):
The method return cached (currently known to the framework) list of peers.
The list is updated according to event received from transport layer
"""
- raise exceptions.NotImplementedError("Abstract method")
+ raise NotImplementedError("Abstract method")
def redirect(self, peer, done):
"""
Redirect this service channel to given peer using this service as a proxy.
@param peer - Peer ID or attributes map.
"""
- raise exceptions.NotImplementedError("Abstract method")
+ raise NotImplementedError("Abstract method")
def sync(self, done):
"""
Call back after TCF messages sent to this target up to this moment are delivered.
This method is intended for synchronization of messages
across multiple channels.
-
+
Note: Cross channel synchronization can reduce performance and throughput.
Most clients don't need channel synchronization and should not call this method.
-
+
@param done will be executed by dispatch thread after communication
messages are delivered to corresponding targets.
-
+
This is internal API, TCF clients should use module 'tcf.protocol'.
"""
- raise exceptions.NotImplementedError("Abstract method")
+ raise NotImplementedError("Abstract method")
def addListener(self, listener):
"Add a listener for Locator service events."
- raise exceptions.NotImplementedError("Abstract method")
+ raise NotImplementedError("Abstract method")
def removeListener(self, listener):
"Remove a listener for Locator service events."
- raise exceptions.NotImplementedError("Abstract method")
+ raise NotImplementedError("Abstract method")
class DoneRedirect(object):
def doneRedirect(self, token, error):
diff --git a/python/src/tcf/services/memory.py b/python/src/tcf/services/memory.py
new file mode 100644
index 000000000..de97b2026
--- /dev/null
+++ b/python/src/tcf/services/memory.py
@@ -0,0 +1,303 @@
+# *******************************************************************************
+# * Copyright (c) 2011 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
+# *******************************************************************************
+
+"""
+Memory service provides basic operations to read/write memory on a target.
+"""
+
+from tcf import services
+
+NAME = "Memory"
+
+# Context property names.
+PROP_ID = "ID" # String, ID of the context, same as getContext command argument
+PROP_PARENT_ID = "ParentID" # String, ID of a parent context
+PROP_PROCESS_ID = "ProcessID" # String, process ID, see Processes service
+PROP_BIG_ENDIAN = "BigEndian" # Boolean, True if memory is big-endian
+PROP_ADDRESS_SIZE = "AddressSize" # Number, size of memory address in bytes
+PROP_NAME = "Name" # String, name of the context, can be used for UI purposes
+PROP_START_BOUND = "StartBound" # Number, lowest address (inclusive) which is valid for the context
+PROP_END_BOUND = "EndBound" # Number, highest address (inclusive) which is valid for the context
+PROP_ACCESS_TYPES = "AccessTypes" # Array of String, the access types allowed for this context
+
+# Values of "AccessTypes".
+# Target system can support multiple different memory access types, like instruction and data access.
+# Different access types can use different logic for address translation and memory mapping, so they can
+# end up accessing different data bits, even if address is the same.
+# Each distinct access type should be represented by separate memory context.
+# A memory context can represent multiple access types if they are equivalent - all access same memory bits.
+# Same data bits can be exposed through multiple memory contexts.
+ACCESS_INSTRUCTION = "instruction" # Context represent instructions fetch access
+ACCESS_DATA = "data" # Context represents data access
+ACCESS_IO = "io" # Context represents IO peripherals
+ACCESS_USER = "user" # Context represents a user (e.g. application running in Linux) view to memory
+ACCESS_SUPERVISOR = "supervisor" # Context represents a supervisor (e.g. Linux kernel) view to memory
+ACCESS_HYPERVISOR = "hypervisor" # Context represents a hypervisor view to memory
+ACCESS_VIRTUAL = "virtual" # Context uses virtual addresses
+ACCESS_PHYSICAL = "physical" # Context uses physical addresses
+ACCESS_CACHE = "cache" # Context is a cache
+ACCESS_TLB = "tlb" # Context is a TLB memory
+
+
+# Memory access mode:
+# Carry on when some of the memory cannot be accessed and
+# return MemoryError at the end if any of the bytes
+# were not processed correctly.
+MODE_CONTINUEONERROR = 0x1
+
+# Memory access mode:
+# Verify result of memory operations (by reading and comparing).
+MODE_VERIFY = 0x2
+
+class MemoryContext(object):
+ def __init__(self, props):
+ self._props = props or {}
+
+ def __str__(self):
+ return "[Memory Context %s]" % self._props
+
+ def getProperties(self):
+ """
+ Get context properties. See PROP_* definitions for property names.
+ Context properties are read only, clients should not try to modify them.
+ @return Map of context properties.
+ """
+ return self._props
+
+ def getID(self):
+ """
+ Retrieve context ID.
+ Same as getProperties().get('ID')
+ """
+ return self._props.get(PROP_ID)
+
+ def getParentID(self):
+ """
+ Retrieve parent context ID.
+ Same as getProperties().get('ParentID')
+ """
+ return self._props.get(PROP_PARENT_ID)
+
+ def getProcessID(self):
+ """
+ Retrieve context process ID.
+ Same as getProperties().get('ProcessID')
+ """
+ return self._props.get(PROP_PROCESS_ID)
+
+ def isBigEndian(self):
+ """
+ Get memory endianness.
+ @return True if memory is big-endian.
+ """
+ return self._props.get(PROP_BIG_ENDIAN, False)
+
+ def getAddressSize(self):
+ """
+ Get memory address size.
+ @return number of bytes used to store memory address value.
+ """
+ return self._props.get(PROP_ADDRESS_SIZE, 0)
+
+ def getName(self):
+ """
+ Get memory context name.
+ The name can be used for UI purposes.
+ @return context name.
+ """
+ return self._props.get(PROP_NAME)
+
+ def getStartBound(self):
+ """
+ Get lowest address (inclusive) which is valid for the context.
+ @return lowest address.
+ """
+ return self._props.get(PROP_START_BOUND)
+
+ def getEndBound(self):
+ """
+ Get highest address (inclusive) which is valid for the context.
+ @return highest address.
+ """
+ return self._props.get(PROP_END_BOUND)
+
+ def getAccessTypes(self):
+ """
+ Get the access types allowed for this context.
+ @return collection of access type names.
+ """
+ return self._props.get(PROP_ACCESS_TYPES)
+
+ def set(self, addr, word_size, buf, offs, size, mode, done):
+ """
+ Set target memory.
+ If 'word_size' is 0 it means client does not care about word size.
+ """
+ raise NotImplementedError("Abstract method")
+
+ def get(self, addr, word_size, buf, offs, size, mode, done):
+ """
+ Read target memory.
+ """
+ raise NotImplementedError("Abstract method")
+
+ def fill(self, addr, word_size, value, size, mode, done):
+ """
+ Fill target memory with given pattern.
+ 'size' is number of bytes to fill.
+ """
+ raise NotImplementedError("Abstract method")
+
+class DoneMemory(object):
+ """
+ Client call back interface for set(), get() and fill() commands.
+ """
+ def doneMemory(self, token, error):
+ pass
+
+class MemoryError(Exception):
+ pass
+
+class ErrorOffset(object):
+ """
+ ErrorOffset may be implemented by MemoryError object,
+ which is returned by get, set and fill commands.
+
+ get/set/fill () returns this exception when reading failed
+ for some but not all bytes, and MODE_CONTINUEONERROR
+ has been set in mode. (For example, when only part of the request
+ translates to valid memory addresses.)
+ Exception.getMessage can be used for generalized message of the
+ possible reasons of partial memory operation.
+ """
+ # Error may have per byte information
+ BYTE_VALID = 0x00
+ BYTE_UNKNOWN = 0x01 # e.g. out of range
+ BYTE_INVALID = 0x02
+ BYTE_CANNOT_READ = 0x04
+ BYTE_CANNOT_WRITE = 0x08
+
+ RANGE_KEY_ADDR = "addr"
+ RANGE_KEY_SIZE = "size"
+ RANGE_KEY_STAT = "stat"
+ RANGE_KEY_MSG = "msg"
+
+ def getStatus(self, offset):
+ raise NotImplementedError("Abstract method")
+
+ def getMessage(self, offset):
+ raise NotImplementedError("Abstract method")
+
+class MemoryService(services.Service):
+ def getName(self):
+ return NAME
+
+ def getContext(self, id, done):
+ """
+ Retrieve context info for given context ID.
+
+ @param id - context ID.
+ @param done - call back interface called when operation is completed.
+ @return - pending command handle.
+ """
+ raise NotImplementedError("Abstract method")
+
+ def getChildren(self, parent_context_id, done):
+ """
+ Retrieve contexts available for memory commands.
+ A context corresponds to an execution thread, process, address space, etc.
+ A context can belong to a parent context. Contexts hierarchy can be simple
+ plain list or it can form a tree. It is up to target agent developers to choose
+ layout that is most descriptive for a given target. Context IDs are valid across
+ all services. In other words, all services access same hierarchy of contexts,
+ with same IDs, however, each service accesses its own subset of context's
+ attributes and functionality, which is relevant to that service.
+
+ @param parent_context_id - parent context ID. Can be None -
+ to retrieve top level of the hierarchy, or one of context IDs retrieved
+ by previous getChildren commands.
+ @param done - call back interface called when operation is completed.
+ @return - pending command handle.
+ """
+ raise NotImplementedError("Abstract method")
+
+ def addListener(self, listener):
+ """
+ Add memory service event listener.
+ @param listener - event listener implementation.
+ """
+ raise NotImplementedError("Abstract method")
+
+ def removeListener(self, listener):
+ """
+ Remove memory service event listener.
+ @param listener - event listener implementation.
+ """
+ raise NotImplementedError("Abstract method")
+
+class MemoryListener(object):
+ """
+ Memory event listener is notified when memory context hierarchy
+ changes, and when memory is modified by memory service commands.
+ """
+
+ def contextAdded(self, contexts):
+ """
+ Called when a new memory access context(s) is created.
+ """
+ pass
+
+ def contextChanged(self, contexts):
+ """
+ Called when a memory access context(s) properties changed.
+ """
+ pass
+
+ def contextRemoved(self, context_ids):
+ """
+ Called when memory access context(s) is removed.
+ """
+ pass
+
+ def memoryChanged(self, context_id, addr, size):
+ """
+ Called when target memory content was changed and clients
+ need to update themselves. Clients, at least, should invalidate
+ corresponding cached memory data.
+ Not every change is notified - it is not possible,
+ only those, which are not caused by normal execution of the debuggee.
+ 'addr' and 'size' can be None if unknown.
+ """
+ pass
+
+class DoneGetContext(object):
+ """
+ Client call back interface for getContext().
+ """
+ def doneGetContext(self, token, error, context):
+ """
+ Called when context data retrieval is done.
+ @param error - error description if operation failed, None if succeeded.
+ @param context - context data.
+ """
+ pass
+
+class DoneGetChildren(object):
+ """
+ Client call back interface for getChildren().
+ """
+ def doneGetChildren(self, token, error, context_ids):
+ """
+ Called when context list retrieval is done.
+ @param error - error description if operation failed, None if succeeded.
+ @param context_ids - array of available context IDs.
+ """
+ pass
diff --git a/python/src/tcf/services/memorymap.py b/python/src/tcf/services/memorymap.py
new file mode 100644
index 000000000..1c80bad96
--- /dev/null
+++ b/python/src/tcf/services/memorymap.py
@@ -0,0 +1,188 @@
+# *******************************************************************************
+# * Copyright (c) 2011 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
+# *******************************************************************************
+
+"""
+MemoryMap service provides information about executable modules (files) mapped (loaded) into target memory.
+"""
+
+from tcf import services
+
+NAME = "MemoryMap"
+
+
+# Memory region property names.
+# Number, region address in memory
+PROP_ADDRESS = "Addr"
+
+# Number, region size
+PROP_SIZE = "Size"
+
+# Number, region offset in the file
+PROP_OFFSET = "Offs"
+
+# Boolean, true if the region represents BSS
+PROP_BSS = "BSS"
+
+# Number, region memory protection flags, see FLAG_*
+PROP_FLAGS = "Flags"
+
+# String, name of the file
+PROP_FILE_NAME = "FileName"
+
+# String, name of the object file section
+PROP_SECTION_NAME = "SectionName"
+
+# Memory region flags.
+# Read access is allowed
+FLAG_READ = 1
+
+# Write access is allowed
+FLAG_WRITE = 2
+
+# Instruction fetch access is allowed
+FLAG_EXECUTE = 4
+
+class MemoryRegion(object):
+ """Memory region object."""
+
+ def __init__(self, props):
+ self._props = props
+
+ def getProperties(self):
+ """
+ Get region properties. See PROP_* definitions for property names.
+ Properties are read only, clients should not try to modify them.
+ @return Map of region properties.
+ """
+ self._props
+
+ def getAddress(self):
+ """
+ Get memory region address.
+ @return region address.
+ """
+ return self._props.get(PROP_ADDRESS)
+
+ def getSize(self):
+ """
+ Get memory region size.
+ @return region size.
+ """
+ return self._props.get(PROP_SIZE)
+
+ def getOffset(self):
+ """
+ Get memory region file offset.
+ @return file offset.
+ """
+ return self._props.get(PROP_OFFSET)
+
+ def getFlags(self):
+ """
+ Get memory region flags.
+ @return region flags.
+ """
+ return self._props.get(PROP_FLAGS, 0)
+
+ def getFileName(self):
+ """
+ Get memory region file name.
+ @return file name.
+ """
+ return self._props.get(PROP_FILE_NAME)
+
+ def getSectionName(self):
+ """
+ Get memory region section name.
+ @return section name.
+ """
+ return self._props.get(PROP_SECTION_NAME)
+
+ def __json__(self):
+ # This makes it serializable using JSON serializer
+ return self._props
+
+ def __repr__(self):
+ return "MemoryRegion(%s)" % str(self._props)
+ __str__ = __repr__
+
+class MemoryMapService(services.Service):
+ def getName(self):
+ return NAME
+
+ def get(self, id, done):
+ """
+ Retrieve memory map for given context ID.
+
+ @param id - context ID.
+ @param done - call back interface called when operation is completed.
+ @return - pending command handle.
+ """
+ return NotImplementedError("Abstract method")
+
+ def set(self, id, map, done):
+ """
+ Set memory map for given context ID.
+
+ @param id - context ID.
+ @param map - memory map data.
+ @param done - call back interface called when operation is completed.
+ @return - pending command handle.
+ """
+ return NotImplementedError("Abstract method")
+
+ def addListener(self, listener):
+ """
+ Add memory map event listener.
+ @param listener - memory map event listener to add.
+ """
+ return NotImplementedError("Abstract method")
+
+ def removeListener(self, listener):
+ """
+ Remove memory map event listener.
+ @param listener - memory map event listener to remove.
+ """
+ return NotImplementedError("Abstract method")
+
+class DoneGet(object):
+ """
+ Client call back interface for get().
+ """
+ def doneGet(self, token, error, map):
+ """
+ Called when memory map data retrieval is done.
+ @param error - error description if operation failed, null if succeeded.
+ @param map - memory map data.
+ """
+ pass
+
+class DoneSet(object):
+ """
+ Client call back interface for set().
+ """
+ def doneSet(self, token, error):
+ """
+ Called when memory map set command is done.
+ @param error - error description if operation failed, null if succeeded.
+ """
+ pass
+
+class MemoryMapListener(object):
+ """
+ Service events listener interface.
+ """
+ def changed(self, context_id):
+ """
+ Called when context memory map changes.
+ @param context_id - context ID.
+ """
+ pass
diff --git a/python/src/tcf/services/processes.py b/python/src/tcf/services/processes.py
index e2e1a8a6a..d5ddef0ca 100644
--- a/python/src/tcf/services/processes.py
+++ b/python/src/tcf/services/processes.py
@@ -21,7 +21,6 @@ available for client to read/write using Streams service. Stream type of such
streams is set to "Processes".
"""
-import exceptions
from tcf import services
NAME = "Processes"
@@ -82,23 +81,23 @@ class ProcessesService(services.Service):
However, 'Processes.getContext' is supposed to return only process specific data,
If the ID is not a process ID, 'IProcesses.getContext' may not return any
useful information
-
+
@param id - context ID.
@param done - call back interface called when operation is completed.
"""
- raise exceptions.NotImplementedError("Abstract method")
+ raise NotImplementedError("Abstract method")
def getChildren(self, parent_context_id, attached_only, done):
"""
Retrieve children of given context.
-
+
@param parent_context_id - parent context ID. Can be None -
to retrieve top level of the hierarchy, or one of context IDs retrieved
by previous getContext or getChildren commands.
@param attached_only - if True return only attached process IDs.
@param done - call back interface called when operation is completed.
"""
- raise exceptions.NotImplementedError("Abstract method")
+ raise NotImplementedError("Abstract method")
def getSignalList(self, context_id, done):
"""
@@ -107,7 +106,7 @@ class ProcessesService(services.Service):
@param done - call back interface called when operation is completed.
@return pending command handle, can be used to cancel the command.
"""
- raise exceptions.NotImplementedError("Abstract method")
+ raise NotImplementedError("Abstract method")
def getSignalMask(self, context_id, done):
"""
@@ -118,7 +117,7 @@ class ProcessesService(services.Service):
@param done - call back interface called when operation is completed.
@return pending command handle, can be used to cancel the command.
"""
- raise exceptions.NotImplementedError("Abstract method")
+ raise NotImplementedError("Abstract method")
def setSignalMask(self, context_id, dont_stop, dont_pass, done):
"""
@@ -131,7 +130,7 @@ class ProcessesService(services.Service):
@param done - call back interface called when operation is completed.
@return pending command handle, can be used to cancel the command.
"""
- raise exceptions.NotImplementedError("Abstract method")
+ raise NotImplementedError("Abstract method")
def signal(self, context_id, signal, done):
"""
@@ -141,7 +140,7 @@ class ProcessesService(services.Service):
@param done - call back interface called when operation is completed.
@return pending command handle, can be used to cancel the command.
"""
- raise exceptions.NotImplementedError("Abstract method")
+ raise NotImplementedError("Abstract method")
def getEnvironment(self, done):
"""
@@ -149,7 +148,7 @@ class ProcessesService(services.Service):
@param done - call back interface called when operation is completed.
@return pending command handle, can be used to cancel the command.
"""
- raise exceptions.NotImplementedError("Abstract method")
+ raise NotImplementedError("Abstract method")
def start(self, directory, file, command_line, environment, attach, done):
"""
@@ -165,21 +164,21 @@ class ProcessesService(services.Service):
@param done - call back interface called when operation is completed.
@return pending command handle, can be used to cancel the command.
"""
- raise exceptions.NotImplementedError("Abstract method")
+ raise NotImplementedError("Abstract method")
def addListener(self, listener):
"""
Add processes service event listener.
@param listener - event listener implementation.
"""
- raise exceptions.NotImplementedError("Abstract method")
+ raise NotImplementedError("Abstract method")
def removeListener(self, listener):
"""
Remove processes service event listener.
@param listener - event listener implementation.
"""
- raise exceptions.NotImplementedError("Abstract method")
+ raise NotImplementedError("Abstract method")
class ProcessContext(object):
@@ -188,7 +187,7 @@ class ProcessContext(object):
def __str__(self):
return "[Processes Context %s]" % self._props
-
+
def getProperties(self):
"""
Get context properties. See PROP_* definitions for property names.
@@ -240,7 +239,7 @@ class ProcessContext(object):
@param done - call back interface called when operation is completed.
@return pending command handle, can be used to cancel the command.
"""
- raise exceptions.NotImplementedError("Abstract method")
+ raise NotImplementedError("Abstract method")
def detach(self, done):
"""
@@ -249,7 +248,7 @@ class ProcessContext(object):
@param done - call back interface called when operation is completed.
@return pending command handle, can be used to cancel the command.
"""
- raise exceptions.NotImplementedError("Abstract method")
+ raise NotImplementedError("Abstract method")
def terminate(self, done):
"""
@@ -257,7 +256,7 @@ class ProcessContext(object):
@param done - call back interface called when operation is completed.
@return pending command handle, can be used to cancel the command.
"""
- raise exceptions.NotImplementedError("Abstract method")
+ raise NotImplementedError("Abstract method")
class DoneCommand(object):
"""
diff --git a/python/src/tcf/services/registers.py b/python/src/tcf/services/registers.py
index a350753d5..6b8e9556b 100644
--- a/python/src/tcf/services/registers.py
+++ b/python/src/tcf/services/registers.py
@@ -13,7 +13,6 @@
Registers service provides access to target CPU register values and properties.
"""
-import exceptions
from tcf import services
NAME = "Registers"
@@ -63,7 +62,7 @@ class RegistersContext(object):
def __str__(self):
return "[Registers Context %s]" % self._props
-
+
def getProperties(self):
"""
Get context properties. See PROP_* definitions for property names.
@@ -243,7 +242,7 @@ class RegistersContext(object):
@param done - call back object.
@return - pending command handle.
"""
- raise exceptions.NotImplementedError("Abstract method")
+ raise NotImplementedError("Abstract method")
def set(self, value, done):
"""
@@ -252,7 +251,7 @@ class RegistersContext(object):
@param done - call back object.
@return - pending command handle.
"""
- raise exceptions.NotImplementedError("Abstract method")
+ raise NotImplementedError("Abstract method")
def search(self, filter, done):
"""
@@ -262,7 +261,7 @@ class RegistersContext(object):
@param done - call back object.
@return - pending command handle.
"""
- raise exceptions.NotImplementedError("Abstract method")
+ raise NotImplementedError("Abstract method")
class RegistersService(services.Service):
@@ -272,11 +271,11 @@ class RegistersService(services.Service):
def getContext(self, id, done):
"""
Retrieve context info for given context ID.
-
+
@param id - context ID.
@param done - call back interface called when operation is completed.
"""
- raise exceptions.NotImplementedError("Abstract method")
+ raise NotImplementedError("Abstract method")
def getChildren(self, parent_context_id, done):
"""
@@ -288,13 +287,13 @@ class RegistersService(services.Service):
all services. In other words, all services access same hierarchy of contexts,
with same IDs, however, each service accesses its own subset of context's
attributes and functionality, which is relevant to that service.
-
+
@param parent_context_id - parent context ID. Can be None -
to retrieve top level of the hierarchy, or one of context IDs retrieved
by previous getChildren commands.
@param done - call back interface called when operation is completed.
"""
- raise exceptions.NotImplementedError("Abstract method")
+ raise NotImplementedError("Abstract method")
def getm(self, locs, done):
"""
@@ -303,8 +302,8 @@ class RegistersService(services.Service):
@param done - call back object.
@return - pending command handle.
"""
- raise exceptions.NotImplementedError("Abstract method")
-
+ raise NotImplementedError("Abstract method")
+
def setm(self, locs, value, done):
"""
Set values of multiple locations in registers.
@@ -313,21 +312,21 @@ class RegistersService(services.Service):
@param done - call back object.
@return - pending command handle.
"""
- raise exceptions.NotImplementedError("Abstract method")
+ raise NotImplementedError("Abstract method")
def addListener(self, listener):
"""
Add registers service event listener.
@param listener - event listener implementation.
"""
- raise exceptions.NotImplementedError("Abstract method")
-
+ raise NotImplementedError("Abstract method")
+
def removeListener(self, listener):
"""
Remove registers service event listener.
@param listener - event listener implementation.
"""
- raise exceptions.NotImplementedError("Abstract method")
+ raise NotImplementedError("Abstract method")
class NamedValue(object):
diff --git a/python/src/tcf/services/remote/BreakpointsProxy.py b/python/src/tcf/services/remote/BreakpointsProxy.py
index 35cec5c5b..7111c5a48 100644
--- a/python/src/tcf/services/remote/BreakpointsProxy.py
+++ b/python/src/tcf/services/remote/BreakpointsProxy.py
@@ -9,7 +9,6 @@
# * Wind River Systems - initial API and implementation
# *******************************************************************************
-import exceptions
from tcf import channel
from tcf.services import breakpoints
from tcf.channel.Command import Command
@@ -46,7 +45,7 @@ class ChannelEventListener(channel.EventListener):
self.listener.contextRemoved(args[0])
else:
raise IOError("Breakpoints service: unknown event: " + name);
- except exceptions.Exception as x:
+ except Exception as x:
self.service.channel.terminate(x)
class BreakpointsProxy(breakpoints.BreakpointsService):
diff --git a/python/src/tcf/services/remote/ExpressionsProxy.py b/python/src/tcf/services/remote/ExpressionsProxy.py
index 48a2d313d..064152c01 100644
--- a/python/src/tcf/services/remote/ExpressionsProxy.py
+++ b/python/src/tcf/services/remote/ExpressionsProxy.py
@@ -9,7 +9,6 @@
# * Wind River Systems - initial API and implementation
# *******************************************************************************
-import exceptions
from tcf import channel
from tcf.services import expressions
from tcf.channel.Command import Command
@@ -130,5 +129,5 @@ class ChannelEventListener(channel.EventListener):
self.listener.valueChanged(args[0])
else:
raise IOError("Expressions service: unknown event: " + name);
- except exceptions.Exception as x:
+ except Exception as x:
self.service.channel.terminate(x)
diff --git a/python/src/tcf/services/remote/FileSystemProxy.py b/python/src/tcf/services/remote/FileSystemProxy.py
index ad626b6e6..27e36a8c4 100644
--- a/python/src/tcf/services/remote/FileSystemProxy.py
+++ b/python/src/tcf/services/remote/FileSystemProxy.py
@@ -132,7 +132,7 @@ class FileSystemProxy(filesystem.FileSystemService):
if not s: a = _toFileAttrs(args[1])
done.doneStat(self.token, s, a)
return StatCommand().token
-
+
def fstat(self, handle, done):
done = self._makeCallback(done)
assert handle.getService() is self
@@ -416,7 +416,7 @@ class FileSystemProxy(filesystem.FileSystemService):
service = self
class CopyCommand(FileSystemCommand):
def __init__(self):
- super(CopyCommand, self).__init__(service, "copy",
+ super(CopyCommand, self).__init__(service, "copy",
(id, src_path, dst_path, copy_permissions, copy_uidgid))
def done(self, error, args):
s = None
diff --git a/python/src/tcf/services/remote/LineNumbersProxy.py b/python/src/tcf/services/remote/LineNumbersProxy.py
index 32211ddf2..ad567d225 100644
--- a/python/src/tcf/services/remote/LineNumbersProxy.py
+++ b/python/src/tcf/services/remote/LineNumbersProxy.py
@@ -22,7 +22,7 @@ class LineNumbersProxy(linenumbers.LineNumbersService):
service = self
class MapCommand(Command):
def __init__(self):
- super(MapCommand, self).__init__(service.channel, service,
+ super(MapCommand, self).__init__(service.channel, service,
"mapToSource", (context_id, start_address, end_address))
def done(self, error, args):
arr = None
@@ -38,7 +38,7 @@ class LineNumbersProxy(linenumbers.LineNumbersService):
service = self
class MapCommand(Command):
def __init__(self):
- super(MapCommand, self).__init__(service.channel, service,
+ super(MapCommand, self).__init__(service.channel, service,
"mapToMemory", (context_id, file, line, column))
def done(self, error, args):
arr = None
diff --git a/python/src/tcf/services/remote/LocatorProxy.py b/python/src/tcf/services/remote/LocatorProxy.py
index 4926ee987..89fff33d9 100644
--- a/python/src/tcf/services/remote/LocatorProxy.py
+++ b/python/src/tcf/services/remote/LocatorProxy.py
@@ -9,7 +9,6 @@
# * Wind River Systems - initial API and implementation
# *******************************************************************************
-import exceptions
from tcf import protocol, peer, channel
from tcf.services import locator
from tcf.channel.Command import Command
@@ -35,25 +34,25 @@ class ChannelEventListener(channel.EventListener):
assert len(args) == 1
peer = Peer(self.channel.getRemotePeer(), args[0])
if self.proxy.peers.get(peer.getID()):
- protocol.log("Invalid peerAdded event", exceptions.Exception())
+ protocol.log("Invalid peerAdded event", Exception())
return
self.proxy.peers[peer.getID()] = peer
for l in self.proxy.listeners:
try:
l.peerAdded(peer)
- except exceptions.Exception as x:
+ except Exception as x:
protocol.log("Unhandled exception in Locator listener", x)
elif name == "peerChanged":
assert len(args) == 1
m = args[0]
- if not m: raise exceptions.Exception("Locator service: invalid peerChanged event - no peer ID")
+ if not m: raise Exception("Locator service: invalid peerChanged event - no peer ID")
peer = self.proxy.peers.get(m.get(peer.ATTR_ID))
if not peer: return
self.proxy.peers[peer.getID()] = peer
for l in self.proxy.listeners:
try:
l.peerChanged(peer)
- except exceptions.Exception as x:
+ except Exception as x:
protocol.log("Unhandled exception in Locator listener", x)
elif name == "peerRemoved":
assert len(args) == 1
@@ -64,7 +63,7 @@ class ChannelEventListener(channel.EventListener):
for l in self.proxy.listeners:
try:
l.peerRemoved(id)
- except exceptions.Exception as x:
+ except Exception as x:
protocol.log("Unhandled exception in Locator listener", x)
elif name == "peerHeartBeat":
assert len(args) == 1
@@ -74,11 +73,11 @@ class ChannelEventListener(channel.EventListener):
for l in self.proxy.listeners:
try:
l.peerHeartBeat(id)
- except exceptions.Exception as x:
+ except Exception as x:
protocol.log("Unhandled exception in Locator listener", x)
else:
- raise exceptions.IOError("Locator service: unknown event: " + name)
- except exceptions.Exception as x:
+ raise IOError("Locator service: unknown event: " + name)
+ except Exception as x:
self.channel.terminate(x)
class LocatorProxy(locator.LocatorService):
@@ -141,7 +140,7 @@ class LocatorProxy(locator.LocatorService):
for l in service.listeners:
try:
l.peerAdded(peer)
- except exceptions.Exception as x:
+ except Exception as x:
protocol.log("Unhandled exception in Locator listener", x)
self.get_peers_done = True
diff --git a/python/src/tcf/services/remote/MemoryMapProxy.py b/python/src/tcf/services/remote/MemoryMapProxy.py
new file mode 100644
index 000000000..9e37feb9b
--- /dev/null
+++ b/python/src/tcf/services/remote/MemoryMapProxy.py
@@ -0,0 +1,84 @@
+# *******************************************************************************
+# * Copyright (c) 2011 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
+# *******************************************************************************
+
+from tcf import channel
+from tcf.services import memorymap
+from tcf.channel.Command import Command
+
+class MemoryMapProxy(memorymap.MemoryMapService):
+ def __init__(self, channel):
+ self.channel = channel
+ self.listeners = {}
+
+ def get(self, id, done):
+ done = self._makeCallback(done)
+ service = self
+ class GetCommand(Command):
+ def __init__(self):
+ super(GetCommand, self).__init__(service.channel, service, "get", (id,))
+ def done(self, error, args):
+ map = None
+ if not error:
+ assert len(args) == 2
+ error = self.toError(args[0])
+ if args[1]: map = _toMemoryMap(args[1])
+ done.doneGet(self.token, error, map)
+ return GetCommand().token
+
+ def set(self, id, map, done):
+ done = self._makeCallback(done)
+ service = self
+ class SetCommand(Command):
+ def __init__(self):
+ super(SetCommand, self).__init__(service.channel, service, "set", (id, map))
+ def done(self, error, args):
+ if not error:
+ assert len(args) == 1
+ error = self.toError(args[0])
+ done.doneSet(self.token, error)
+ return SetCommand().token
+
+ def addListener(self, listener):
+ l = ChannelEventListener(self, listener)
+ self.channel.addEventListener(self, l)
+ self.listeners[listener] = l
+
+ def removeListener(self, listener):
+ l = self.listeners.get(listener)
+ if l:
+ del self.listeners[listener]
+ self.channel.removeEventListener(self, l)
+
+class ChannelEventListener(channel.EventListener):
+ def __init__(self, service, listener):
+ self.service = service
+ self.listener = listener
+ def event(self, name, data):
+ try:
+ args = channel.fromJSONSequence(data)
+ if name == "changed":
+ assert len(args) == 1
+ self.listener.changed(args[0])
+ else:
+ raise IOError("MemoryMap service: unknown event: " + name);
+ except Exception as x:
+ self.service.channel.terminate(x)
+
+
+def _toMemoryMap(o):
+ if o is None: return None
+ map = []
+ for x in o: map.append(_toMemoryRegion(x))
+ return map
+
+def _toMemoryRegion(o):
+ if o is None: return None
+ return memorymap.MemoryRegion(o)
diff --git a/python/src/tcf/services/remote/MemoryProxy.py b/python/src/tcf/services/remote/MemoryProxy.py
new file mode 100644
index 000000000..f2449fcb3
--- /dev/null
+++ b/python/src/tcf/services/remote/MemoryProxy.py
@@ -0,0 +1,249 @@
+# *******************************************************************************
+# * Copyright (c) 2011 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
+# *******************************************************************************
+
+from tcf import errors, channel
+from tcf.services import memory
+from tcf.channel.Command import Command
+
+class Range(object):
+ offs = 0
+ size = 0
+ stat = 0
+ msg = None
+ def __cmp__(self, o):
+ if self.offs < o.offs: return -1
+ if self.offs > o.offs: return +1
+ return 0
+
+class MemoryErrorReport(errors.ErrorReport, memory.MemoryError, memory.ErrorOffset):
+ def __init__(self, msg, attrs, addr, ranges):
+ super(MemoryErrorReport, self).__init__(msg, attrs)
+ if ranges is None:
+ self.ranges = None
+ else:
+ self.ranges = []
+ for m in ranges:
+ r = Range()
+ x = m.get(memory.ErrorOffset.RANGE_KEY_ADDR)
+ if isinstance(x, str):
+ y = int(x)
+ else:
+ y = x
+ r.offs = y - addr
+ r.size = m.get(memory.ErrorOffset.RANGE_KEY_SIZE)
+ r.stat = m.get(memory.ErrorOffset.RANGE_KEY_STAT)
+ r.msg = errors.toErrorString(m.get(memory.ErrorOffset.RANGE_KEY_MSG))
+ assert r.offs >= 0
+ assert r.size >= 0
+ self.ranges.append(r)
+ self.ranges.sort()
+
+ def getMessage(self, offset):
+ if self.ranges is None: return None
+ l = 0
+ h = len(self.ranges) - 1
+ while l <= h:
+ n = (l + h) / 2
+ r = self.ranges[n]
+ if r.offs > offset:
+ h = n - 1
+ elif offset >= r.offs + r.size:
+ l = n + 1
+ else:
+ return r.msg
+ return None
+
+ def getStatus(self, offset):
+ if self.ranges is None: return memory.ErrorOffset.BYTE_UNKNOWN
+ l = 0
+ h = len(self.ranges) - 1
+ while l <= h:
+ n = (l + h) / 2
+ r = self.ranges[n]
+ if r.offs > offset:
+ h = n - 1
+ elif offset >= r.offs + r.size:
+ l = n + 1
+ else:
+ return r.stat
+ return memory.ErrorOffset.BYTE_UNKNOWN
+
+
+class MemContext(memory.MemoryContext):
+ def __init__(self, service, props):
+ super(MemContext, self).__init__(props)
+ self.service = service
+
+ def fill(self, addr, word_size, value, size, mode, done):
+ service = self.service
+ id = self.getID()
+ done = service._makeCallback(done)
+ class FillCommand(MemoryCommand):
+ def __init__(self):
+ super(FillCommand, self).__init__(service,
+ "fill", (id, addr, word_size, size, mode, value))
+ def done(self, error, args):
+ e = None
+ if error:
+ e = memory.MemoryError(error.message)
+ else:
+ assert len(args) == 2
+ e = self.toMemoryError(args[0], args[1])
+ done.doneMemory(self.token, e)
+ return FillCommand().token
+
+ def get(self, addr, word_size, buf, offs, size, mode, done):
+ service = self.service
+ id = self.getID()
+ done = service._makeCallback(done)
+ class GetCommand(MemoryCommand):
+ def __init__(self):
+ super(GetCommand, self).__init__(service,
+ "get", (id, addr, word_size, size, mode))
+ def done(self, error, args):
+ e = None
+ if error:
+ e = memory.MemoryError(error.message)
+ else:
+ assert len(args) == 3
+ bytes = channel.toByteArray(args[0])
+ assert len(bytes) <= size
+ buf[offs:offs+len(bytes)] = bytes
+ e = self.toMemoryError(args[1], args[2])
+ done.doneMemory(self.token, e)
+ return GetCommand().token
+
+ def set(self, addr, word_size, buf, offs, size, mode, done):
+ service = self.service
+ id = self.getID()
+ done = service._makeCallback(done)
+ class SetCommand(MemoryCommand):
+ def __init__(self):
+ super(SetCommand, self).__init__(service,
+ "set", (id, addr, word_size, size, mode, bytearray(buf[offs:offs:size])))
+ def done(self, error, args):
+ e = None
+ if error:
+ e = memory.MemoryError(error.message)
+ else:
+ assert len(args) == 2
+ e = self.toMemoryError(args[1], args[2])
+ done.doneMemory(self.token, e)
+ return SetCommand().token
+
+class MemoryProxy(memory.MemoryService):
+ def __init__(self, channel):
+ self.channel = channel
+ self.listeners = {}
+
+ def getContext(self, context_id, done):
+ done = self._makeCallback(done)
+ service = self
+ class GetContextCommand(Command):
+ def __init__(self):
+ super(GetContextCommand, self).__init__(service.channel, service, "getContext", (context_id,))
+ def done(self, error, args):
+ ctx = None
+ if not error:
+ assert len(args) == 2
+ error = self.toError(args[0])
+ if args[1]: ctx = MemContext(service, args[1])
+ done.doneGetContext(self.token, error, ctx)
+ return GetContextCommand().token
+
+ def getChildren(self, parent_context_id, done):
+ done = self._makeCallback(done)
+ service = self
+ class GetChildrenCommand(Command):
+ def __init__(self):
+ super(GetChildrenCommand, self).__init__(service.channel, service, "getChildren", (parent_context_id,))
+ def done(self, error, args):
+ contexts = None
+ if not error:
+ assert len(args) == 2
+ error = self.toError(args[0])
+ contexts = args[1]
+ done.doneGetChildren(self.token, error, contexts)
+ return GetChildrenCommand().token
+
+ def addListener(self, listener):
+ l = ChannelEventListener(self, listener)
+ self.channel.addEventListener(self, l)
+ self.listeners[listener] = l
+
+ def removeListener(self, listener):
+ l = self.listeners.get(listener)
+ if l:
+ del self.listeners[listener]
+ self.channel.removeEventListener(self, l)
+
+class MemoryCommand(Command):
+ def __init__(self, service, cmd, args):
+ super(MemoryCommand, self).__init__(service.channel, service, cmd, args)
+ def toMemoryError(self, addr, data, ranges):
+ if data is None: return None
+ code = data.get(errors.ERROR_CODE)
+ cmd = self.getCommandString()
+ if len(cmd) > 72: cmd = cmd[0:72] + "..."
+ e = MemoryErrorReport(
+ "TCF command exception:\nCommand: %s\nException: %s\nError code: " % (
+ cmd, self.toErrorString(data), code),
+ map, addr, ranges)
+ caused_by = data.get(errors.ERROR_CAUSED_BY)
+ if caused_by is not None: e.caused_by = self.toError(caused_by, False)
+ return e
+
+
+class ChannelEventListener(channel.EventListener):
+ def __init__(self, service, listener):
+ self.service = service
+ self.listener = listener
+ def event(self, name, data):
+ try:
+ args = channel.fromJSONSequence(data)
+ if name == "contextAdded":
+ assert len(args) == 1
+ self.listener.contextAdded(_toContextArray(args[0]))
+ elif name == "contextChanged":
+ assert len(args) == 1
+ self.listener.contextChanged(_toContextArray(args[0]))
+ elif name == "contextRemoved":
+ assert len(args) == 1
+ self.listener.contextRemoved(args[0])
+ elif name == "memoryChanged":
+ assert len(args) == 2
+ self.listener.memoryChanged(args[0], _toAddrArray(args[1]), _toSizeArray(args[1]))
+ else:
+ raise IOError("Memory service: unknown event: " + name);
+ except Exception as x:
+ self.service.channel.terminate(x)
+
+
+def _toContextArray(o):
+ if o is None: return None
+ ctx = []
+ for m in o: ctx.append(MemContext(m))
+ return ctx
+
+def _toSizeArray(o):
+ if o is None: return None
+ a = []
+ for m in o:
+ sz = m.get("size", 0)
+ a.append(sz)
+ return a
+
+def _toAddrArray(o):
+ if o is None: return None
+ a = []
+ for m in o:
+ a.append(m.get("addr"))
+ return a
diff --git a/python/src/tcf/services/remote/ProcessesProxy.py b/python/src/tcf/services/remote/ProcessesProxy.py
index b4155ffef..baad634b6 100644
--- a/python/src/tcf/services/remote/ProcessesProxy.py
+++ b/python/src/tcf/services/remote/ProcessesProxy.py
@@ -9,7 +9,6 @@
# * Wind River Systems - initial API and implementation
# *******************************************************************************
-import exceptions
from tcf import channel
from tcf.services import processes
from tcf.channel.Command import Command
@@ -53,7 +52,7 @@ class ProcessesProxy(processes.ProcessesService):
service = self
class GetChildrenCommand(Command):
def __init__(self):
- super(GetChildrenCommand, self).__init__(service.channel, service,
+ super(GetChildrenCommand, self).__init__(service.channel, service,
"getChildren", (parent_context_id, attached_only))
def done(self, error, args):
contexts = None
@@ -196,7 +195,7 @@ class ChannelEventListener(channel.EventListener):
self.listener.exited(args[0], args[1])
else:
raise IOError("Processes service: unknown event: " + name);
- except exceptions.Exception as x:
+ except Exception as x:
self.service.channel.terminate(x)
def _toEnvStringArray(map):
diff --git a/python/src/tcf/services/remote/RegistersProxy.py b/python/src/tcf/services/remote/RegistersProxy.py
index ae2cfd4e0..f33eea147 100644
--- a/python/src/tcf/services/remote/RegistersProxy.py
+++ b/python/src/tcf/services/remote/RegistersProxy.py
@@ -9,7 +9,6 @@
# * Wind River Systems - initial API and implementation
# *******************************************************************************
-import exceptions
from tcf import channel
from tcf.services import registers
from tcf.channel import toByteArray
@@ -19,7 +18,7 @@ class Context(registers.RegistersContext):
def __init__(self, service, props):
super(Context, self).__init__(props)
self.service = service
-
+
def getNamedValues(self):
return _toValuesArray(self._props.get(registers.PROP_VALUES))
@@ -173,5 +172,5 @@ class ChannelEventListener(channel.EventListener):
self.listener.registerChanged(args[0])
else:
raise IOError("Registers service: unknown event: " + name);
- except exceptions.Exception as x:
+ except Exception as x:
self.service.channel.terminate(x)
diff --git a/python/src/tcf/services/remote/RunControlProxy.py b/python/src/tcf/services/remote/RunControlProxy.py
index d7606c74a..f3aa8ac5e 100644
--- a/python/src/tcf/services/remote/RunControlProxy.py
+++ b/python/src/tcf/services/remote/RunControlProxy.py
@@ -9,7 +9,6 @@
# * Wind River Systems - initial API and implementation
# *******************************************************************************
-import exceptions
from tcf import channel
from tcf.services import runcontrol
from tcf.channel.Command import Command
@@ -85,10 +84,10 @@ class ChannelEventListener(channel.EventListener):
self.listener.contextResumed(args[0])
elif name == "contextAdded":
assert len(args) == 1
- self.listener.contextAdded(args[0])
+ self.listener.contextAdded(_toContextArray(args[0]))
elif name == "contextChanged":
assert len(args) == 1
- self.listener.contextChanged(args[0])
+ self.listener.contextChanged(_toContextArray(args[0]))
elif name == "contextRemoved":
assert len(args) == 1
self.listener.contextRemoved(args[0])
@@ -103,7 +102,7 @@ class ChannelEventListener(channel.EventListener):
self.listener.containerResumed(args[0])
else:
raise IOError("RunControl service: unknown event: " + name);
- except exceptions.Exception as x:
+ except Exception as x:
self.service.channel.terminate(x)
class RunControlProxy(runcontrol.RunControlService):
@@ -151,3 +150,9 @@ class RunControlProxy(runcontrol.RunControlService):
contexts = args[1]
done.doneGetChildren(self.token, error, contexts)
return GetChildrenCommand().token
+
+def _toContextArray(o):
+ if o is None: return None
+ ctx = []
+ for m in o: ctx.append(RunContext(m))
+ return ctx
diff --git a/python/src/tcf/services/runcontrol.py b/python/src/tcf/services/runcontrol.py
index a80585d1c..cd48f40fe 100644
--- a/python/src/tcf/services/runcontrol.py
+++ b/python/src/tcf/services/runcontrol.py
@@ -9,7 +9,6 @@
# * Wind River Systems - initial API and implementation
# *******************************************************************************
-import exceptions
from tcf import services
NAME = "RunControl"
@@ -159,39 +158,39 @@ class RunControlService(services.Service):
def getContext(self, id, done):
"""
Retrieve context properties for given context ID.
-
+
@param id - context ID.
@param done - callback interface called when operation is completed.
"""
- raise exceptions.NotImplementedError("Abstract method")
+ raise NotImplementedError("Abstract method")
def getChildren(self, parent_context_id, done):
"""
Retrieve children of given context.
-
+
@param parent_context_id - parent context ID. Can be null -
to retrieve top level of the hierarchy, or one of context IDs retrieved
by previous getContext or getChildren commands.
@param done - callback interface called when operation is completed.
"""
- raise exceptions.NotImplementedError("Abstract method")
+ raise NotImplementedError("Abstract method")
def addListener(self, listener):
"""
Add run control event listener.
@param listener - run control event listener to add.
"""
- raise exceptions.NotImplementedError("Abstract method")
+ raise NotImplementedError("Abstract method")
def removeListener(self, listener):
"""
Remove run control event listener.
@param listener - run control event listener to remove.
"""
- raise exceptions.NotImplementedError("Abstract method")
+ raise NotImplementedError("Abstract method")
-class RunControlError(exceptions.Exception):
+class RunControlError(Exception):
pass
class DoneGetState(object):
@@ -251,7 +250,7 @@ class RunControlContext(object):
def __str__(self):
return "[Run Control Context %s]" % self._props
-
+
def getProperties(self):
"""
Get context properties. See PROP_* definitions for property names.
@@ -375,7 +374,7 @@ class RunControlContext(object):
@param done - command result call back object.
@return pending command handle, can be used to cancel the command.
"""
- raise exceptions.NotImplementedError("Abstract method")
+ raise NotImplementedError("Abstract method")
def suspend(self, done):
"""
@@ -384,7 +383,7 @@ class RunControlContext(object):
@param done - command result call back object.
@return pending command handle, can be used to cancel the command.
"""
- raise exceptions.NotImplementedError("Abstract method")
+ raise NotImplementedError("Abstract method")
# def resume(self, mode, count, done):
# """
@@ -395,7 +394,7 @@ class RunControlContext(object):
# @param done - command result call back object.
# @return pending command handle, can be used to cancel the command.
# """
-# raise exceptions.NotImplementedError("Abstract method")
+# raise NotImplementedError("Abstract method")
def resume(self, mode, count, params, done):
"""
@@ -407,7 +406,7 @@ class RunControlContext(object):
@param done - command result call back object.
@return pending command handle, can be used to cancel the command.
"""
- raise exceptions.NotImplementedError("Abstract method")
+ raise NotImplementedError("Abstract method")
def terminate(self, done):
"""
@@ -415,7 +414,7 @@ class RunControlContext(object):
@param done - command result call back object.
@return pending command handle, can be used to cancel the command.
"""
- raise exceptions.NotImplementedError("Abstract method")
+ raise NotImplementedError("Abstract method")
class RunControlListener(object):
"Service events listener interface."
@@ -456,7 +455,7 @@ class RunControlListener(object):
"""
Called when target simultaneously suspends multiple threads in a container
(process, core, etc.).
-
+
@param context - ID of a context responsible for the event. It can be container ID or
any one of container children, for example, it can be thread that hit "suspend all" breakpoint.
Client expected to move focus (selection) to this context.
@@ -470,7 +469,7 @@ class RunControlListener(object):
"""
Called when target simultaneously resumes multiple threads in a container (process,
core, etc.).
-
+
@param context_ids - full list of all contexts that were resumed.
"""
pass
diff --git a/python/src/tcf/services/stacktrace.py b/python/src/tcf/services/stacktrace.py
index 1cb47b363..f0d477825 100644
--- a/python/src/tcf/services/stacktrace.py
+++ b/python/src/tcf/services/stacktrace.py
@@ -4,12 +4,11 @@
# * 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
#******************************************************************************
-import exceptions
from tcf import services
NAME = "StackTrace"
@@ -32,19 +31,19 @@ PROP_ARGUMENTS_ADDRESS = "ArgsAddr" # Number, memory address of function argu
class StackTraceService(services.Service):
def getName(self):
return NAME
-
+
def getContext(self, ids, done):
"""
Retrieve context info for given context IDs.
-
+
The command will fail if parent thread is not suspended.
Client can use Run Control service to suspend a thread.
-
+
@param ids - array of context IDs.
@param done - call back interface called when operation is completed.
"""
- raise exceptions.NotImplementedError("Abstract method")
-
+ raise NotImplementedError("Abstract method")
+
def getChildren(self, parent_context_id, done):
"""
Retrieve stack trace context list.
@@ -52,14 +51,14 @@ class StackTraceService(services.Service):
Some targets have more then one stack. In such case children of a thread
are stacks, and stack frames are deeper in the hierarchy - they can be
retrieved with additional getChildren commands.
-
+
The command will fail if parent thread is not suspended.
Client can use Run Control service to suspend a thread.
-
+
@param parent_context_id - parent context ID.
@param done - call back interface called when operation is completed.
"""
- raise exceptions.NotImplementedError("Abstract method")
+ raise NotImplementedError("Abstract method")
class DoneGetContext(object):
"""
@@ -92,7 +91,7 @@ class StackTraceContext(object):
"""
def __init__(self, props):
self._props = props or {}
-
+
def __str__(self):
return "[Stack Trace Context %s]" % self._props
@@ -102,7 +101,7 @@ class StackTraceContext(object):
@return context ID.
"""
return self._props.get(PROP_ID)
-
+
def getParentID(self):
"""
Get parent context ID.
diff --git a/python/src/tcf/services/symbols.py b/python/src/tcf/services/symbols.py
index 2f03f7402..807ee6cca 100644
--- a/python/src/tcf/services/symbols.py
+++ b/python/src/tcf/services/symbols.py
@@ -4,12 +4,11 @@
# * 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
#******************************************************************************
-import exceptions
from tcf import services
# Service name.
@@ -81,7 +80,7 @@ class Symbol(object):
def __str__(self):
return "[Symbol Context %s]" % self._props
-
+
def getID(self):
"""
Get symbol ID.
@@ -222,7 +221,7 @@ class Symbol(object):
@return register ID or null.
"""
return self._props.get(PROP_REGISTER)
-
+
def getProperties(self):
"""
Get complete map of context properties.
@@ -233,17 +232,17 @@ class Symbol(object):
class SymbolsService(services.Service):
def getName(self):
return NAME
-
+
def getContext(self, id, done):
"""
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.
"""
- raise exceptions.NotImplementedError("Abstract method")
+ raise NotImplementedError("Abstract method")
def getChildren(self, parent_context_id, done):
"""
@@ -251,48 +250,48 @@ class SymbolsService(services.Service):
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.
"""
- raise exceptions.NotImplementedError("Abstract method")
+ raise NotImplementedError("Abstract method")
def find(self, context_id, ip, name, done):
"""
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 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 exceptions.NotImplementedError("Abstract method")
+ raise NotImplementedError("Abstract method")
def findByAddr(self, context_id, addr, done):
"""
Search symbol with given address in given context.
The context can be memory space, process, thread or stack frame.
-
+
@param context_id - a search scope.
@param addr - symbol address.
@param done - call back interface called when operation is completed.
@return - pending command handle.
"""
- raise exceptions.NotImplementedError("Abstract method")
+ raise NotImplementedError("Abstract method")
def list(self, context_id, done):
"""
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.
"""
- raise exceptions.NotImplementedError("Abstract method")
+ raise NotImplementedError("Abstract method")
def findFrameInfo(self, context_id, address, done):
"""
@@ -302,7 +301,7 @@ class SymbolsService(services.Service):
@param done - call back interface called when operation is completed.
@return - pending command handle.
"""
- raise exceptions.NotImplementedError("Abstract method")
+ raise NotImplementedError("Abstract method")
class DoneGetContext(object):
"""
diff --git a/python/src/tcf/shell.py b/python/src/tcf/shell.py
index 7e0f8c54f..bf29f0ec0 100644
--- a/python/src/tcf/shell.py
+++ b/python/src/tcf/shell.py
@@ -15,7 +15,7 @@ TCF extensions.
Usage:
python tcf/shell.py
-
+
Commands:
connect(params) - Connect to TCF peer, params = "<protocol>:<host>:<port>"
cmd.<service>.<command<(args)
diff --git a/python/src/tcf/tests/BasicTests.py b/python/src/tcf/tests/BasicTests.py
index 917ddcc07..da8200b12 100644
--- a/python/src/tcf/tests/BasicTests.py
+++ b/python/src/tcf/tests/BasicTests.py
@@ -9,7 +9,7 @@
# * Wind River Systems - initial API and implementation
# *******************************************************************************
-import sys, time, threading, exceptions
+import sys, time, threading
import tcf
from tcf import protocol, channel, errors
from tcf.util import sync
@@ -24,12 +24,13 @@ class TraceListener(channel.TraceListener):
print>>sys.stderr, "*** closed ***", error
_suspended = []
+_memory = []
def test():
protocol.startEventQueue()
try:
c = tcf.connect("TCP:127.0.0.1:1534")
- except exceptions.Exception as e:
+ except Exception as e:
protocol.log(e)
sys.exit()
assert c.state == channel.STATE_OPEN
@@ -51,7 +52,9 @@ def test():
testDataCache(c)
testProcesses(c)
testFileSystem(c)
- except exceptions.Exception as e:
+ testMemory(c)
+ testMemoryMap(c)
+ except Exception as e:
protocol.log(e)
if c.state == channel.STATE_OPEN:
@@ -62,7 +65,7 @@ def test():
def testRunControl(c):
lock = threading.Condition()
from tcf.services import runcontrol
- def r3():
+ def getContexts():
rctrl = c.getRemoteService(runcontrol.NAME)
pending = []
class DoneGetContext(runcontrol.DoneGetContext):
@@ -105,9 +108,9 @@ def testRunControl(c):
lock.notify()
pending.append(rctrl.getChildren(None, DoneGetChildren()))
with lock:
- protocol.invokeLater(r3)
+ protocol.invokeLater(getContexts)
lock.wait(5000)
- def r4():
+ def listenerTest():
rc = c.getRemoteService(runcontrol.NAME)
class RCListener(runcontrol.RunControlListener):
def contextSuspended(self, *args):
@@ -136,10 +139,10 @@ def testRunControl(c):
with lock: lock.notify()
context.resume(runcontrol.RM_RESUME, 1, None, DoneResume())
rc.getContext(_suspended[0], DoneGetContext())
-
+
if _suspended:
with lock:
- protocol.invokeLater(r4)
+ protocol.invokeLater(listenerTest)
lock.wait(5000)
def testBreakpoints(c):
@@ -381,7 +384,7 @@ def testDataCache(c):
def startDataRetrieval(self):
rc = self._channel.getRemoteService(runcontrol.NAME)
if not rc:
- self.set(None, exceptions.Exception("No RunControl service"), None)
+ self.set(None, Exception("No RunControl service"), None)
return
cache = self
pending = []
@@ -429,6 +432,58 @@ def testFileSystem(c):
print "FileSystem roots:", roots
user = fs.user().get()
print "User info: ", user
-
+
+def testMemory(c):
+ lock = threading.Condition()
+ from tcf.services import memory
+ def getContexts():
+ mem = c.getRemoteService(memory.NAME)
+ pending = []
+ class DoneGetContext(memory.DoneGetContext):
+ def doneGetContext(self, token, error, context):
+ pending.remove(token)
+ if error:
+ protocol.log("Error from Memory.getContext", error)
+ else:
+ print context
+ if len(pending) == 0:
+ with lock:
+ lock.notify()
+ class DoneGetChildren(memory.DoneGetChildren):
+ def doneGetChildren(self, token, error, context_ids):
+ pending.remove(token)
+ if error:
+ protocol.log("Error from Memory.GetChildren", error)
+ else:
+ for c in context_ids:
+ _memory.append(c)
+ pending.append(mem.getContext(c, DoneGetContext()))
+ pending.append(mem.getChildren(c, self))
+ if len(pending) == 0:
+ with lock:
+ lock.notify()
+ pending.append(mem.getChildren(None, DoneGetChildren()))
+ with lock:
+ protocol.invokeLater(getContexts)
+ lock.wait(5000)
+
+def testMemoryMap(c):
+ if not _memory: return
+ from tcf.services import memorymap
+ cmd = sync.CommandControl(c)
+ try:
+ mm = cmd.MemoryMap
+ except AttributeError:
+ # no MemoryMap service
+ return
+ id = _memory[0]
+ map = mm.get(id).get()
+ print "Memory map:", map
+ region = memorymap.MemoryRegion({memorymap.PROP_FILE_NAME : "/tmp/system.elf"})
+ print "Memory map: setting map", [region]
+ mm.set(id, [region]).get()
+ map = mm.get(id).get()
+ print "Memory map:", map
+
if __name__ == '__main__':
test()
diff --git a/python/src/tcf/transport.py b/python/src/tcf/transport.py
index 7a54ce0f1..1a046cee1 100644
--- a/python/src/tcf/transport.py
+++ b/python/src/tcf/transport.py
@@ -9,7 +9,7 @@
# * Wind River Systems - initial API and implementation
# *******************************************************************************
-import threading, exceptions
+import threading
import protocol, channel
from tcf.services import locator
@@ -22,7 +22,7 @@ class TransportProvider(object):
"""
TransportProvider represents communication protocol that can be used to open TCF communication channels.
Examples of transports are: TCP/IP, RS-232, USB.
-
+
Client can implement this interface if they want to provide support for a transport that is not
supported directly by the framework.
"""
@@ -32,8 +32,8 @@ class TransportProvider(object):
Return transport name. Same as used as peer attribute, @see IPeer.ATTR_TRANSPORT_NAME
@return transport name.
"""
- raise exceptions.NotImplementedError("Abstract method")
-
+ raise NotImplementedError("Abstract method")
+
def openChannel(self, peer):
"""
Open channel to communicate with this peer using this transport.
@@ -43,13 +43,13 @@ class TransportProvider(object):
@param peer - a IPeer object that describes remote end-point of the channel.
@return TCF communication channel.
"""
- raise exceptions.NotImplementedError("Abstract method")
+ raise NotImplementedError("Abstract method")
def addTransportProvider(transport):
name = transport.getName()
assert name
with _lock:
- if _transports.get(name): raise exceptions.Exception("Already registered: " + name)
+ if _transports.get(name): raise Exception("Already registered: " + name)
_transports[name] = transport
def removeTransportProvider(transport):
@@ -72,7 +72,7 @@ def channelOpened(channel):
for l in _listeners:
try:
l.onChannelOpen(channel)
- except exceptions.Exception as x:
+ except Exception as x:
protocol.log("Exception in channel listener", x)
def channelClosed(channel, error):
@@ -98,23 +98,23 @@ class TCPTransportProvider(TransportProvider):
attrs = p.getAttributes()
host = attrs.get(peer.ATTR_IP_HOST)
port = attrs.get(peer.ATTR_IP_PORT)
- if not host: raise exceptions.RuntimeError("No host name")
+ if not host: raise RuntimeError("No host name")
from channel.ChannelTCP import ChannelTCP
return ChannelTCP(p, host, _parsePort(port))
def _parsePort(port):
- if not port: raise exceptions.Exception("No port number")
+ if not port: raise Exception("No port number")
try:
return int(port)
- except exceptions.Exception:
- raise exceptions.RuntimeError(
+ except Exception:
+ raise RuntimeError(
"Invalid value of \"Port\" attribute. Must be decimal number.")
def sendEvent(service_name, event_name, data):
"""
Transmit TCF event message.
The message is sent to all open communication channels - broadcasted.
-
+
This is internal API, TCF clients should use protocol.sendEvent().
"""
for c in _channels:
@@ -128,13 +128,13 @@ def sync(done):
Call back after TCF messages sent by this host up to this moment are delivered
to their intended targets. This method is intended for synchronization of messages
across multiple channels.
-
+
Note: Cross channel synchronization can reduce performance and throughput.
Most clients don't need cross channel synchronization and should not call this method.
-
+
@param done will be executed by dispatch thread after communication
messages are delivered to corresponding targets.
-
+
This is internal API, TCF clients should use protocol.sync().
"""
set = set()
diff --git a/python/src/tcf/util/cache.py b/python/src/tcf/util/cache.py
index 99aa13c12..aaa8622c3 100644
--- a/python/src/tcf/util/cache.py
+++ b/python/src/tcf/util/cache.py
@@ -9,7 +9,7 @@
# * Wind River Systems - initial API and implementation
# *******************************************************************************
-import cStringIO, exceptions
+import cStringIO
from tcf import protocol, channel
class DataCache(object):
@@ -20,22 +20,22 @@ class DataCache(object):
2. Invalid - cache is out of sync, start data retrieval by calling validate()
3. Pending - cache is waiting result of a command that was sent to remote peer
4. Disposed - cache is disposed and cannot be used to store data.
-
+
A cache instance can be created on any data type that needs to be cached.
Examples might be context children list, context properties, context state, memory data,
register data, symbol, variable, etc.
Clients of cache items can register for cache changes, but don't need to think about any particular events
since that is handled by the cache item itself.
-
+
A typical cache client should implement Runnable interface.
The implementation of run() method should:
-
+
Validate all cache items required for client task.
If anything is invalid then client should not alter any shared data structures,
should discard any intermediate results and register (wait) for changes of invalid cache instance(s) state.
When cache item state changes, client is invoked again and full validation is restarted.
Once everything is valid, client completes its task in a single dispatch cycle.
-
+
Note: clients should never retain copies of remote data across dispatch cycles!
Such data would get out of sync and compromise data consistency.
All remote data and everything derived from remote data should be kept in cache items
@@ -267,4 +267,4 @@ class DataCache(object):
Sub-classes should override this method to implement actual data retrieval logic.
@return True is all done, False if retrieval is in progress.
"""
- raise exceptions.NotImplementedError("Abstract method")
+ raise NotImplementedError("Abstract method")
diff --git a/python/src/tcf/util/event.py b/python/src/tcf/util/event.py
index 3be8d694e..3e5e92118 100644
--- a/python/src/tcf/util/event.py
+++ b/python/src/tcf/util/event.py
@@ -9,7 +9,7 @@
# * Wind River Systems - initial API and implementation
# *******************************************************************************
-import exceptions, threading
+import threading
from tcf import protocol, channel
class DelegatingEventListener(channel.EventListener):
@@ -19,7 +19,7 @@ class DelegatingEventListener(channel.EventListener):
try:
args = channel.fromJSONSequence(data)
self._callable(self.svc_name, name, *args)
- except exceptions.Exception as x:
+ except Exception as x:
protocol.log("Error decoding event data", x)
def _print_event(service, name, *args):
@@ -79,7 +79,7 @@ class Event(object):
self.name = name
try:
self.args = channel.fromJSONSequence(data)
- except exceptions.Exception as x:
+ except Exception as x:
protocol.log("Error decoding event data", x)
def __str__(self):
return "Event: %s.%s%s" % (self.service, self.name, tuple(self.args))
diff --git a/python/src/tcf/util/logging.py b/python/src/tcf/util/logging.py
index c18931903..7ac2c22e3 100644
--- a/python/src/tcf/util/logging.py
+++ b/python/src/tcf/util/logging.py
@@ -48,7 +48,7 @@ def trace(msg):
logger implementation may or may not inject its own timestamp. For
tracing, we definitely need one, so we introduce a minimal, relative-time
stamp.
-
+
@param msg the trace message
"""
protocol.log('%s %s' % (getDebugTime(), msg))
diff --git a/python/src/tcf/util/sync.py b/python/src/tcf/util/sync.py
index 959d0f999..2aad54532 100644
--- a/python/src/tcf/util/sync.py
+++ b/python/src/tcf/util/sync.py
@@ -9,7 +9,7 @@
# * Wind River Systems - initial API and implementation
# *******************************************************************************
-import threading, exceptions, types
+import threading, types
from tcf import protocol
from tcf.channel.Command import Command
@@ -28,11 +28,11 @@ class DispatchWrapper(object):
class CommandControl(object):
"""Provides a simple interface to send commands to remote services
and receive results.
-
+
Usage:
> cmd = CommandControl(channel)
> cmd.<service>.<command>(<args>)
-
+
Examples:
# send command, but don't wait for result:
> cmd.RunControl.suspend("system")
@@ -60,7 +60,7 @@ class CommandControl(object):
return services
if attr in services:
return ServiceWrapper(self, attr)
- raise exceptions.AttributeError("Unknown service: %s. Use one of %s" % (attr, services))
+ raise AttributeError("Unknown service: %s. Use one of %s" % (attr, services))
def invoke(self, service, command, *args, **kwargs):
cmd = None
if not protocol.isDispatchThread():
diff --git a/python/src/tcf/util/task.py b/python/src/tcf/util/task.py
index e4230c9dc..8c4e3ed92 100644
--- a/python/src/tcf/util/task.py
+++ b/python/src/tcf/util/task.py
@@ -9,7 +9,7 @@
# Wind River Systems - initial API and implementation
#******************************************************************************
-import threading, exceptions
+import threading
from tcf import protocol
class Task(object):
@@ -18,12 +18,12 @@ class Task(object):
communication over TCF framework. Methods are provided to check if the communication is
complete, to wait for its completion, and to retrieve the result of
the communication.
-
+
Task is useful when communication is requested by a thread other then TCF dispatch thread.
If client has a global state, for example, cached remote data, multithreading should be avoided,
because it is extremely difficult to ensure absence of racing conditions or deadlocks in such environment.
Such clients should consider message driven design, see DataCache and its usage as an example.
-
+
If a client is extending Task it should implement run() method to perform actual communications.
The run() method will be execute by TCF dispatch thread, and client code should then call either done() or
error() to indicate that task computations are complete.
@@ -33,7 +33,7 @@ class Task(object):
__error = None
__canceled = False
__channel = None
-
+
def __init__(self, target=None, *args, **kwargs):
"""
Construct a TCF task object and schedule it for execution.
@@ -42,7 +42,7 @@ class Task(object):
kwargs["done"] = self.__done
else:
target = self.run
-
+
self._target = target
self._args = args
self._kwargs = kwargs
@@ -89,10 +89,10 @@ class Task(object):
def __doRun(self):
try:
self._target(*self._args, **self._kwargs)
- except exceptions.Exception as x:
+ except Exception as x:
if not self.__is_done and self.__error is None:
self.error(x)
-
+
def __done(self, error, result):
if error:
self.error(error)
@@ -100,8 +100,8 @@ class Task(object):
self.done(result)
def run(self, *args, **kwargs):
- raise exceptions.NotImplementedError("Abstract method")
-
+ raise NotImplementedError("Abstract method")
+
def done(self, result):
with self._lock:
assert protocol.isDispatchThread()
@@ -119,7 +119,7 @@ class Task(object):
"""
Set a __error and notify all threads waiting for the task to complete.
The method is supposed to be called in response to executing of run() method of this task.
-
+
@param __error - computation __error.
"""
assert protocol.isDispatchThread()
@@ -139,7 +139,7 @@ class Task(object):
with self._lock:
if self.isDone(): return False
self.__canceled = True
- self.__error = exceptions.Exception("Canceled")
+ self.__error = Exception("Canceled")
if self.__channel:
self.__channel.removeChannelListener(self.channel_listener)
self._lock.notifyAll()
@@ -149,7 +149,7 @@ class Task(object):
"""
Waits if necessary for the computation to complete, and then
retrieves its result.
-
+
@return the computed result
@throws CancellationException if the computation was __canceled
@throws ExecutionException if the computation threw an
@@ -164,14 +164,14 @@ class Task(object):
if timeout and not self.isDone():
raise TimeoutException("Timed out")
if self.__error:
- raise exceptions.Exception("TCF task aborted", self.__error)
+ raise Exception("TCF task aborted", self.__error)
return self.__result
def isCancelled(self):
"""
Returns <tt>true</tt> if this task was __canceled before it completed
normally.
-
+
@return <tt>true</tt> if task was __canceled before it completed
"""
with self._lock:
@@ -180,11 +180,11 @@ class Task(object):
def isDone(self):
"""
Returns <tt>true</tt> if this task completed.
-
+
Completion may be due to normal termination, an exception, or
cancellation -- in all of these cases, this method will return
<tt>true</tt>.
-
+
@return <tt>true</tt> if this task completed.
"""
with self._lock:
@@ -200,5 +200,5 @@ class Task(object):
def getResult(self):
return self.__result
-class TimeoutException(exceptions.Exception):
+class TimeoutException(Exception):
pass
diff --git a/python/todo.twiki b/python/todo.twiki
index 028a48279..72bb2f848 100644
--- a/python/todo.twiki
+++ b/python/todo.twiki
@@ -18,8 +18,8 @@
* [done] LineNumbers
* [done] Processes
* [done] FileSystem
- * MemoryMap
- * Memory
+ * [done] MemoryMap
+ * [done] Memory
* PathMap
* Diagnostics
* Disassembly
@@ -29,6 +29,7 @@
* Local services:
* [incomplete] ZeroCopy
* [done] Locator service (discovery)
+ * iterate over network interfaces
* Utilities:
* [done] ACPM data cache
* [done] TCFTask

Back to the top