Skip to content
Snippets Groups Projects
Commit 36f92713 authored by Phil's avatar Phil
Browse files

Automaton thread's exception tracebacks transfered to foreground

parent 952833b1
No related branches found
No related tags found
No related merge requests found
...@@ -141,6 +141,7 @@ class _ATMT_Command: ...@@ -141,6 +141,7 @@ class _ATMT_Command:
NEXT = "NEXT" NEXT = "NEXT"
STOP = "STOP" STOP = "STOP"
END = "END" END = "END"
EXCEPTION = "EXCEPTION"
SINGLESTEP = "SINGLESTEP" SINGLESTEP = "SINGLESTEP"
INTERCEPT = "INTERCEPT" INTERCEPT = "INTERCEPT"
ACCEPT = "ACCEPT" ACCEPT = "ACCEPT"
...@@ -395,33 +396,38 @@ class Automaton: ...@@ -395,33 +396,38 @@ class Automaton:
singlestep = True singlestep = True
self.debug(3, "Starting control thread [tid=%i]" % self.threadid) self.debug(3, "Starting control thread [tid=%i]" % self.threadid)
stop = False stop = False
while not stop: try:
c = self.cmdin.recv() while not stop:
self.debug(5, "Received command %s" % c.type) c = self.cmdin.recv()
if c.type == _ATMT_Command.RUN: self.debug(5, "Received command %s" % c.type)
singlestep = False if c.type == _ATMT_Command.RUN:
elif c.type == _ATMT_Command.NEXT: singlestep = False
singlestep = True elif c.type == _ATMT_Command.NEXT:
elif c.type == _ATMT_Command.STOP: singlestep = True
break elif c.type == _ATMT_Command.STOP:
while True:
try:
state = self.do_next()
except KeyboardInterrupt:
self.debug(1,"Interrupted by user")
stop=True
break
except self.CommandMessage:
break
except StopIteration,e:
c = Message(type=_ATMT_Command.END, result=e.args[0])
self.cmdout.send(c)
stop=True
break
if singlestep:
c = Message(type=_ATMT_Command.SINGLESTEP,state=state)
self.cmdout.send(c)
break break
while True:
try:
state = self.do_next()
except KeyboardInterrupt:
self.debug(1,"Interrupted by user")
stop=True
break
except self.CommandMessage:
break
except StopIteration,e:
c = Message(type=_ATMT_Command.END, result=e.args[0])
self.cmdout.send(c)
stop=True
break
if singlestep:
c = Message(type=_ATMT_Command.SINGLESTEP,state=state)
self.cmdout.send(c)
break
except Exception,e:
self.debug(3, "Transfering exception [%s] from tid=%i"% (e,self.threadid))
m = Message(type = _ATMT_Command.EXCEPTION, exception=e)
self.cmdout.send(m)
self.debug(3, "Stopping control thread (tid=%i)"%self.threadid) self.debug(3, "Stopping control thread (tid=%i)"%self.threadid)
self.threadid = None self.threadid = None
...@@ -522,6 +528,8 @@ class Automaton: ...@@ -522,6 +528,8 @@ class Automaton:
return c.pkt return c.pkt
elif c.type == _ATMT_Command.SINGLESTEP: elif c.type == _ATMT_Command.SINGLESTEP:
return c.state return c.state
elif c.type == _ATMT_Command.EXCEPTION:
raise c.exception
def next(self): def next(self):
return self.run(resume = Message(type=_ATMT_Command.NEXT)) return self.run(resume = Message(type=_ATMT_Command.NEXT))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment