<s> """<STR_LIT>""" <EOL> import types <EOL> import rpc <EOL> import Debugger <EOL> debugging = <NUM_LIT:0> <EOL> idb_adap_oid = "<STR_LIT>" <EOL> gui_adap_oid = "<STR_LIT>" <EOL> frametable = { } <EOL> dicttable = { } <EOL> codetable = { } <EOL> tracebacktable = { } <EOL> def wrap_frame ( frame ) : <EOL> fid = id ( frame ) <EOL> frametable [ fid ] = frame <EOL> return fid <EOL> def wrap_info ( info ) : <EOL> "<STR_LIT>" <EOL> if info is None : <EOL> return None <EOL> else : <EOL> traceback = info [ <NUM_LIT:2> ] <EOL> assert isinstance ( traceback , types . TracebackType ) <EOL> traceback_id = id ( traceback ) <EOL> tracebacktable [ traceback_id ] = traceback <EOL> modified_info = ( info [ <NUM_LIT:0> ] , info [ <NUM_LIT:1> ] , traceback_id ) <EOL> return modified_info <EOL> class GUIProxy : <EOL> def __init__ ( self , conn , gui_adap_oid ) : <EOL> self . conn = conn <EOL> self . oid = gui_adap_oid <EOL> def interaction ( self , message , frame , info = None ) : <EOL> self . conn . remotecall ( self . oid , "<STR_LIT>" , <EOL> ( message , wrap_frame ( frame ) , wrap_info ( info ) ) , <EOL> { } ) <EOL> class IdbAdapter : <EOL> def __init__ ( self , idb ) : <EOL> self . idb = idb <EOL> def set_step ( self ) : <EOL> self . idb . set_step ( ) <EOL> def set_quit ( self ) : <EOL> self . idb . set_quit ( ) <EOL> def set_continue ( self ) : <EOL> self . idb . set_continue ( ) <EOL> def set_next ( self , fid ) : <EOL> frame = frametable [ fid ] <EOL> self . idb . set_next ( frame ) <EOL> def set_return ( self , fid ) : <EOL> frame = frametable [ fid ] <EOL> self . idb . set_return ( frame ) <EOL> def get_stack ( self , fid , tbid ) : <EOL> frame = frametable [ fid ] <EOL> if tbid is None : <EOL> tb = None <EOL> else : <EOL> tb = tracebacktable [ tbid ] <EOL> stack , i = self . idb . get_stack ( frame , tb ) <EOL> stack = [ ( wrap_frame ( frame ) , k ) for frame , k in stack ] <EOL> return stack , i <EOL> def run ( self , cmd ) : <EOL> import __main__ <EOL> self . idb . run ( cmd , __main__ . __dict__ ) <EOL> def set_break ( self , filename , lineno ) : <EOL> msg = self . idb . set_break ( filename , lineno ) <EOL> return msg <EOL> def clear_break ( self , filename , lineno ) : <EOL> msg = self . idb . clear_break ( filename , lineno ) <EOL> return msg <EOL> def clear_all_file_breaks ( self , filename ) : <EOL> msg = self . idb . clear_all_file_breaks ( filename ) <EOL> return msg <EOL> def frame_attr ( self , fid , name ) : <EOL> frame = frametable [ fid ] <EOL> return getattr ( frame , name ) <EOL> def frame_globals ( self , fid ) : <EOL> frame = frametable [ fid ] <EOL> dict = frame . f_globals <EOL> did = id ( dict ) <EOL> dicttable [ did ] = dict <EOL> return did <EOL> def frame_locals ( self , fid ) : <EOL> frame = frametable [ fid ] <EOL> dict = frame . f_locals <EOL> did = id ( dict ) <EOL> dicttable [ did ] = dict <EOL> return did <EOL> def frame_code ( self , fid ) : <EOL> frame = frametable [ fid ] <EOL> code = frame . f_code <EOL> cid = id ( code ) <EOL> codetable [ cid ] = code <EOL> return cid <EOL> def code_name ( self , cid ) : <EOL> code = codetable [ cid ] <EOL> return code . co_name <EOL> def code_filename ( self , cid ) : <EOL> code = codetable [ cid ] <EOL> return code . co_filename <EOL> def dict_keys ( self , did ) : <EOL> dict = dicttable [ did ] <EOL> return dict . keys ( ) <EOL> def dict_item ( self , did , key ) : <EOL> dict = dicttable [ did ] <EOL> value = dict [ key ] <EOL> value = repr ( value ) <EOL> return value <EOL> def start_debugger ( rpchandler , gui_adap_oid ) : <EOL> """<STR_LIT>""" <EOL> gui_proxy = GUIProxy ( rpchandler , gui_adap_oid ) <EOL> idb = Debugger . Idb ( gui_proxy ) <EOL> idb_adap = IdbAdapter ( idb ) <EOL> rpchandler . register ( idb_adap_oid , idb_adap ) <EOL> return idb_adap_oid <EOL> class FrameProxy : <EOL> def __init__ ( self , conn , fid ) : <EOL> self . _conn = conn <EOL> self . _fid = fid <EOL> self . _oid = "<STR_LIT>" <EOL> self . _dictcache = { } <EOL> def __getattr__ ( self , name ) : <EOL> if name [ : <NUM_LIT:1> ] == "<STR_LIT:_>" : <EOL> raise AttributeError , name <EOL> if name == "<STR_LIT>" : <EOL> return self . _get_f_code ( ) <EOL> if name == "<STR_LIT>" : <EOL> return self . _get_f_globals ( ) <EOL> if name == "<STR_LIT>" : <EOL> return self . _get_f_locals ( ) <EOL> return self . _conn . remotecall ( self . _oid , "<STR_LIT>" , <EOL> ( self . _fid , name ) , { } ) <EOL> def _get_f_code ( self ) : <EOL> cid = self . _conn . remotecall ( self . _oid , "<STR_LIT>" , ( self . _fid , ) , { } ) <EOL> return CodeProxy ( self . _conn , self . _oid , cid ) <EOL> def _get_f_globals ( self ) : <EOL> did = self . _conn . remotecall ( self . _oid , "<STR_LIT>" , <EOL> ( self . _fid , ) , { } ) <EOL> return self . _get_dict_proxy ( did ) <EOL> def _get_f_locals ( self ) : <EOL> did = self . _conn . remotecall ( self . _oid , "<STR_LIT>" , <EOL> ( self . _fid , ) , { } ) <EOL> return self . _get_dict_proxy ( did ) <EOL> def _get_dict_proxy ( self , did ) : <EOL> if self . _dictcache . has_key ( did ) : <EOL> return self . _dictcache [ did ] <EOL> dp = DictProxy ( self . _conn , self . _oid , did ) <EOL> self . _dictcache [ did ] = dp <EOL> return dp <EOL> class CodeProxy : <EOL> def __init__ ( self , conn , oid , cid ) : <EOL> self . _conn = conn <EOL> self . _oid = oid <EOL> self . _cid = cid <EOL> def __getattr__ ( self , name ) : <EOL> if name == "<STR_LIT>" : <EOL> return self . _conn . remotecall ( self . _oid , "<STR_LIT>" , <EOL> ( self . _cid , ) , { } ) <EOL> if name == "<STR_LIT>" : <EOL> return self . _conn . remotecall ( self . _oid , "<STR_LIT>" , <EOL> ( self . _cid , ) , { } ) <EOL> class DictProxy : <EOL> def __init__ ( self , conn , oid , did ) : <EOL> self . _conn = conn <EOL> self . _oid = oid <EOL> self . _did = did <EOL> def keys ( self ) : <EOL> return self . _conn . remotecall ( self . _oid , "<STR_LIT>" , ( self . _did , ) , { } ) <EOL> def __getitem__ ( self , key ) : <EOL> return self . _conn . remotecall ( self . _oid , "<STR_LIT>" , <EOL> ( self . _did , key ) , { } ) <EOL> def __getattr__ ( self , name ) : <EOL> raise AttributeError , name <EOL> class GUIAdapter : <EOL> def __init__ ( self , conn , gui ) : <EOL> self . conn = conn <EOL> self . gui = gui <EOL> def interaction ( self , message , fid , modified_info ) : <EOL> frame = FrameProxy ( self . conn , fid ) <EOL> self . gui . interaction ( message , frame , modified_info ) <EOL> class IdbProxy : <EOL> def __init__ ( self , conn , shell , oid ) : <EOL> self . oid = oid <EOL> self . conn = conn <EOL> self . shell = shell <EOL> def call ( self , methodname , * args , ** kwargs ) : <EOL> value = self . conn . remotecall ( self . oid , methodname , args , kwargs ) <EOL> return value <EOL> def run ( self , cmd , locals ) : <EOL> seq = self . conn . asyncqueue ( self . oid , "<STR_LIT>" , ( cmd , ) , { } ) <EOL> self . shell . interp . active_seq = seq <EOL> def get_stack ( self , frame , tbid ) : <EOL> stack , i = self . call ( "<STR_LIT>" , frame . _fid , tbid ) <EOL> stack = [ ( FrameProxy ( self . conn , fid ) , k ) for fid , k in stack ] <EOL> return stack , i <EOL> def set_continue ( self ) : <EOL> self . call ( "<STR_LIT>" ) <EOL> def set_step ( self ) : <EOL> self . call ( "<STR_LIT>" ) <EOL> def set_next ( self , frame ) : <EOL> self . call ( "<STR_LIT>" , frame . _fid ) <EOL> def set_return ( self , frame ) : <EOL> self . call ( "<STR_LIT>" , frame . _fid ) <EOL> def set_quit ( self ) : <EOL> self . call ( "<STR_LIT>" ) <EOL> def set_break ( self , filename , lineno ) : <EOL> msg = self . call ( "<STR_LIT>" , filename , lineno ) <EOL> return msg <EOL> def clear_break ( self , filename , lineno ) : <EOL> msg = self . call ( "<STR_LIT>" , filename , lineno ) <EOL> return msg <EOL> def clear_all_file_breaks ( self , filename ) : <EOL> msg = self . call ( "<STR_LIT>" , filename ) <EOL> return msg <EOL> def start_remote_debugger ( rpcclt , pyshell ) : <EOL> """<STR_LIT>""" <EOL> global idb_adap_oid <EOL> idb_adap_oid = rpcclt . remotecall ( "<STR_LIT>" , "<STR_LIT>" , ( gui_adap_oid , ) , { } ) <EOL> idb_proxy = IdbProxy ( rpcclt , pyshell , idb_adap_oid ) <EOL> gui = Debugger . Debugger ( pyshell , idb_proxy ) <EOL> gui_adap = GUIAdapter ( rpcclt , gui ) <EOL> rpcclt . register ( gui_adap_oid , gui_adap ) <EOL> return gui <EOL> def close_remote_debugger ( rpcclt ) : <EOL> """<STR_LIT>""" <EOL> close_subprocess_debugger ( rpcclt ) <EOL> rpcclt . unregister ( gui_adap_oid ) <EOL> def close_subprocess_debugger ( rpcclt ) : <EOL> rpcclt . remotecall ( "<STR_LIT>" , "<STR_LIT>" , ( idb_adap_oid , ) , { } ) <EOL> def restart_subprocess_debugger ( rpcclt ) : <EOL> idb_adap_oid_ret = rpcclt . remotecall ( "<STR_LIT>" , "<STR_LIT>" , ( gui_adap_oid , ) , { } ) <EOL> assert idb_adap_oid_ret == idb_adap_oid , '<STR_LIT>' </s>
