#NEWLINE# def handleMsg( self , msg ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# if ( msg [ 0 ] != '$' ) : #NEWLINE# #INDENT# logging . debug ( 'msg ignored: first char != $' ) #NEWLINE# return ( None , 0 ) #NEWLINE# #UNINDENT# if ( msg [ 1 ] == '?' ) : #NEWLINE# #INDENT# return ( self . stopReasonQuery ( ) , 0 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( msg [ 1 ] == 'C' ) or ( msg [ 1 ] == 'c' ) ) : #NEWLINE# #INDENT# return ( self . resume ( msg [ 1 : ] ) , 0 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( msg [ 1 ] == 'D' ) : #NEWLINE# #INDENT# return ( self . detach ( msg [ 1 : ] ) , 1 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( msg [ 1 ] == 'g' ) : #NEWLINE# #INDENT# return ( self . getRegisters ( ) , 0 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( msg [ 1 ] == 'G' ) : #NEWLINE# #INDENT# return ( self . setRegisters ( msg [ 2 : ] ) , 0 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( msg [ 1 ] == 'H' ) : #NEWLINE# #INDENT# return ( self . createRSPPacket ( 'OK' ) , 0 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( msg [ 1 ] == 'k' ) : #NEWLINE# #INDENT# return ( self . kill ( ) , 1 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( msg [ 1 ] == 'm' ) : #NEWLINE# #INDENT# return ( self . getMemory ( msg [ 2 : ] ) , 0 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( msg [ 1 ] == 'M' ) : #NEWLINE# #INDENT# return ( self . writeMemoryHex ( msg [ 2 : ] ) , 0 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( msg [ 1 ] == 'p' ) : #NEWLINE# #INDENT# return ( self . readRegister ( msg [ 2 : ] ) , 0 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( msg [ 1 ] == 'P' ) : #NEWLINE# #INDENT# return ( self . writeRegister ( msg [ 2 : ] ) , 0 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( msg [ 1 ] == 'q' ) : #NEWLINE# #INDENT# return ( self . handleQuery ( msg [ 2 : ] ) , 0 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( msg [ 1 ] == 'Q' ) : #NEWLINE# #INDENT# return ( self . handleGeneralSet ( msg [ 2 : ] ) , 0 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( msg [ 1 ] == 'S' ) or ( msg [ 1 ] == 's' ) ) : #NEWLINE# #INDENT# return ( self . step ( msg [ 1 : ] ) , 0 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( msg [ 1 ] == 'T' ) : #NEWLINE# #INDENT# return ( self . createRSPPacket ( 'OK' ) , 0 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( msg [ 1 ] == 'v' ) : #NEWLINE# #INDENT# return ( self . vCommand ( msg [ 2 : ] ) , 0 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( msg [ 1 ] == 'X' ) : #NEWLINE# #INDENT# return ( self . writeMemory ( msg [ 2 : ] ) , 0 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( msg [ 1 ] == 'Z' ) or ( msg [ 1 ] == 'z' ) ) : #NEWLINE# #INDENT# return ( self . breakpoint ( msg [ 1 : ] ) , 0 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# logging . error ( 'Unknown RSP packet: %s' , self ) #NEWLINE# return ( self . createRSPPacket ( '' ) , 0 ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# except Exception as e : #NEWLINE# #INDENT# logging . error ( 'Unhandled exception in handleMsg: %s' , e ) #NEWLINE# traceback . print_exc ( ) #NEWLINE# return ( self . createRSPPacket ( 'E01' ) , 0 )