Instantly share code, notes, and snippets.

@o11c /errors.txt
Last active Nov 3, 2016

Embed
What would you like to do?
Unhandled Error
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/twisted/python/log.py", line 101, in callWithLogger
return callWithContext({"system": lp}, func, *args, **kw)
File "/usr/lib/python3/dist-packages/twisted/python/log.py", line 84, in callWithContext
return context.call({ILogContext: newCtx}, func, *args, **kw)
File "/usr/lib/python3/dist-packages/twisted/python/context.py", line 118, in callWithContext
return self.currentContext().callWithContext(ctx, func, *args, **kw)
File "/usr/lib/python3/dist-packages/twisted/python/context.py", line 81, in callWithContext
return func(*args,**kw)
--- <exception caught here> ---
File "/usr/lib/python3/dist-packages/twisted/internet/posixbase.py", line 597, in _doReadOrWrite
why = selectable.doRead()
File "/usr/lib/python3/dist-packages/twisted/internet/process.py", line 280, in doRead
return fdesc.readFromFD(self.fd, self.dataReceived)
File "/usr/lib/python3/dist-packages/twisted/internet/fdesc.py", line 94, in readFromFD
callback(output)
File "/usr/lib/python3/dist-packages/twisted/internet/process.py", line 283, in dataReceived
self.proc.childDataReceived(self.name, data)
File "/usr/lib/python3/dist-packages/twisted/internet/process.py", line 937, in childDataReceived
self.proto.childDataReceived(name, data)
File "/usr/lib/python3/dist-packages/twisted/internet/endpoints.py", line 344, in childDataReceived
return self.protocol.dataReceived(data)
File "/usr/lib/python3/dist-packages/twisted/protocols/basic.py", line 445, in dataReceived
if self.transport.disconnecting:
builtins.AttributeError: '_ProcessEndpointTransport' object has no attribute 'disconnecting'
import os
import shutil
from twisted.internet import protocol, endpoints
from twisted.protocols import basic
class GdbMiProtocol(basic.LineOnlyReceiver):
''' Protocol that parses GDB/MI lines.
Nothing interesting is done with them.
You should subclass this to actually *do* something with the MI.
'''
MAX_LENGTH = float('inf')
delimiter = b'\n'
def lineReceived(self, line):
''' Implements twisted's interface.
'''
print('line: %s' % line)
pass
# sendLine(self, data)
class ExecGdbMiEndpoint(endpoints.ProcessEndpoint):
def __init__(self, reactor, executable='gdb'):
''' Endpoint that spawns an instance of GDB/MI.
'''
full_exe = shutil.which(executable)
args = [executable, '--interpreter=mi2']
env = os.environ # The default is retarded.
# Default is to pipe stderr, but passthrough is a better idea.
#childFDs= { 0: "w", 1: "r", 2: "r" }
childFDs = { 0: "w", 1: "r", 2: 2 }
endpoints.ProcessEndpoint.__init__(self, reactor, full_exe,
args=args, env=env, childFDs=childFDs)
def main():
from twisted.internet import reactor
point = ExecGdbMiEndpoint(reactor)
if 1:
endpoints.connectProtocol(point, GdbMiProtocol())
else:
GdbMiFactory = protocol.Factory.forProtocol(GdbMiProtocol)
endpoint.connect(GdbMiFactory)
reactor.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment