def __init__(self, gdb="gdb", gdb_args=None, env=None): """Initialize a new machine interface session with GDB.""" gdb_args = gdb_args or [] env = env or {} env.update(os.environ) args = [gdb, '--quiet', '--nx', '--nw', '--interpreter=mi2'] + gdb_args self.process = subprocess.Popen( args=args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, close_fds=True, env=env ) flags = fcntl.fcntl(self.process.stdout, fcntl.F_GETFL) fcntl.fcntl(self.process.stdout, fcntl.F_SETFL, flags | os.O_NONBLOCK) self.buffer = "" # Buffer for output from GDB. self.parser = GDBMIParser() # Parser for output from GDB.