當前位置: 首頁>>代碼示例>>Python>>正文


Python GDBWebSocket.close方法代碼示例

本文整理匯總了Python中gdb_websocket.GDBWebSocket.close方法的典型用法代碼示例。如果您正苦於以下問題:Python GDBWebSocket.close方法的具體用法?Python GDBWebSocket.close怎麽用?Python GDBWebSocket.close使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在gdb_websocket.GDBWebSocket的用法示例。


在下文中一共展示了GDBWebSocket.close方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: GDBServer

# 需要導入模塊: from gdb_websocket import GDBWebSocket [as 別名]
# 或者: from gdb_websocket.GDBWebSocket import close [as 別名]

#.........這裏部分代碼省略.........
            
                if self.detach_event.isSet():
                    continue
                
                self.abstract_socket.setBlocking(1)
                    
                data = data[data.index("$"):]
                
                self.lock.acquire()
            
                if len(data) != 0:
                    # decode and prepare resp
                    [resp, ack, detach] = self.handleMsg(data)
            
                    if resp is not None:
                        # ack
                        if ack:
                            resp = "+" + resp
                        # send resp
                        self.abstract_socket.write(resp)
                        # wait a '+' from the client
                        try:
                            data = self.abstract_socket.read()
                            if data[0] != '+':
                                logging.debug('gdb client has not ack!')
                            else:
                                logging.debug('gdb client has ack!')
                            if data.index("$") >= 0 and data.index("#") >= 0:
                                new_command = True
                        except:
                            pass
                        
                    if detach:
                        self.abstract_socket.close()
                        self.lock.release()
                        break
                    
                self.lock.release()
        
        
    def handleMsg(self, msg):
        
        if msg[0] != '$':
            logging.debug('msg ignored: first char != $')
            return None, 0, 0
        
        #logging.debug('-->>>>>>>>>>>> GDB rsp packet: %s', msg)
        
        # query command
        if msg[1] == 'q':
            return self.handleQuery(msg[2:]), 1, 0
            
        elif msg[1] == 'H':
            return self.createRSPPacket(''), 1, 0
        
        elif msg[1] == '?':
            return self.lastSignal(), 1, 0
        
        elif msg[1] == 'g':
            return self.getRegister(), 1, 0
        
        elif msg[1] == 'p':
            return self.readRegister(msg[2:]), 1, 0
        
        elif msg[1] == 'P':
            return self.writeRegister(msg[2:]), 1, 0
開發者ID:ervandarnell,項目名稱:pyOCD,代碼行數:70,代碼來源:gdbserver.py

示例2: GDBServer

# 需要導入模塊: from gdb_websocket import GDBWebSocket [as 別名]
# 或者: from gdb_websocket.GDBWebSocket import close [as 別名]

#.........這裏部分代碼省略.........
            
                if self.detach_event.isSet():
                    continue
                
                self.abstract_socket.setBlocking(1)
                    
                data = data[data.index("$"):]
                
                self.lock.acquire()
            
                if len(data) != 0:
                    # decode and prepare resp
                    [resp, ack, detach] = self.handleMsg(data)
            
                    if resp is not None:
                        # ack
                        if ack:
                            resp = "+" + resp
                        # send resp
                        self.abstract_socket.write(resp)
                        # wait a '+' from the client
                        try:
                            data = self.abstract_socket.read()
                            if data[0] != '+':
                                logging.debug('gdb client has not ack!')
                            else:
                                logging.debug('gdb client has ack!')
                            if data.index("$") >= 0 and data.index("#") >= 0:
                                new_command = True
                        except:
                            pass
                        
                    if detach:
                        self.abstract_socket.close()
                        self.lock.release()
                        break
                    
                self.lock.release()
        
        
    def handleMsg(self, msg):
        
        if msg[0] != '$':
            logging.debug('msg ignored: first char != $')
            return None, 0, 0
        
        #logging.debug('-->>>>>>>>>>>> GDB rsp packet: %s', msg)
        
        # query command
        if msg[1] == 'q':
            return self.handleQuery(msg[2:]), 1, 0
            
        elif msg[1] == 'H':
            return self.createRSPPacket(''), 1, 0
        
        elif msg[1] == '?':
            return self.lastSignal(), 1, 0
        
        elif msg[1] == 'g':
            return self.getRegister(), 1, 0
        
        elif msg[1] == 'p':
            return self.readRegister(msg[2:]), 1, 0
        
        elif msg[1] == 'P':
            return self.writeRegister(msg[2:]), 1, 0
開發者ID:henryeherman,項目名稱:pyOCD,代碼行數:70,代碼來源:gdbserver.py

示例3: GDBServer

# 需要導入模塊: from gdb_websocket import GDBWebSocket [as 別名]
# 或者: from gdb_websocket.GDBWebSocket import close [as 別名]

#.........這裏部分代碼省略.........
                            self.sendStopNotification()
                    except Exception as e:
                        logging.error("Unexpected exception: %s", e)
                        traceback.print_exc()

                # read command
                try:
                    packet = self.packet_io.receive(block=not self.non_stop)
                except ConnectionClosedException:
                    break

                if self.shutdown_event.isSet():
                    self._cleanup()
                    return

                if self.detach_event.isSet():
                    break

                if self.non_stop and packet is None:
                    sleep(0.1)
                    continue

                self.lock.acquire()

                if len(packet) != 0:
                    # decode and prepare resp
                    resp, detach = self.handleMsg(packet)

                    if resp is not None:
                        # send resp
                        self.packet_io.send(resp)

                    if detach:
                        self.abstract_socket.close()
                        self.packet_io.stop()
                        self.packet_io = None
                        self.lock.release()
                        if self.persist:
                            break
                        else:
                            self.shutdown_event.set()
                            return

                self.lock.release()

            except Exception as e:
                logging.error("Unexpected exception: %s", e)
                traceback.print_exc()

    def handleMsg(self, msg):
        try:
            if msg[0] != '$':
                logging.debug('msg ignored: first char != $')
                return None, 0

            # query command
            if msg[1] == '?':
                return self.stopReasonQuery(), 0

            # we don't send immediately the response for C and S commands
            elif msg[1] == 'C' or msg[1] == 'c':
                return self.resume(msg[1:]), 0

            elif msg[1] == 'D':
                return self.detach(msg[1:]), 1
開發者ID:oliviermartin,項目名稱:pyOCD,代碼行數:69,代碼來源:gdbserver.py

示例4: GDBServer

# 需要導入模塊: from gdb_websocket import GDBWebSocket [as 別名]
# 或者: from gdb_websocket.GDBWebSocket import close [as 別名]

#.........這裏部分代碼省略.........
                            self.sendStopNotification()
                    except Exception as e:
                        logging.error("Unexpected exception: %s", e)
                        traceback.print_exc()

                # read command
                try:
                    packet = self.packet_io.receive(block=not self.non_stop)
                except ConnectionClosedException:
                    break

                if self.shutdown_event.isSet():
                    self._cleanup()
                    return

                if self.detach_event.isSet():
                    break

                if self.non_stop and packet is None:
                    sleep(0.1)
                    continue

                self.lock.acquire()

                if len(packet) != 0:
                    # decode and prepare resp
                    resp, detach = self.handleMsg(packet)

                    if resp is not None:
                        # send resp
                        self.packet_io.send(resp)

                    if detach:
                        self.abstract_socket.close()
                        self.packet_io.stop()
                        self.packet_io = None
                        self.lock.release()
                        if self.persist:
                            break
                        else:
                            self.shutdown_event.set()
                            return

                self.lock.release()

            except Exception as e:
                logging.error("Unexpected exception: %s", e)
                traceback.print_exc()

    def handleMsg(self, msg):
        try:
            if msg[0] != "$":
                logging.debug("msg ignored: first char != $")
                return None, 0

            # query command
            if msg[1] == "?":
                return self.stopReasonQuery(), 0

            # we don't send immediately the response for C and S commands
            elif msg[1] == "C" or msg[1] == "c":
                return self.resume(msg[1:]), 0

            elif msg[1] == "D":
                return self.detach(msg[1:]), 1
開發者ID:sw17ch,項目名稱:pyOCD,代碼行數:69,代碼來源:gdbserver.py

示例5: GDBServer

# 需要導入模塊: from gdb_websocket import GDBWebSocket [as 別名]
# 或者: from gdb_websocket.GDBWebSocket import close [as 別名]

#.........這裏部分代碼省略.........
                
                self.lock.acquire()
            
                if len(data) != 0:
                    # decode and prepare resp
                    [resp, ack, detach] = self.handleMsg(data)

                    # Clear out data
                    data = ""
            
                    if resp is not None:
                        # ack
                        if ack and self.send_acks:
                            resp = "+" + resp
                        # send resp
                        self.abstract_socket.write(resp)
                        if self.send_acks:
                            # wait a '+' from the client
                            try:
                                data = self.abstract_socket.read()
                                if LOG_ACK:
                                    if data[0] != '+':
                                        logging.debug('gdb client has not ack!')
                                    else:
                                        logging.debug('gdb client has ack!')
                                if self.clear_send_acks:
                                    self.send_acks = False
                                if data.index("$") >= 0 and data.index("#") >= 0:
                                    new_command = True
                            except:
                                pass

                    if detach:
                        self.abstract_socket.close()
                        self.lock.release()
                        if self.persist:
                            break
                        else:
                            return

                    self.timeOfLastPacket = time()

                self.lock.release()
        
        
    def handleMsg(self, msg):
        
        if msg[0] != '$':
            logging.debug('msg ignored: first char != $')
            return None, 0, 0
        
        #logging.debug('-->>>>>>>>>>>> GDB rsp packet: %s', msg)
        
        # query command
        if msg[1] == '?':
            return self.createRSPPacket(self.target.getTResponse()), 1, 0

        # we don't send immediately the response for C and S commands
        elif msg[1] == 'C' or msg[1] == 'c':
            return self.resume()

        elif msg[1] == 'D':
            return self.detach(msg[1:]), 1, 1

        elif msg[1] == 'g':
            return self.getRegisters(), 1, 0
開發者ID:geky,項目名稱:pyOCD,代碼行數:70,代碼來源:gdbserver.py

示例6: GDBServer

# 需要導入模塊: from gdb_websocket import GDBWebSocket [as 別名]
# 或者: from gdb_websocket.GDBWebSocket import close [as 別名]

#.........這裏部分代碼省略.........
            
                if self.detach_event.isSet():
                    continue
                
                self.abstract_socket.setBlocking(1)
                    
                data = data[data.index("$"):]
                
                self.lock.acquire()
            
                if len(data) != 0:
                    # decode and prepare resp
                    [resp, ack, detach] = self.handleMsg(data)
            
                    if resp is not None:
                        # ack
                        if ack:
                            resp = "+" + resp
                        # send resp
                        self.abstract_socket.write(resp.encode())
                        # wait a '+' from the client
                        try:
                            data = self.abstract_socket.read().decode()
                            if data[0] != '+':
                                logging.debug('gdb client has not ack!')
                            else:
                                logging.debug('gdb client has ack!')
                            if data.index("$") >= 0 and data.index("#") >= 0:
                                new_command = True
                        except:
                            pass
                        
                    if detach:
                        self.abstract_socket.close()
                        self.lock.release()
                        if self.persist:
                            break
                        else:
                            return

                    self.timeOfLastPacket = time()

                self.lock.release()
        
        
    def handleMsg(self, msg):
        
        if msg[0] != '$':
            logging.debug('msg ignored: first char != $')
            return None, 0, 0
        
        #logging.debug('-->>>>>>>>>>>> GDB rsp packet: %s', msg)
        
        # query command
        if msg[1] == 'q':
            return self.handleQuery(msg[2:]), 1, 0
            
        elif msg[1] == 'H':
            return self.createRSPPacket(''), 1, 0
        
        elif msg[1] == '?':
            return self.createRSPPacket(self.target.getTResponse()), 1, 0

        elif msg[1] == 'g':
            return self.getRegisters(), 1, 0
開發者ID:dbrobins,項目名稱:pyOCD,代碼行數:69,代碼來源:gdbserver.py

示例7: GDBServer

# 需要導入模塊: from gdb_websocket import GDBWebSocket [as 別名]
# 或者: from gdb_websocket.GDBWebSocket import close [as 別名]

#.........這裏部分代碼省略.........
                            self.sendStopNotification()
                    except Exception as e:
                        self.log.error("Unexpected exception: %s", e)
                        traceback.print_exc()

                # read command
                try:
                    packet = self.packet_io.receive(block=not self.non_stop)
                except ConnectionClosedException:
                    break

                if self.shutdown_event.isSet():
                    self._cleanup()
                    return

                if self.detach_event.isSet():
                    break

                if self.non_stop and packet is None:
                    sleep(0.1)
                    continue

                self.lock.acquire()

                if len(packet) != 0:
                    # decode and prepare resp
                    resp, detach = self.handleMsg(packet)

                    if resp is not None:
                        # send resp
                        self.packet_io.send(resp)

                    if detach:
                        self.abstract_socket.close()
                        self.packet_io.stop()
                        self.packet_io = None
                        self.lock.release()
                        if self.persist:
                            self._cleanup_for_next_connection()
                            break
                        else:
                            self.shutdown_event.set()
                            return

                self.lock.release()

            except Exception as e:
                self.log.error("Unexpected exception: %s", e)
                traceback.print_exc()

    def handleMsg(self, msg):
        try:
            assert msg[0] == '$', "invalid first char of message (!= $"

            try:
                handler, msgStart = self.COMMANDS[msg[1]]
                if msgStart == 0:
                    reply = handler()
                else:
                    reply = handler(msg[msgStart:])
                detach = 1 if msg[1] in self.DETACH_COMMANDS else 0
                return reply, detach
            except (KeyError, IndexError):
                self.log.error("Unknown RSP packet: %s", msg)
                return self.createRSPPacket(""), 0
開發者ID:matthewelse,項目名稱:pyOCD,代碼行數:69,代碼來源:gdbserver.py

示例8: GDBServer

# 需要導入模塊: from gdb_websocket import GDBWebSocket [as 別名]
# 或者: from gdb_websocket.GDBWebSocket import close [as 別名]

#.........這裏部分代碼省略.........

                if self.detach_event.isSet():
                    continue

                self.abstract_socket.setBlocking(1)

                data = data[data.index("$") :]

                self.lock.acquire()

                if len(data) != 0:
                    # decode and prepare resp
                    [resp, ack, detach] = self.handleMsg(data)

                    if resp is not None:
                        # ack
                        if ack:
                            resp = "+" + resp
                        # send resp
                        self.abstract_socket.write(resp)
                        # wait a '+' from the client
                        try:
                            data = self.abstract_socket.read()
                            if data[0] != "+":
                                logging.debug("gdb client has not ack!")
                            else:
                                logging.debug("gdb client has ack!")
                            if data.index("$") >= 0 and data.index("#") >= 0:
                                new_command = True
                        except:
                            pass

                    if detach:
                        self.abstract_socket.close()
                        self.lock.release()
                        break

                self.lock.release()

    def handleMsg(self, msg):

        if msg[0] != "$":
            logging.debug("msg ignored: first char != $")
            return None, 0, 0

        # logging.debug('-->>>>>>>>>>>> GDB rsp packet: %s', msg)

        # query command
        if msg[1] == "q":
            return self.handleQuery(msg[2:]), 1, 0

        elif msg[1] == "H":
            return self.createRSPPacket(""), 1, 0

        elif msg[1] == "?":
            return self.lastSignal(), 1, 0

        elif msg[1] == "g":
            return self.getRegister(), 1, 0

        elif msg[1] == "p":
            return self.readRegister(msg[2:]), 1, 0

        elif msg[1] == "P":
            return self.writeRegister(msg[2:]), 1, 0
開發者ID:Kazu-zamasu,項目名稱:pyOCD,代碼行數:69,代碼來源:gdbserver.py


注:本文中的gdb_websocket.GDBWebSocket.close方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。