Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'python/src/tcf/services/remote')
-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
10 files changed, 361 insertions, 28 deletions
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

Back to the top