Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
authorFrederic Leger2014-03-13 13:59:09 +0000
committerFrederic Leger2014-03-13 15:06:58 +0000
commitfcee9e4889c7304a4210df4720432234ae2d4778 (patch)
tree922420eebc2ff3a9f70962b5d003fb33cc825b9c /python
parente5d5f9bbe2c36eb1bd2debfd27411b55d0492bb2 (diff)
downloadorg.eclipse.tcf-fcee9e4889c7304a4210df4720432234ae2d4778.tar.gz
org.eclipse.tcf-fcee9e4889c7304a4210df4720432234ae2d4778.tar.xz
org.eclipse.tcf-fcee9e4889c7304a4210df4720432234ae2d4778.zip
Improve debug output in the case of exception.
Another ound of adding the stacktrace at the time of the exception.
Diffstat (limited to 'python')
-rw-r--r--python/src/tcf/services/remote/BreakpointsProxy.py4
-rw-r--r--python/src/tcf/services/remote/ContextQueryProxy.py2
-rw-r--r--python/src/tcf/services/remote/DiagnosticsProxy.py8
-rw-r--r--python/src/tcf/services/remote/ExpressionsProxy.py7
-rw-r--r--python/src/tcf/services/remote/LocatorProxy.py50
-rw-r--r--python/src/tcf/services/remote/MemoryMapProxy.py4
-rw-r--r--python/src/tcf/services/remote/MemoryProxy.py12
-rw-r--r--python/src/tcf/services/remote/PathMapProxy.py4
-rw-r--r--python/src/tcf/services/remote/ProcessesProxy.py4
-rw-r--r--python/src/tcf/services/remote/RegistersProxy.py4
-rw-r--r--python/src/tcf/services/remote/RunControlProxy.py32
-rw-r--r--python/src/tcf/services/remote/StreamsProxy.py6
-rw-r--r--python/src/tcf/services/remote/TerminalsProxy.py4
13 files changed, 113 insertions, 28 deletions
diff --git a/python/src/tcf/services/remote/BreakpointsProxy.py b/python/src/tcf/services/remote/BreakpointsProxy.py
index c10ea3c9e..85016017f 100644
--- a/python/src/tcf/services/remote/BreakpointsProxy.py
+++ b/python/src/tcf/services/remote/BreakpointsProxy.py
@@ -1,5 +1,5 @@
# *****************************************************************************
-# * Copyright (c) 2011, 2013 Wind River Systems, Inc. and others.
+# * Copyright (c) 2011, 2013-2014 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
@@ -49,6 +49,8 @@ class ChannelEventListener(channel.EventListener):
else:
raise IOError("Breakpoints service: unknown event: " + name)
except Exception as x:
+ import sys
+ x.tb = sys.exc_info()[2]
self.service.channel.terminate(x)
diff --git a/python/src/tcf/services/remote/ContextQueryProxy.py b/python/src/tcf/services/remote/ContextQueryProxy.py
index bd83911eb..6ea3e0cc0 100644
--- a/python/src/tcf/services/remote/ContextQueryProxy.py
+++ b/python/src/tcf/services/remote/ContextQueryProxy.py
@@ -1,5 +1,5 @@
# *****************************************************************************
-# * Copyright (c) 2012, 2013 Wind River Systems, Inc. and others.
+# * Copyright (c) 2012, 2013-2014 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
diff --git a/python/src/tcf/services/remote/DiagnosticsProxy.py b/python/src/tcf/services/remote/DiagnosticsProxy.py
index 82e135364..dd7fb4132 100644
--- a/python/src/tcf/services/remote/DiagnosticsProxy.py
+++ b/python/src/tcf/services/remote/DiagnosticsProxy.py
@@ -1,5 +1,5 @@
# *****************************************************************************
-# * Copyright (c) 2011, 2013 Wind River Systems, Inc. and others.
+# * Copyright (c) 2011, 2013-2014 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
@@ -59,9 +59,9 @@ class DiagnosticsProxy(diagnostics.DiagnosticsService):
errMap = err.getAttributes()
else:
errMap = {
- errors.ERROR_TIME : int(time.time() * 1000),
- errors.ERROR_CODE : errors.TCF_ERROR_OTHER,
- errors.ERROR_FORMAT : err.message
+ errors.ERROR_TIME: int(time.time() * 1000),
+ errors.ERROR_CODE: errors.TCF_ERROR_OTHER,
+ errors.ERROR_FORMAT: err.message
}
done = self._makeCallback(done)
service = self
diff --git a/python/src/tcf/services/remote/ExpressionsProxy.py b/python/src/tcf/services/remote/ExpressionsProxy.py
index 19dde711b..4d21ca895 100644
--- a/python/src/tcf/services/remote/ExpressionsProxy.py
+++ b/python/src/tcf/services/remote/ExpressionsProxy.py
@@ -1,5 +1,5 @@
# *****************************************************************************
-# * Copyright (c) 2011, 2013 Wind River Systems, Inc. and others.
+# * Copyright (c) 2011, 2013-2014 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
@@ -53,7 +53,8 @@ class ExpressionsProxy(expressions.ExpressionsService):
if not error:
assert len(args) == 2
error = self.toError(args[0])
- ctx = expressions.Expression(args[1])
+ if args[1]:
+ ctx = expressions.Expression(args[1])
done.doneCreate(self.token, error, ctx)
return CreateCommand().token
@@ -159,4 +160,6 @@ class ChannelEventListener(channel.EventListener):
else:
raise IOError("Expressions service: unknown event: " + name)
except Exception as x:
+ import sys
+ x.tb = sys.exc_info()[2]
self.service.channel.terminate(x)
diff --git a/python/src/tcf/services/remote/LocatorProxy.py b/python/src/tcf/services/remote/LocatorProxy.py
index 730c095bb..3fbacd340 100644
--- a/python/src/tcf/services/remote/LocatorProxy.py
+++ b/python/src/tcf/services/remote/LocatorProxy.py
@@ -1,5 +1,5 @@
# *****************************************************************************
-# * Copyright (c) 2011, 2013 Wind River Systems, Inc. and others.
+# * Copyright (c) 2011, 2013-2014 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
@@ -32,6 +32,9 @@ class ChannelEventListener(channel.EventListener):
self.channel = proxy.channel
def event(self, name, data):
+ if self.proxy.peers is None:
+ return # peers not synchronized yet
+
try:
args = channel.fromJSONSequence(data)
if name == "peerAdded":
@@ -91,20 +94,42 @@ class ChannelEventListener(channel.EventListener):
else:
raise IOError("Locator service: unknown event: " + name)
except Exception as x:
+ import sys
+ x.tb = sys.exc_info()[2]
self.channel.terminate(x)
class LocatorProxy(locator.LocatorService):
def __init__(self, channel):
self.channel = channel
- self.peers = {}
+ self.peers = None # not yet synchronized
self.listeners = []
self.get_peers_done = False
self.event_listener = ChannelEventListener(self)
channel.addEventListener(self, self.event_listener)
+ def getAgentID(self, done):
+ done = self._makeCallback(done)
+ service = self
+
+ class GetAgentIDCommand(Command):
+ def __init__(self):
+ super(GetAgentIDCommand, self).__init__(service.channel,
+ service, "getAgentID",
+ None)
+
+ def done(self, error, args):
+ agentID = None
+ if not error:
+ assert len(args) == 2
+ error = self.toError(args[0])
+ agentID = args[1]
+ done.doneGetAgentID(self.token, error, agentID)
+ return GetAgentIDCommand().token
+
def getPeers(self):
- return self.peers
+ assert protocol.isDispatchThread()
+ return self.peers # None if not synchronized yet
def redirect(self, _peer, done):
done = self._makeCallback(done)
@@ -119,6 +144,24 @@ class LocatorProxy(locator.LocatorService):
if not error:
assert len(args) == 1
error = self.toError(args[0])
+
+ if not error and service.peers:
+ # The redirect was a success. Invalidate all the peers
+ # already detected.
+
+ for peerId in list(service.peers.keys()):
+ del service.peers[peerId]
+ for l in service.listeners:
+ try:
+ l.peerRemoved(peerId)
+ except Exception as x:
+ protocol.log("Unhandled exception in "\
+ "Locator listener", x)
+
+ assert len(service.peers) == 0
+ service.peers = None
+ service.get_peers_done = False
+
done.doneRedirect(self.token, error)
return RedirectCommand().token
@@ -156,6 +199,7 @@ class LocatorProxy(locator.LocatorService):
protocol.log("Locator error", error)
return
c = args[1]
+ service.peers = {} # peers list synchronized
if c:
for m in c:
peerID = m.get(peer.ATTR_ID)
diff --git a/python/src/tcf/services/remote/MemoryMapProxy.py b/python/src/tcf/services/remote/MemoryMapProxy.py
index f21eaf0a4..76ed14f50 100644
--- a/python/src/tcf/services/remote/MemoryMapProxy.py
+++ b/python/src/tcf/services/remote/MemoryMapProxy.py
@@ -1,5 +1,5 @@
# *****************************************************************************
-# * Copyright (c) 2011, 2013 Wind River Systems, Inc. and others.
+# * Copyright (c) 2011, 2013-2014 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
@@ -82,6 +82,8 @@ class ChannelEventListener(channel.EventListener):
else:
raise IOError("MemoryMap service: unknown event: " + name)
except Exception as x:
+ import sys
+ x.tb = sys.exc_info()[2]
self.service.channel.terminate(x)
diff --git a/python/src/tcf/services/remote/MemoryProxy.py b/python/src/tcf/services/remote/MemoryProxy.py
index 8d84d3746..fdc51bd7a 100644
--- a/python/src/tcf/services/remote/MemoryProxy.py
+++ b/python/src/tcf/services/remote/MemoryProxy.py
@@ -1,5 +1,5 @@
# *****************************************************************************
-# * Copyright (c) 2011, 2013 Wind River Systems, Inc. and others.
+# * Copyright (c) 2011, 2013-2014 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
@@ -229,10 +229,10 @@ class MemoryCommand(Command):
cmd = self.getCommandString()
if len(cmd) > 72:
cmd = cmd[0:72] + "..."
- e = MemoryErrorReport("TCF command exception:\nCommand: %s\n" +
- "Exception: %s\nError code: %d" %
- (cmd, errors.toErrorString(data), code),
- data, addr, ranges)
+ msg = "TCF command exception:\nCommand: %s\n" % cmd + \
+ "Exception: %s\nError code: %d" % (errors.toErrorString(data),
+ code)
+ e = MemoryErrorReport(msg, data, addr, ranges)
caused_by = data.get(errors.ERROR_CAUSED_BY)
if caused_by is not None:
e.caused_by = self.toError(caused_by, False)
@@ -265,6 +265,8 @@ class ChannelEventListener(channel.EventListener):
else:
raise IOError("Memory service: unknown event: " + name)
except Exception as x:
+ import sys
+ x.tb = sys.exc_info()[2]
self.service.channel.terminate(x)
diff --git a/python/src/tcf/services/remote/PathMapProxy.py b/python/src/tcf/services/remote/PathMapProxy.py
index b4755521b..42da055f3 100644
--- a/python/src/tcf/services/remote/PathMapProxy.py
+++ b/python/src/tcf/services/remote/PathMapProxy.py
@@ -1,5 +1,5 @@
# *****************************************************************************
-# * Copyright (c) 2011, 2013 Wind River Systems, Inc. and others.
+# * Copyright (c) 2011, 2013-2014 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
@@ -24,6 +24,8 @@ class ChannelEventListener(channel.EventListener):
if name == "changed":
self.listener.changed()
except Exception as x:
+ import sys
+ x.tb = sys.exc_info()[2]
self.service.channel.terminate(x)
diff --git a/python/src/tcf/services/remote/ProcessesProxy.py b/python/src/tcf/services/remote/ProcessesProxy.py
index bb9b5f9a6..c4fbc901b 100644
--- a/python/src/tcf/services/remote/ProcessesProxy.py
+++ b/python/src/tcf/services/remote/ProcessesProxy.py
@@ -1,5 +1,5 @@
# *****************************************************************************
-# * Copyright (c) 2011, 2013 Wind River Systems, Inc. and others.
+# * Copyright (c) 2011, 2013-2014 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
@@ -239,6 +239,8 @@ class ChannelEventListener(channel.EventListener):
else:
raise IOError("Processes service: unknown event: " + name)
except Exception as x:
+ import sys
+ x.tb = sys.exc_info()[2]
self.service.channel.terminate(x)
diff --git a/python/src/tcf/services/remote/RegistersProxy.py b/python/src/tcf/services/remote/RegistersProxy.py
index aa52f34b4..f93ee6d64 100644
--- a/python/src/tcf/services/remote/RegistersProxy.py
+++ b/python/src/tcf/services/remote/RegistersProxy.py
@@ -1,5 +1,5 @@
# *****************************************************************************
-# * Copyright (c) 2011, 2013 Wind River Systems, Inc. and others.
+# * Copyright (c) 2011, 2013-2014 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
@@ -206,4 +206,6 @@ class ChannelEventListener(channel.EventListener):
else:
raise IOError("Registers service: unknown event: " + name)
except Exception as x:
+ import sys
+ x.tb = sys.exc_info()[2]
self.service.channel.terminate(x)
diff --git a/python/src/tcf/services/remote/RunControlProxy.py b/python/src/tcf/services/remote/RunControlProxy.py
index 8aef1bcaa..7675a129c 100644
--- a/python/src/tcf/services/remote/RunControlProxy.py
+++ b/python/src/tcf/services/remote/RunControlProxy.py
@@ -1,5 +1,5 @@
# *****************************************************************************
-# * Copyright (c) 2011, 2013 Wind River Systems, Inc. and others.
+# * Copyright (c) 2011, 2013-2014 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
@@ -19,6 +19,26 @@ class RunContext(runcontrol.RunControlContext):
super(RunContext, self).__init__(props)
self.service = service
+ def getISA(self, address, done):
+ service = self.service
+ done = service._makeCallback(done)
+ contextID = self.getID()
+
+ class GetISACommand(Command):
+ def __init__(self):
+ super(GetISACommand, self).__init__(service.channel, service,
+ "getISA",
+ (contextID, address))
+
+ def done(self, error, args):
+ isa = None
+ if not error:
+ assert len(args) == 2
+ error = self.toError(args[0])
+ isa = runcontrol.RunControlISA(args[1])
+ done.doneGetISA(self.token, error, isa)
+ return GetISACommand().token
+
def getState(self, done):
service = self.service
done = service._makeCallback(done)
@@ -38,15 +58,15 @@ class RunContext(runcontrol.RunControlContext):
assert len(args) == 5
error = self.toError(args[0])
susp = args[1]
- if args[2]:
- pc = str(args[2])
+ if args[2] is not None:
+ pc = int(args[2])
reason = args[3]
states = args[4]
done.doneGetState(self.token, error, susp, pc, reason, states)
return GetStateCommand().token
-# def resume(self, mode, count, done):
-# return self._command("resume", [self.getID(), mode, count], done)
+ def detach(self, done):
+ return self._command("detach", (self.getID(),), done)
def resume(self, mode, count, params, done):
if not params:
@@ -117,6 +137,8 @@ class ChannelEventListener(channel.EventListener):
else:
raise IOError("RunControl service: unknown event: " + name)
except Exception as x:
+ import sys
+ x.tb = sys.exc_info()[2]
self.service.channel.terminate(x)
diff --git a/python/src/tcf/services/remote/StreamsProxy.py b/python/src/tcf/services/remote/StreamsProxy.py
index d249a5b93..dbaf68e3e 100644
--- a/python/src/tcf/services/remote/StreamsProxy.py
+++ b/python/src/tcf/services/remote/StreamsProxy.py
@@ -1,5 +1,5 @@
# *****************************************************************************
-# * Copyright (c) 2011, 2013 Wind River Systems, Inc. and others.
+# * Copyright (c) 2011, 2013-2014 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
@@ -142,7 +142,7 @@ class StreamsProxy(streams.StreamsService):
def __init__(self):
super(WriteCommand, self).__init__(service.channel, service,
"write",
- (stream_id, binary))
+ (stream_id, size, binary,))
def done(self, error, args):
if not error:
@@ -172,4 +172,6 @@ class ChannelEventListener(channel.EventListener):
else:
raise IOError("Streams service: unknown event: " + name)
except Exception as x:
+ import sys
+ x.tb = sys.exc_info()[2]
self.service.channel.terminate(x)
diff --git a/python/src/tcf/services/remote/TerminalsProxy.py b/python/src/tcf/services/remote/TerminalsProxy.py
index f3e3d275a..8b3fb7650 100644
--- a/python/src/tcf/services/remote/TerminalsProxy.py
+++ b/python/src/tcf/services/remote/TerminalsProxy.py
@@ -1,5 +1,5 @@
# *****************************************************************************
-# * Copyright (c) 2011, 2013 Wind River Systems, Inc. and others.
+# * Copyright (c) 2011, 2013-2014 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
@@ -144,4 +144,6 @@ class ChannelEventListener(channel.EventListener):
else:
raise IOError("Terminals service: unknown event: " + name)
except Exception as x:
+ import sys
+ x.tb = sys.exc_info()[2]
self.service.channel.terminate(x)

Back to the top