Ejemplo n.º 1
0
    def on_message(self, message):
        if '|' in message:
            cmd, data = message.split('|', 1)
        else:
            cmd, data = message, ''

        if cmd == 'ListSockets':
            for uuid in sockets.uuids:
                syncwebsockets.send(self.uuid, 'AddSocket', uuid)
        elif cmd == 'ListWebsockets':
            for uuid in websockets.uuids:
                syncwebsockets.send(self.uuid, 'AddWebSocket', uuid)
        elif cmd == 'ListBreaks':
            for brk in breakpoints.get():
                syncwebsockets.send(self.uuid, 'AddBreak', brk)
        elif cmd == 'RemoveBreak':
            brk = json.loads(data)
            breakpoints.remove(brk)
            # If it was here, it wasn't temporary
            brk['temporary'] = False
            sockets.broadcast('Unbreak', brk)
        elif cmd == 'RemoveUUID':
            sockets.close(data)
            sockets.remove(data)
            websockets.close(data)
            websockets.remove(data)
        elif cmd == 'ListProcesses':
            refresh_process(self.uuid)
        elif cmd == 'Pause':
            if int(data) == os.getpid():
                log.debug('Pausing self')

                def self_shell(variables):
                    # Debugging self
                    import wdb
                    wdb.set_trace()

                Process(target=self_shell, args=(globals(),)).start()

            else:
                log.debug('Pausing %s' % data)
                tornado.process.Subprocess([
                    'gdb', '-p', data,
                    '-batch'] + [
                        "-eval-command=call %s" % hook
                        for hook in [
                            'PyGILState_Ensure()',
                            'PyRun_SimpleString('
                            '"import wdb; wdb.set_trace(skip=1)"'
                            ')',
                            'PyGILState_Release($1)',
                        ]])
        elif cmd == 'RunFile':
            file_name = data

            def run():
                from wdb import Wdb
                Wdb.get().run_file(file_name)

            Process(target=run).start()
Ejemplo n.º 2
0
    def on_message(self, message):
        if '|' in message:
            cmd, data = message.split('|', 1)
        else:
            cmd, data = message, ''

        if cmd == 'ListSockets':
            for uuid in sockets.uuids:
                syncwebsockets.send(self.uuid, 'AddSocket', uuid)
        elif cmd == 'ListWebsockets':
            for uuid in websockets.uuids:
                syncwebsockets.send(self.uuid, 'AddWebSocket', uuid)
        elif cmd == 'ListBreaks':
            for brk in breakpoints.get():
                syncwebsockets.send(self.uuid, 'AddBreak', brk)
        elif cmd == 'RemoveBreak':
            brk = json.loads(data)
            breakpoints.remove(brk)
            # If it was here, it wasn't temporary
            brk['temporary'] = False
            sockets.broadcast('Unbreak', brk)
        elif cmd == 'RemoveUUID':
            sockets.close(data)
            sockets.remove(data)
            websockets.close(data)
            websockets.remove(data)
        elif cmd == 'ListProcesses':
            refresh_process(self.uuid)
        elif cmd == 'Pause':
            if int(data) == os.getpid():
                log.debug('Pausing self')

                def self_shell(variables):
                    # Debugging self
                    import wdb
                    wdb.set_trace()

                Process(target=self_shell, args=(globals(),)).start()

            else:
                log.debug('Pausing %s' % data)
                tornado.process.Subprocess([
                    'gdb', '-p', data,
                    '-batch'] + [
                        "-eval-command=call %s" % hook
                        for hook in [
                            'PyGILState_Ensure()',
                            'PyRun_SimpleString('
                            '"import wdb; wdb.set_trace(skip=1)"'
                            ')',
                            'PyGILState_Release($1)',
                        ]])
        elif cmd == 'RunFile':
            file_name = data

            def run():
                from wdb import Wdb
                Wdb.get().run_file(file_name)

            Process(target=run).start()
Ejemplo n.º 3
0
def read_frame(stream, uuid, frame):
    if frame.decode('utf-8') == 'ServerBreaks':
        sockets.send(uuid, json.dumps(breakpoints.get()))
    else:
        websockets.send(uuid, frame)
    try:
        stream.read_bytes(4, partial(read_header, stream, uuid))
    except StreamClosedError:
        log.warn('Closed stream for %s' % uuid)
Ejemplo n.º 4
0
def read_frame(stream, uuid, frame):
    if frame.decode('utf-8') == 'ServerBreaks':
        sockets.send(uuid, json.dumps(breakpoints.get()))
    else:
        websockets.send(uuid, frame)
    try:
        stream.read_bytes(4, partial(read_header, stream, uuid))
    except StreamClosedError:
        log.warn('Closed stream for %s' % uuid)
Ejemplo n.º 5
0
def read_frame(stream, uuid, frame):
    decoded_frame = frame.decode("utf-8")
    if decoded_frame == "ServerBreaks":
        sockets.send(uuid, json.dumps(breakpoints.get()))
    elif decoded_frame == "PING":
        log.info("%s PONG" % uuid)
    else:
        websockets.send(uuid, frame)
    try:
        stream.read_bytes(4, partial(read_header, stream, uuid))
    except StreamClosedError:
        log.warn("Closed stream for %s" % uuid)
Ejemplo n.º 6
0
def read_frame(stream, uuid, frame):
    decoded_frame = frame.decode('utf-8')
    if decoded_frame == 'ServerBreaks':
        sockets.send(uuid, json.dumps(breakpoints.get()))
    elif decoded_frame == 'PING':
        log.info('%s PONG' % uuid)
    elif decoded_frame.startswith('UPDATE_FILENAME'):
        filename = decoded_frame.split('|', 1)[1]
        sockets.set_filename(uuid, filename)
    else:
        websockets.send(uuid, frame)
    try:
        stream.read_bytes(4, partial(read_header, stream, uuid))
    except StreamClosedError:
        log.warn('Closed stream for %s' % uuid)
Ejemplo n.º 7
0
def read_frame(stream, uuid, frame):
    decoded_frame = frame.decode('utf-8')
    if decoded_frame == 'ServerBreaks':
        sockets.send(uuid, json.dumps(breakpoints.get()))
    elif decoded_frame == 'PING':
        log.info('%s PONG' % uuid)
    elif decoded_frame.startswith('UPDATE_FILENAME'):
        filename = decoded_frame.split('|', 1)[1]
        sockets.set_filename(uuid, filename)
    else:
        websockets.send(uuid, frame)
    try:
        stream.read_bytes(4, partial(read_header, stream, uuid))
    except StreamClosedError:
        log.warn('Closed stream for %s' % uuid)