当前位置: 首页>>代码示例>>Python>>正文


Python gdb_websocket.GDBWebSocket类代码示例

本文整理汇总了Python中gdb_websocket.GDBWebSocket的典型用法代码示例。如果您正苦于以下问题:Python GDBWebSocket类的具体用法?Python GDBWebSocket怎么用?Python GDBWebSocket使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了GDBWebSocket类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

 def __init__(self, board, port_urlWSS, options = {}):
     threading.Thread.__init__(self)
     self.board = board
     self.target = board.target
     self.flash = board.flash
     self.abstract_socket = None
     self.wss_server = None
     self.port = 0
     if isinstance(port_urlWSS, str) == True:
         self.wss_server = port_urlWSS
     else:
         self.port = port_urlWSS
     self.break_at_hardfault = bool(options.get('break_at_hardfault', True))
     self.packet_size = 2048
     self.flashData = list()
     self.flashOffset = None
     self.conn = None
     self.lock = threading.Lock()
     self.shutdown_event = threading.Event()
     self.detach_event = threading.Event()
     self.quit = False
     if self.wss_server == None:
         self.abstract_socket = GDBSocket(self.port, self.packet_size)
     else:
         self.abstract_socket = GDBWebSocket(self.wss_server)
     self.setDaemon(True)
     self.start()
开发者ID:ervandarnell,项目名称:pyOCD,代码行数:27,代码来源:gdbserver.py

示例2: __init__

 def __init__(self, board, port_urlWSS):
     threading.Thread.__init__(self)
     self.board = board
     self.target = board.target
     self.flash = board.flash
     self.abstract_socket = None
     self.wss_server = None
     self.port = 0
     if isinstance(port_urlWSS, str) == True:
         self.wss_server = port_urlWSS
     else:
         self.port = port_urlWSS
     self.packet_size = 2048
     self.flashData = list()
     self.flash_watermark = 0
     self.conn = None
     self.lock = threading.Lock()
     self.shutdown_event = threading.Event()
     self.detach_event = threading.Event()
     self.quit = False
     if self.wss_server == None:
         self.abstract_socket = GDBSocket(self.port, self.packet_size)
     else:
         self.abstract_socket = GDBWebSocket(self.wss_server)
     self.start()
开发者ID:henryeherman,项目名称:pyOCD,代码行数:25,代码来源:gdbserver.py

示例3: __init__

 def __init__(self, board, port_urlWSS, options = {}):
     threading.Thread.__init__(self)
     self.board = board
     self.target = board.target
     self.flash = board.flash
     self.abstract_socket = None
     self.wss_server = None
     self.port = 0
     if isinstance(port_urlWSS, str) == True:
         self.wss_server = port_urlWSS
     else:
         self.port = port_urlWSS
     self.break_at_hardfault = bool(options.get('break_at_hardfault', True))
     self.board.target.setVectorCatchFault(self.break_at_hardfault)
     self.break_on_reset = options.get('break_on_reset', False)
     self.board.target.setVectorCatchReset(self.break_on_reset)
     self.step_into_interrupt = options.get('step_into_interrupt', False)
     self.persist = options.get('persist', False)
     self.packet_size = 2048
     self.flashBuilder = None
     self.conn = None
     self.lock = threading.Lock()
     self.shutdown_event = threading.Event()
     self.detach_event = threading.Event()
     self.quit = False
     if self.wss_server == None:
         self.abstract_socket = GDBSocket(self.port, self.packet_size)
     else:
         self.abstract_socket = GDBWebSocket(self.wss_server)
     self.setDaemon(True)
     self.start()
开发者ID:HAPI-Tech-Solution,项目名称:pyOCD,代码行数:31,代码来源:gdbserver.py

示例4: __init__

 def __init__(self, board, port_urlWSS, options = {}):
     threading.Thread.__init__(self)
     self.board = board
     self.target = board.target
     self.flash = board.flash
     self.abstract_socket = None
     self.wss_server = None
     self.port = 0
     if isinstance(port_urlWSS, str) == True:
         self.wss_server = port_urlWSS
     else:
         self.port = port_urlWSS
     self.break_at_hardfault = bool(options.get('break_at_hardfault', True))
     self.board.target.setVectorCatchFault(self.break_at_hardfault)
     self.break_on_reset = options.get('break_on_reset', False)
     self.board.target.setVectorCatchReset(self.break_on_reset)
     self.step_into_interrupt = options.get('step_into_interrupt', False)
     self.persist = options.get('persist', False)
     self.soft_bkpt_as_hard = options.get('soft_bkpt_as_hard', False)
     self.chip_erase = options.get('chip_erase', None)
     self.hide_programming_progress = options.get('hide_programming_progress', False)
     self.fast_program = options.get('fast_program', False)
     self.packet_size = 2048
     self.packet_io = None
     self.gdb_features = []
     self.flashBuilder = None
     self.lock = threading.Lock()
     self.shutdown_event = threading.Event()
     self.detach_event = threading.Event()
     if self.wss_server == None:
         self.abstract_socket = GDBSocket(self.port, self.packet_size)
     else:
         self.abstract_socket = GDBWebSocket(self.wss_server)
     self.setDaemon(True)
     self.start()
开发者ID:arunpersaud,项目名称:pyOCD,代码行数:35,代码来源:gdbserver.py

示例5: __init__

    def __init__(self, board, port_urlWSS, options={}):
        threading.Thread.__init__(self)
        self.board = board
        self.target = board.target
        self.flash = board.flash
        self.abstract_socket = None
        self.wss_server = None
        self.port = 0
        if isinstance(port_urlWSS, str) == True:
            self.wss_server = port_urlWSS
        else:
            self.port = port_urlWSS
        self.break_at_hardfault = bool(options.get('break_at_hardfault', True))
        self.board.target.setVectorCatchFault(self.break_at_hardfault)
        self.break_on_reset = options.get('break_on_reset', False)
        self.board.target.setVectorCatchReset(self.break_on_reset)
        self.step_into_interrupt = options.get('step_into_interrupt', False)
        self.persist = options.get('persist', False)
        self.soft_bkpt_as_hard = options.get('soft_bkpt_as_hard', False)
        self.chip_erase = options.get('chip_erase', None)
        self.hide_programming_progress = options.get('hide_programming_progress', False)
        self.fast_program = options.get('fast_program', False)
        self.enable_semihosting = options.get('enable_semihosting', False)
        self.telnet_port = options.get('telnet_port', 4444)
        self.semihost_use_syscalls = options.get('semihost_use_syscalls', False)
        self.server_listening_callback = options.get('server_listening_callback', None)
        self.serve_local_only = options.get('serve_local_only', True)
        self.packet_size = 2048
        self.packet_io = None
        self.gdb_features = []
        self.non_stop = False
        self.is_target_running = (self.target.getState() == Target.TARGET_RUNNING)
        self.flashBuilder = None
        self.lock = threading.Lock()
        self.shutdown_event = threading.Event()
        self.detach_event = threading.Event()
        if self.wss_server == None:
            self.abstract_socket = GDBSocket(self.port, self.packet_size)
            if self.serve_local_only:
                self.abstract_socket.host = 'localhost'
        else:
            self.abstract_socket = GDBWebSocket(self.wss_server)

        # Init semihosting and telnet console.
        if self.semihost_use_syscalls:
            semihost_io_handler = GDBSyscallIOHandler(self)
        else:
            # Use internal IO handler.
            semihost_io_handler = semihost.InternalSemihostIOHandler()
        self.telnet_console = semihost.TelnetSemihostIOHandler(self.telnet_port, self.serve_local_only)
        self.semihost = semihost.SemihostAgent(self.target, io_handler=semihost_io_handler, console=self.telnet_console)

        self.setDaemon(True)
        self.start()
开发者ID:oliviermartin,项目名称:pyOCD,代码行数:54,代码来源:gdbserver.py

示例6: GDBServer

class GDBServer(threading.Thread):
    """
    This class start a GDB server listening a gdb connection on a specific port.
    It implements the RSP (Remote Serial Protocol).
    """
    def __init__(self, board, port_urlWSS, options = {}):
        threading.Thread.__init__(self)
        self.board = board
        self.target = board.target
        self.flash = board.flash
        self.abstract_socket = None
        self.wss_server = None
        self.port = 0
        if isinstance(port_urlWSS, str) == True:
            self.wss_server = port_urlWSS
        else:
            self.port = port_urlWSS
        self.break_at_hardfault = bool(options.get('break_at_hardfault', True))
        self.packet_size = 2048
        self.flashData = list()
        self.flashOffset = None
        self.conn = None
        self.lock = threading.Lock()
        self.shutdown_event = threading.Event()
        self.detach_event = threading.Event()
        self.quit = False
        if self.wss_server == None:
            self.abstract_socket = GDBSocket(self.port, self.packet_size)
        else:
            self.abstract_socket = GDBWebSocket(self.wss_server)
        self.setDaemon(True)
        self.start()
    
    def restart(self):
        if self.isAlive():
            self.detach_event.set()
    
    def stop(self):
        if self.isAlive():
            self.shutdown_event.set()
            while self.isAlive():
                pass
            logging.info("GDB server thread killed")
        self.board.uninit()
        
    def setBoard(self, board, stop = True):
        self.lock.acquire()
        if stop:
            self.restart()
        self.board = board
        self.target = board.target
        self.flash = board.flash
        self.lock.release()
        return
        
    def run(self):
        while True:
            new_command = False
            data = ""
            logging.info('GDB server started at port:%d',self.port)
            
            self.shutdown_event.clear()
            self.detach_event.clear()
                
            while not self.shutdown_event.isSet() and not self.detach_event.isSet():
                connected = self.abstract_socket.connect()
                if connected != None:
                    break
            
            if self.shutdown_event.isSet():
                return
            
            if self.detach_event.isSet():
                continue
            
            logging.info("One client connected!")
            
            while True:
                
                if self.shutdown_event.isSet():
                    return
            
                if self.detach_event.isSet():
                    continue
                
                # read command
                while True:
                    if (new_command == True):
                        new_command = False
                        break
                    try:
                        if self.shutdown_event.isSet() or self.detach_event.isSet():
                            break
                        self.abstract_socket.setBlocking(0)
                        data += self.abstract_socket.read()
                        if data.index("$") >= 0 and data.index("#") >= 0:
                            break
                    except (ValueError, socket.error):
                        pass
                
#.........这里部分代码省略.........
开发者ID:ervandarnell,项目名称:pyOCD,代码行数:101,代码来源:gdbserver.py

示例7: GDBServer

class GDBServer(threading.Thread):
    """
    This class start a GDB server listening a gdb connection on a specific port.
    It implements the RSP (Remote Serial Protocol).
    """
    def __init__(self, board, port_urlWSS, options={}):
        threading.Thread.__init__(self)
        self.board = board
        self.target = board.target
        self.flash = board.flash
        self.abstract_socket = None
        self.wss_server = None
        self.port = 0
        if isinstance(port_urlWSS, str) == True:
            self.wss_server = port_urlWSS
        else:
            self.port = port_urlWSS
        self.break_at_hardfault = bool(options.get('break_at_hardfault', True))
        self.board.target.setVectorCatchFault(self.break_at_hardfault)
        self.break_on_reset = options.get('break_on_reset', False)
        self.board.target.setVectorCatchReset(self.break_on_reset)
        self.step_into_interrupt = options.get('step_into_interrupt', False)
        self.persist = options.get('persist', False)
        self.soft_bkpt_as_hard = options.get('soft_bkpt_as_hard', False)
        self.chip_erase = options.get('chip_erase', None)
        self.hide_programming_progress = options.get('hide_programming_progress', False)
        self.fast_program = options.get('fast_program', False)
        self.enable_semihosting = options.get('enable_semihosting', False)
        self.telnet_port = options.get('telnet_port', 4444)
        self.semihost_use_syscalls = options.get('semihost_use_syscalls', False)
        self.server_listening_callback = options.get('server_listening_callback', None)
        self.serve_local_only = options.get('serve_local_only', True)
        self.packet_size = 2048
        self.packet_io = None
        self.gdb_features = []
        self.non_stop = False
        self.is_target_running = (self.target.getState() == Target.TARGET_RUNNING)
        self.flashBuilder = None
        self.lock = threading.Lock()
        self.shutdown_event = threading.Event()
        self.detach_event = threading.Event()
        if self.wss_server == None:
            self.abstract_socket = GDBSocket(self.port, self.packet_size)
            if self.serve_local_only:
                self.abstract_socket.host = 'localhost'
        else:
            self.abstract_socket = GDBWebSocket(self.wss_server)

        # Init semihosting and telnet console.
        if self.semihost_use_syscalls:
            semihost_io_handler = GDBSyscallIOHandler(self)
        else:
            # Use internal IO handler.
            semihost_io_handler = semihost.InternalSemihostIOHandler()
        self.telnet_console = semihost.TelnetSemihostIOHandler(self.telnet_port, self.serve_local_only)
        self.semihost = semihost.SemihostAgent(self.target, io_handler=semihost_io_handler, console=self.telnet_console)

        self.setDaemon(True)
        self.start()

    def restart(self):
        if self.isAlive():
            self.detach_event.set()

    def stop(self):
        if self.isAlive():
            self.shutdown_event.set()
            while self.isAlive():
                pass
            logging.info("GDB server thread killed")
        self.board.uninit()

    def setBoard(self, board, stop=True):
        self.lock.acquire()
        if stop:
            self.restart()
        self.board = board
        self.target = board.target
        self.flash = board.flash
        self.lock.release()
        return

    def _cleanup(self):
        logging.debug("GDB server cleaning up")
        if self.packet_io:
            self.packet_io.stop()
            self.packet_io = None
        if self.semihost:
            self.semihost.cleanup()
            self.semihost = None
        if self.telnet_console:
            self.telnet_console.stop()
            self.telnet_console = None

    def run(self):
        logging.info('GDB server started at port:%d', self.port)

        while True:
            try:
                self.detach_event.clear()
#.........这里部分代码省略.........
开发者ID:oliviermartin,项目名称:pyOCD,代码行数:101,代码来源:gdbserver.py

示例8: GDBServer

class GDBServer(threading.Thread):
    """
    This class start a GDB server listening a gdb connection on a specific port.
    It implements the RSP (Remote Serial Protocol).
    """
    def __init__(self, board, port_urlWSS):
        threading.Thread.__init__(self)
        self.board = board
        self.target = board.target
        self.flash = board.flash
        self.abstract_socket = None
        self.wss_server = None
        self.port = 0
        if isinstance(port_urlWSS, str) == True:
            self.wss_server = port_urlWSS
        else:
            self.port = port_urlWSS
        self.packet_size = 2048
        self.flashData = list()
        self.flash_watermark = 0
        self.conn = None
        self.lock = threading.Lock()
        self.shutdown_event = threading.Event()
        self.detach_event = threading.Event()
        self.quit = False
        if self.wss_server == None:
            self.abstract_socket = GDBSocket(self.port, self.packet_size)
        else:
            self.abstract_socket = GDBWebSocket(self.wss_server)
        self.start()
    
    def restart(self):
        if self.isAlive():
            self.detach_event.set()
    
    def stop(self):
        if self.isAlive():
            self.shutdown_event.set()
            while self.isAlive():
                pass
            logging.info("GDB server thread killed")
        self.board.uninit()
        
    def setBoard(self, board, stop = True):
        self.lock.acquire()
        if stop:
            self.restart()
        self.board = board
        self.target = board.target
        self.flash = board.flash
        self.lock.release()
        return
        
    def run(self):
        while True:
            new_command = False
            data = ""
            logging.info('GDB server started')
            
            self.shutdown_event.clear()
            self.detach_event.clear()
                
            while not self.shutdown_event.isSet() and not self.detach_event.isSet():
                connected = self.abstract_socket.connect()
                if connected != None:
                    break
            
            if self.shutdown_event.isSet():
                return
            
            if self.detach_event.isSet():
                continue
            
            logging.info("One client connected!")
            
            while True:
                
                if self.shutdown_event.isSet():
                    return
            
                if self.detach_event.isSet():
                    continue
                
                # read command
                while True:
                    if (new_command == True):
                        new_command = False
                        break
                    try:
                        if self.shutdown_event.isSet() or self.detach_event.isSet():
                            break
                        self.abstract_socket.setBlocking(0)
                        data += self.abstract_socket.read()
                        if data.index("$") >= 0 and data.index("#") >= 0:
                            break
                    except (ValueError, socket.error):
                        pass
                
                if self.shutdown_event.isSet():
                    return
#.........这里部分代码省略.........
开发者ID:henryeherman,项目名称:pyOCD,代码行数:101,代码来源:gdbserver.py

示例9: GDBServer

class GDBServer(threading.Thread):
    """
    This class start a GDB server listening a gdb connection on a specific port.
    It implements the RSP (Remote Serial Protocol).
    """

    def __init__(self, board, port_urlWSS, options={}):
        threading.Thread.__init__(self)
        self.board = board
        self.target = board.target
        self.flash = board.flash
        self.abstract_socket = None
        self.wss_server = None
        self.port = 0
        if isinstance(port_urlWSS, str) == True:
            self.wss_server = port_urlWSS
        else:
            self.port = port_urlWSS
        self.break_at_hardfault = bool(options.get("break_at_hardfault", True))
        self.board.target.setVectorCatchFault(self.break_at_hardfault)
        self.break_on_reset = options.get("break_on_reset", False)
        self.board.target.setVectorCatchReset(self.break_on_reset)
        self.step_into_interrupt = options.get("step_into_interrupt", False)
        self.persist = options.get("persist", False)
        self.soft_bkpt_as_hard = options.get("soft_bkpt_as_hard", False)
        self.chip_erase = options.get("chip_erase", None)
        self.hide_programming_progress = options.get("hide_programming_progress", False)
        self.fast_program = options.get("fast_program", False)
        self.enable_semihosting = options.get("enable_semihosting", False)
        self.telnet_port = options.get("telnet_port", 4444)
        self.semihost_use_syscalls = options.get("semihost_use_syscalls", False)
        self.server_listening_callback = options.get("server_listening_callback", None)
        self.serve_local_only = options.get("serve_local_only", True)
        self.packet_size = 2048
        self.packet_io = None
        self.gdb_features = []
        self.non_stop = False
        self.is_target_running = self.target.getState() == Target.TARGET_RUNNING
        self.flashBuilder = None
        self.lock = threading.Lock()
        self.shutdown_event = threading.Event()
        self.detach_event = threading.Event()
        if self.wss_server == None:
            self.abstract_socket = GDBSocket(self.port, self.packet_size)
            if self.serve_local_only:
                self.abstract_socket.host = "localhost"
        else:
            self.abstract_socket = GDBWebSocket(self.wss_server)

        # Init semihosting and telnet console.
        if self.semihost_use_syscalls:
            semihost_io_handler = GDBSyscallIOHandler(self)
        else:
            # Use internal IO handler.
            semihost_io_handler = semihost.InternalSemihostIOHandler()
        self.telnet_console = semihost.TelnetSemihostIOHandler(self.telnet_port, self.serve_local_only)
        self.semihost = semihost.SemihostAgent(self.target, io_handler=semihost_io_handler, console=self.telnet_console)

        self.setDaemon(True)
        self.start()

    def restart(self):
        if self.isAlive():
            self.detach_event.set()

    def stop(self):
        if self.isAlive():
            self.shutdown_event.set()
            while self.isAlive():
                pass
            logging.info("GDB server thread killed")
        self.board.uninit()

    def setBoard(self, board, stop=True):
        self.lock.acquire()
        if stop:
            self.restart()
        self.board = board
        self.target = board.target
        self.flash = board.flash
        self.lock.release()
        return

    def _cleanup(self):
        logging.debug("GDB server cleaning up")
        if self.packet_io:
            self.packet_io.stop()
            self.packet_io = None
        if self.semihost:
            self.semihost.cleanup()
            self.semihost = None
        if self.telnet_console:
            self.telnet_console.stop()
            self.telnet_console = None

    def run(self):
        logging.info("GDB server started at port:%d", self.port)

        while True:
            try:
#.........这里部分代码省略.........
开发者ID:sw17ch,项目名称:pyOCD,代码行数:101,代码来源:gdbserver.py

示例10: GDBServer

class GDBServer(threading.Thread):
    """
    This class start a GDB server listening a gdb connection on a specific port.
    It implements the RSP (Remote Serial Protocol).
    """
    def __init__(self, board, port_urlWSS, options = {}):
        threading.Thread.__init__(self)
        self.board = board
        self.target = board.target
        self.flash = board.flash
        self.abstract_socket = None
        self.wss_server = None
        self.port = 0
        if isinstance(port_urlWSS, str) == True:
            self.wss_server = port_urlWSS
        else:
            self.port = port_urlWSS
        self.break_at_hardfault = bool(options.get('break_at_hardfault', True))
        self.board.target.setVectorCatchFault(self.break_at_hardfault)
        self.break_on_reset = options.get('break_on_reset', False)
        self.board.target.setVectorCatchReset(self.break_on_reset)
        self.step_into_interrupt = options.get('step_into_interrupt', False)
        self.persist = options.get('persist', False)
        self.soft_bkpt_as_hard = options.get('soft_bkpt_as_hard', False)
        self.chip_erase = options.get('chip_erase', None)
        self.hide_programming_progress = options.get('hide_programming_progress', False)
        self.fast_program = options.get('fast_program', False)
        self.packet_size = 2048
        self.send_acks = True
        self.clear_send_acks = False
        self.gdb_features = []
        self.flashBuilder = None
        self.conn = None
        self.lock = threading.Lock()
        self.shutdown_event = threading.Event()
        self.detach_event = threading.Event()
        self.quit = False
        if self.wss_server == None:
            self.abstract_socket = GDBSocket(self.port, self.packet_size)
        else:
            self.abstract_socket = GDBWebSocket(self.wss_server)
        self.setDaemon(True)
        self.start()
    
    def restart(self):
        if self.isAlive():
            self.detach_event.set()
    
    def stop(self):
        if self.isAlive():
            self.shutdown_event.set()
            while self.isAlive():
                pass
            logging.info("GDB server thread killed")
        self.board.uninit()
        
    def setBoard(self, board, stop = True):
        self.lock.acquire()
        if stop:
            self.restart()
        self.board = board
        self.target = board.target
        self.flash = board.flash
        self.lock.release()
        return
        
    def run(self):
        self.timeOfLastPacket = time()
        while True:
            new_command = False
            data = ""
            logging.info('GDB server started at port:%d',self.port)
            
            self.shutdown_event.clear()
            self.detach_event.clear()
                
            while not self.shutdown_event.isSet() and not self.detach_event.isSet():
                connected = self.abstract_socket.connect()
                if connected != None:
                    break
            
            if self.shutdown_event.isSet():
                return
            
            if self.detach_event.isSet():
                continue
            
            logging.info("One client connected!")
            
            while True:
                
                if self.shutdown_event.isSet():
                    return
            
                if self.detach_event.isSet():
                    continue
                
                # read command
                while True:
                    if (new_command == True):
#.........这里部分代码省略.........
开发者ID:geky,项目名称:pyOCD,代码行数:101,代码来源:gdbserver.py

示例11: GDBServer

class GDBServer(threading.Thread):
    """
    This class start a GDB server listening a gdb connection on a specific port.
    It implements the RSP (Remote Serial Protocol).
    """
    def __init__(self, board, port_urlWSS, options = {}):
        threading.Thread.__init__(self)
        self.board = board
        self.target = board.target
        self.flash = board.flash
        self.abstract_socket = None
        self.wss_server = None
        self.port = 0
        if isinstance(port_urlWSS, str) == True:
            self.wss_server = port_urlWSS
        else:
            self.port = port_urlWSS
        self.break_at_hardfault = bool(options.get('break_at_hardfault', True))
        self.board.target.setVectorCatchFault(self.break_at_hardfault)
        self.break_on_reset = options.get('break_on_reset', False)
        self.board.target.setVectorCatchReset(self.break_on_reset)
        self.step_into_interrupt = options.get('step_into_interrupt', False)
        self.persist = options.get('persist', False)
        self.packet_size = 2048
        self.flashData = list()
        self.flashOffset = None
        self.conn = None
        self.lock = threading.Lock()
        self.shutdown_event = threading.Event()
        self.detach_event = threading.Event()
        self.quit = False
        if self.wss_server == None:
            self.abstract_socket = GDBSocket(self.port, self.packet_size)
        else:
            self.abstract_socket = GDBWebSocket(self.wss_server)
        self.setDaemon(True)
        self.start()
    
    def restart(self):
        if self.isAlive():
            self.detach_event.set()
    
    def stop(self):
        if self.isAlive():
            self.shutdown_event.set()
            while self.isAlive():
                pass
            logging.info("GDB server thread killed")
        self.board.uninit()
        
    def setBoard(self, board, stop = True):
        self.lock.acquire()
        if stop:
            self.restart()
        self.board = board
        self.target = board.target
        self.flash = board.flash
        self.lock.release()
        return
        
    def run(self):
        self.timeOfLastPacket = time()
        while True:
            new_command = False
            data = ""
            logging.info('GDB server started at port:%d',self.port)
            
            self.shutdown_event.clear()
            self.detach_event.clear()
                
            while not self.shutdown_event.isSet() and not self.detach_event.isSet():
                connected = self.abstract_socket.connect()
                if connected != None:
                    break
            
            if self.shutdown_event.isSet():
                return
            
            if self.detach_event.isSet():
                continue
            
            logging.info("One client connected!")
            
            while True:
                
                if self.shutdown_event.isSet():
                    return
            
                if self.detach_event.isSet():
                    continue
                
                # read command
                while True:
                    if (new_command == True):
                        new_command = False
                        break

                    # Reduce CPU usage by sleep()ing once we know that the
                    # debugger doesn't have a queue of commands that we should
                    # execute as quickly as possible.
#.........这里部分代码省略.........
开发者ID:dbrobins,项目名称:pyOCD,代码行数:101,代码来源:gdbserver.py

示例12: __init__

    def __init__(self, board, port_urlWSS, options={}):
        threading.Thread.__init__(self)
        self.board = board
        self.target = board.target
        self.log = logging.getLogger('gdbserver')
        self.flash = board.flash
        self.abstract_socket = None
        self.wss_server = None
        self.port = 0
        if isinstance(port_urlWSS, str) == True:
            self.wss_server = port_urlWSS
        else:
            self.port = port_urlWSS
        self.vector_catch = options.get('vector_catch', Target.CATCH_HARD_FAULT)
        self.board.target.setVectorCatch(self.vector_catch)
        self.step_into_interrupt = options.get('step_into_interrupt', False)
        self.persist = options.get('persist', False)
        self.soft_bkpt_as_hard = options.get('soft_bkpt_as_hard', False)
        self.chip_erase = options.get('chip_erase', None)
        self.hide_programming_progress = options.get('hide_programming_progress', False)
        self.fast_program = options.get('fast_program', False)
        self.enable_semihosting = options.get('enable_semihosting', False)
        self.telnet_port = options.get('telnet_port', 4444)
        self.semihost_use_syscalls = options.get('semihost_use_syscalls', False)
        self.server_listening_callback = options.get('server_listening_callback', None)
        self.serve_local_only = options.get('serve_local_only', True)
        self.packet_size = 2048
        self.packet_io = None
        self.gdb_features = []
        self.non_stop = False
        self.is_target_running = (self.target.getState() == Target.TARGET_RUNNING)
        self.flashBuilder = None
        self.lock = threading.Lock()
        self.shutdown_event = threading.Event()
        self.detach_event = threading.Event()
        self.target_context = self.target.getTargetContext()
        self.target_facade = GDBDebugContextFacade(self.target_context)
        self.thread_provider = None
        self.did_init_thread_providers = False
        self.current_thread_id = 0
        if self.wss_server == None:
            self.abstract_socket = GDBSocket(self.port, self.packet_size)
            if self.serve_local_only:
                self.abstract_socket.host = 'localhost'
        else:
            self.abstract_socket = GDBWebSocket(self.wss_server)

        # Init semihosting and telnet console.
        if self.semihost_use_syscalls:
            semihost_io_handler = GDBSyscallIOHandler(self)
        else:
            # Use internal IO handler.
            semihost_io_handler = semihost.InternalSemihostIOHandler()
        self.telnet_console = semihost.TelnetSemihostIOHandler(self.telnet_port, self.serve_local_only)
        self.semihost = semihost.SemihostAgent(self.target_context, io_handler=semihost_io_handler, console=self.telnet_console)

        # Command handler table.
        #
        # The dict keys are the first character of the incoming command from gdb. Values are a
        # bi-tuple. The first element is the handler method, and the second element is the start
        # offset of the command string passed to the handler.
        #
        # Start offset values:
        #  0 - Special case: handler method does not take any parameters.
        #  1 - Strip off leading "$" from command.
        #  2 - Strip leading "$" plus character matched through this table.
        #  3+ - Supported, but not very useful.
        #
        self.COMMANDS = {
        #       CMD    HANDLER                  START    DESCRIPTION
                '?' : (self.stopReasonQuery,    0   ), # Stop reason query.
                'C' : (self.resume,             1   ), # Continue (at addr)
                'c' : (self.resume,             1   ), # Continue with signal.
                'D' : (self.detach,             1   ), # Detach.
                'g' : (self.getRegisters,       0   ), # Read general registers.
                'G' : (self.setRegisters,       2   ), # Write general registers.
                'H' : (self.setThread,          2   ), # Set thread for subsequent operations.
                'k' : (self.kill,               0   ), # Kill.
                'm' : (self.getMemory,          2   ), # Read memory.
                'M' : (self.writeMemoryHex,     2   ), # Write memory (hex).
                'p' : (self.readRegister,       2   ), # Read register.
                'P' : (self.writeRegister,      2   ), # Write register.
                'q' : (self.handleQuery,        2   ), # General query.
                'Q' : (self.handleGeneralSet,   2   ), # General set.
                's' : (self.step,               1   ), # Single step.
                'S' : (self.step,               1   ), # Step with signal.
                'T' : (self.isThreadAlive,      1   ), # Thread liveness query.
                'v' : (self.vCommand,           2   ), # v command.
                'X' : (self.writeMemory,        2   ), # Write memory (binary).
                'z' : (self.breakpoint,         1   ), # Insert breakpoint/watchpoint.
                'Z' : (self.breakpoint,         1   ), # Remove breakpoint/watchpoint.
            }

        # Commands that kill the connection to gdb.
        self.DETACH_COMMANDS = ('D', 'k')

        self.setDaemon(True)
        self.start()
开发者ID:matthewelse,项目名称:pyOCD,代码行数:98,代码来源:gdbserver.py

示例13: GDBServer

class GDBServer(threading.Thread):
    """
    This class start a GDB server listening a gdb connection on a specific port.
    It implements the RSP (Remote Serial Protocol).
    """
    def __init__(self, board, port_urlWSS, options={}):
        threading.Thread.__init__(self)
        self.board = board
        self.target = board.target
        self.log = logging.getLogger('gdbserver')
        self.flash = board.flash
        self.abstract_socket = None
        self.wss_server = None
        self.port = 0
        if isinstance(port_urlWSS, str) == True:
            self.wss_server = port_urlWSS
        else:
            self.port = port_urlWSS
        self.vector_catch = options.get('vector_catch', Target.CATCH_HARD_FAULT)
        self.board.target.setVectorCatch(self.vector_catch)
        self.step_into_interrupt = options.get('step_into_interrupt', False)
        self.persist = options.get('persist', False)
        self.soft_bkpt_as_hard = options.get('soft_bkpt_as_hard', False)
        self.chip_erase = options.get('chip_erase', None)
        self.hide_programming_progress = options.get('hide_programming_progress', False)
        self.fast_program = options.get('fast_program', False)
        self.enable_semihosting = options.get('enable_semihosting', False)
        self.telnet_port = options.get('telnet_port', 4444)
        self.semihost_use_syscalls = options.get('semihost_use_syscalls', False)
        self.server_listening_callback = options.get('server_listening_callback', None)
        self.serve_local_only = options.get('serve_local_only', True)
        self.packet_size = 2048
        self.packet_io = None
        self.gdb_features = []
        self.non_stop = False
        self.is_target_running = (self.target.getState() == Target.TARGET_RUNNING)
        self.flashBuilder = None
        self.lock = threading.Lock()
        self.shutdown_event = threading.Event()
        self.detach_event = threading.Event()
        self.target_context = self.target.getTargetContext()
        self.target_facade = GDBDebugContextFacade(self.target_context)
        self.thread_provider = None
        self.did_init_thread_providers = False
        self.current_thread_id = 0
        if self.wss_server == None:
            self.abstract_socket = GDBSocket(self.port, self.packet_size)
            if self.serve_local_only:
                self.abstract_socket.host = 'localhost'
        else:
            self.abstract_socket = GDBWebSocket(self.wss_server)

        # Init semihosting and telnet console.
        if self.semihost_use_syscalls:
            semihost_io_handler = GDBSyscallIOHandler(self)
        else:
            # Use internal IO handler.
            semihost_io_handler = semihost.InternalSemihostIOHandler()
        self.telnet_console = semihost.TelnetSemihostIOHandler(self.telnet_port, self.serve_local_only)
        self.semihost = semihost.SemihostAgent(self.target_context, io_handler=semihost_io_handler, console=self.telnet_console)

        # Command handler table.
        #
        # The dict keys are the first character of the incoming command from gdb. Values are a
        # bi-tuple. The first element is the handler method, and the second element is the start
        # offset of the command string passed to the handler.
        #
        # Start offset values:
        #  0 - Special case: handler method does not take any parameters.
        #  1 - Strip off leading "$" from command.
        #  2 - Strip leading "$" plus character matched through this table.
        #  3+ - Supported, but not very useful.
        #
        self.COMMANDS = {
        #       CMD    HANDLER                  START    DESCRIPTION
                '?' : (self.stopReasonQuery,    0   ), # Stop reason query.
                'C' : (self.resume,             1   ), # Continue (at addr)
                'c' : (self.resume,             1   ), # Continue with signal.
                'D' : (self.detach,             1   ), # Detach.
                'g' : (self.getRegisters,       0   ), # Read general registers.
                'G' : (self.setRegisters,       2   ), # Write general registers.
                'H' : (self.setThread,          2   ), # Set thread for subsequent operations.
                'k' : (self.kill,               0   ), # Kill.
                'm' : (self.getMemory,          2   ), # Read memory.
                'M' : (self.writeMemoryHex,     2   ), # Write memory (hex).
                'p' : (self.readRegister,       2   ), # Read register.
                'P' : (self.writeRegister,      2   ), # Write register.
                'q' : (self.handleQuery,        2   ), # General query.
                'Q' : (self.handleGeneralSet,   2   ), # General set.
                's' : (self.step,               1   ), # Single step.
                'S' : (self.step,               1   ), # Step with signal.
                'T' : (self.isThreadAlive,      1   ), # Thread liveness query.
                'v' : (self.vCommand,           2   ), # v command.
                'X' : (self.writeMemory,        2   ), # Write memory (binary).
                'z' : (self.breakpoint,         1   ), # Insert breakpoint/watchpoint.
                'Z' : (self.breakpoint,         1   ), # Remove breakpoint/watchpoint.
            }

        # Commands that kill the connection to gdb.
        self.DETACH_COMMANDS = ('D', 'k')
#.........这里部分代码省略.........
开发者ID:matthewelse,项目名称:pyOCD,代码行数:101,代码来源:gdbserver.py

示例14: GDBServer

class GDBServer(threading.Thread):
    """
    This class start a GDB server listening a gdb connection on a specific port.
    It implements the RSP (Remote Serial Protocol).
    """

    def __init__(self, board, port_urlWSS):
        threading.Thread.__init__(self)
        self.board = board
        self.target = board.target
        self.flash = board.flash
        self.abstract_socket = None
        self.wss_server = None
        self.port = 0
        if isinstance(port_urlWSS, str) == True:
            self.wss_server = port_urlWSS
        else:
            self.port = port_urlWSS
        self.packet_size = 2048
        self.flashData = list()
        self.conn = None
        self.lock = threading.Lock()
        self.shutdown_event = threading.Event()
        self.detach_event = threading.Event()
        self.quit = False
        if self.wss_server == None:
            self.abstract_socket = GDBSocket(self.port, self.packet_size)
        else:
            self.abstract_socket = GDBWebSocket(self.wss_server)
        self.setDaemon(True)
        self.start()

    def restart(self):
        if self.isAlive():
            self.detach_event.set()

    def stop(self):
        if self.isAlive():
            self.shutdown_event.set()
            while self.isAlive():
                pass
            logging.info("GDB server thread killed")
        self.board.uninit()

    def setBoard(self, board, stop=True):
        self.lock.acquire()
        if stop:
            self.restart()
        self.board = board
        self.target = board.target
        self.flash = board.flash
        self.lock.release()
        return

    def run(self):
        while True:
            new_command = False
            data = ""
            logging.info("GDB server started")

            self.shutdown_event.clear()
            self.detach_event.clear()

            while not self.shutdown_event.isSet() and not self.detach_event.isSet():
                connected = self.abstract_socket.connect()
                if connected != None:
                    break

            if self.shutdown_event.isSet():
                return

            if self.detach_event.isSet():
                continue

            logging.info("One client connected!")

            while True:

                if self.shutdown_event.isSet():
                    return

                if self.detach_event.isSet():
                    continue

                # read command
                while True:
                    if new_command == True:
                        new_command = False
                        break
                    try:
                        if self.shutdown_event.isSet() or self.detach_event.isSet():
                            break
                        self.abstract_socket.setBlocking(0)
                        data += self.abstract_socket.read()
                        if data.index("$") >= 0 and data.index("#") >= 0:
                            break
                    except (ValueError, socket.error):
                        pass

                if self.shutdown_event.isSet():
#.........这里部分代码省略.........
开发者ID:Kazu-zamasu,项目名称:pyOCD,代码行数:101,代码来源:gdbserver.py


注:本文中的gdb_websocket.GDBWebSocket类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。