Your IP : 18.119.118.237


Current Path : /opt/alt/python35/lib64/python3.5/idlelib/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/idlelib/__pycache__/RemoteDebugger.cpython-35.pyc



��Yf�.�@s)dZddlZddlmZdZdadZiZiZiZ	iZ
dd�Zdd	�ZGd
d�d�Z
Gdd
�d
�Zdd�ZGdd�d�ZGdd�d�ZGdd�d�ZGdd�d�ZGdd�d�Zdd�Zdd�Zdd�Zd d!�ZdS)"a�Support for remote Python debugging.

Some ASCII art to describe the structure:

       IN PYTHON SUBPROCESS          #             IN IDLE PROCESS
                                     #
                                     #        oid='gui_adapter'
                 +----------+        #       +------------+          +-----+
                 | GUIProxy |--remote#call-->| GUIAdapter |--calls-->| GUI |
+-----+--calls-->+----------+        #       +------------+          +-----+
| Idb |                               #                             /
+-----+<-calls--+------------+         #      +----------+<--calls-/
                | IdbAdapter |<--remote#call--| IdbProxy |
                +------------+         #      +----------+
                oid='idb_adapter'      #

The purpose of the Proxy and Adapter classes is to translate certain
arguments and return values that cannot be transported through the RPC
barrier, in particular frame and traceback objects.

�N)�Debugger�idb_adapterZgui_adaptercCst|�}|t|<|S)N)�id�
frametable)�frame�fid�r�;/opt/alt/python35/lib64/python3.5/idlelib/RemoteDebugger.py�
wrap_frame(s
r
cCsg|dkrdS|d}t|tj�s2t�t|�}|t|<|d|d|f}|SdS)z0replace info[2], a traceback instance, by its IDN�r�)�
isinstance�types�
TracebackType�AssertionErrorr�tracebacktable)�info�	tracebackZtraceback_id�
modified_inforrr	�	wrap_info-s

rc@s+eZdZdd�Zddd�ZdS)�GUIProxycCs||_||_dS)N)�conn�oid)�selfr�gui_adap_oidrrr	�__init__;s	zGUIProxy.__init__NcCs5|jj|jd|t|�t|�fi�dS)N�interaction)r�
remotecallrr
r)r�messagerrrrr	r?szGUIProxy.interaction)�__name__�
__module__�__qualname__rrrrrr	r9src@seZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)S)*�
IdbAdaptercCs
||_dS)N)�idb)rr#rrr	rHszIdbAdapter.__init__cCs|jj�dS)N)r#�set_step)rrrr	r$MszIdbAdapter.set_stepcCs|jj�dS)N)r#�set_quit)rrrr	r%PszIdbAdapter.set_quitcCs|jj�dS)N)r#�set_continue)rrrr	r&SszIdbAdapter.set_continuecCst|}|jj|�dS)N)rr#�set_next)rrrrrr	r'Vs
zIdbAdapter.set_nextcCst|}|jj|�dS)N)rr#�
set_return)rrrrrr	r(Zs
zIdbAdapter.set_returncCsat|}|dkrd}n
t|}|jj||�\}}dd�|D�}||fS)NcSs(g|]\}}t|�|f�qSr)r
)�.0Zframe2�krrr	�
<listcomp>es	z(IdbAdapter.get_stack.<locals>.<listcomp>)rrr#�	get_stack)rr�tbidr�tb�stack�irrr	r,^s
	
zIdbAdapter.get_stackcCs&ddl}|jj||j�dS)Nr)�__main__r#�run�__dict__)r�cmdr1rrr	r2hszIdbAdapter.runcCs|jj||�}|S)N)r#�	set_break)r�filename�lineno�msgrrr	r5lszIdbAdapter.set_breakcCs|jj||�}|S)N)r#�clear_break)rr6r7r8rrr	r9pszIdbAdapter.clear_breakcCs|jj|�}|S)N)r#�clear_all_file_breaks)rr6r8rrr	r:tsz IdbAdapter.clear_all_file_breakscCst|}t||�S)N)r�getattr)rr�namerrrr	�
frame_attrzs
zIdbAdapter.frame_attrcCs-t|}|j}t|�}|t|<|S)N)r�	f_globalsr�	dicttable)rrr�dict�didrrr	�
frame_globals~s

	
zIdbAdapter.frame_globalscCs-t|}|j}t|�}|t|<|S)N)r�f_localsrr?)rrrr@rArrr	�frame_locals�s

	
zIdbAdapter.frame_localscCs-t|}|j}t|�}|t|<|S)N)r�f_coder�	codetable)rrr�code�cidrrr	�
frame_code�s

	
zIdbAdapter.frame_codecCst|}|jS)N)rF�co_name)rrHrGrrr	�	code_name�s
zIdbAdapter.code_namecCst|}|jS)N)rF�co_filename)rrHrGrrr	�
code_filename�s
zIdbAdapter.code_filenamecCstd��dS)Nz"dict_keys not public or pickleable)�NotImplemented)rrArrr	�	dict_keys�szIdbAdapter.dict_keyscCst|}t|j��S)N)r?�list�keys)rrAr@rrr	�dict_keys_list�s
zIdbAdapter.dict_keys_listcCs$t|}||}t|�}|S)N)r?�repr)rrA�keyr@�valuerrr	�	dict_item�s

zIdbAdapter.dict_itemN)rr r!rr$r%r&r'r(r,r2r5r9r:r=rBrDrIrKrMrOrRrVrrrr	r"Fs(
	r"cCs>t||�}tj|�}t|�}|jt|�tS)a|Start the debugger and its RPC link in the Python subprocess

    Start the subprocess side of the split debugger and set up that side of the
    RPC link by instantiating the GUIProxy, Idb debugger, and IdbAdapter
    objects and linking them together.  Register the IdbAdapter with the
    RPCServer to handle RPC requests from the split debugger GUI via the
    IdbProxy.

    )rrZIdbr"�register�idb_adap_oid)Z
rpchandlerrZ	gui_proxyr#Zidb_adaprrr	�start_debugger�s

rYc@sXeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�
FrameProxycCs(||_||_d|_i|_dS)Nr)�_conn�_fid�_oid�
_dictcache)rrrrrr	r�s			zFrameProxy.__init__cCs�|dd�dkr"t|��|dkr8|j�S|dkrN|j�S|dkrd|j�S|jj|jd|j|fi�S)Nr�_rEr>rCr=)�AttributeError�_get_f_code�_get_f_globals�
_get_f_localsr[rr]r\)rr<rrr	�__getattr__�s


zFrameProxy.__getattr__cCs:|jj|jd|jfi�}t|j|j|�S)NrI)r[rr]r\�	CodeProxy)rrHrrr	ra�s$zFrameProxy._get_f_codecCs1|jj|jd|jfi�}|j|�S)NrB)r[rr]r\�_get_dict_proxy)rrArrr	rb�szFrameProxy._get_f_globalscCs1|jj|jd|jfi�}|j|�S)NrD)r[rr]r\rf)rrArrr	rc�szFrameProxy._get_f_localscCsC||jkr|j|St|j|j|�}||j|<|S)N)r^�	DictProxyr[r])rrAZdprrr	rf�s

zFrameProxy._get_dict_proxyN)	rr r!rrdrarbrcrfrrrr	rZ�srZc@s(eZdZdd�Zdd�ZdS)recCs||_||_||_dS)N)r[r]�_cid)rrrrHrrr	r�s		zCodeProxy.__init__cCs`|dkr.|jj|jd|jfi�S|dkr\|jj|jd|jfi�SdS)NrJrKrLrM)r[rr]rh)rr<rrr	rd�szCodeProxy.__getattr__N)rr r!rrdrrrr	re�srec@s@eZdZdd�Zdd�Zdd�Zdd�Zd	S)
rgcCs||_||_||_dS)N)r[r]�_did)rrrrArrr	rs		zDictProxy.__init__cCs"|jj|jd|jfi�S)NrR)r[rr]ri)rrrr	rQszDictProxy.keyscCs%|jj|jd|j|fi�S)NrV)r[rr]ri)rrTrrr	�__getitem__szDictProxy.__getitem__cCst|��dS)N)r`)rr<rrr	rdszDictProxy.__getattr__N)rr r!rrQrjrdrrrr	rgs	rgc@s(eZdZdd�Zdd�ZdS)�
GUIAdaptercCs||_||_dS)N)r�gui)rrrlrrr	rs	zGUIAdapter.__init__cCs,t|j|�}|jj|||�dS)N)rZrrlr)rrrrrrrr	r!szGUIAdapter.interactionN)rr r!rrrrrr	rksrkc@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�ZdS)�IdbProxycCs||_||_||_dS)N)rr�shell)rrrnrrrr	r)s		zIdbProxy.__init__cOs"|jj|j|||�}|S)N)rrr)rZ
methodname�args�kwargsrUrrr	�call.sz
IdbProxy.callcCs4|jj|jd|fi�}||jj_dS)Nr2)rZ
asyncqueuerrnZinterpZ
active_seq)rr4�locals�seqrrr	r24s!zIdbProxy.runcsA�jd|j|�\}}�fdd�|D�}||fS)Nr,cs.g|]$\}}t�j|�|f�qSr)rZr)r)rr*)rrr	r+<s	z&IdbProxy.get_stack.<locals>.<listcomp>)rqr\)rrr-r/r0r)rr	r,9szIdbProxy.get_stackcCs|jd�dS)Nr&)rq)rrrr	r&?szIdbProxy.set_continuecCs|jd�dS)Nr$)rq)rrrr	r$BszIdbProxy.set_stepcCs|jd|j�dS)Nr')rqr\)rrrrr	r'EszIdbProxy.set_nextcCs|jd|j�dS)Nr()rqr\)rrrrr	r(HszIdbProxy.set_returncCs|jd�dS)Nr%)rq)rrrr	r%KszIdbProxy.set_quitcCs|jd||�}|S)Nr5)rq)rr6r7r8rrr	r5NszIdbProxy.set_breakcCs|jd||�}|S)Nr9)rq)rr6r7r8rrr	r9RszIdbProxy.clear_breakcCs|jd|�}|S)Nr:)rq)rr6r8rrr	r:VszIdbProxy.clear_all_file_breaksN)rr r!rrqr2r,r&r$r'r(r%r5r9r:rrrr	rm'srmcCsb|jddtfi�at||t�}tj||�}t||�}|jt|�|S)a]Start the subprocess debugger, initialize the debugger GUI and RPC link

    Request the RPCServer start the Python subprocess debugger and link.  Set
    up the Idle side of the split debugger by instantiating the IdbProxy,
    debugger GUI, and debugger GUIAdapter objects and linking them together.

    Register the GUIAdapter with the RPCClient to handle debugger GUI
    interaction requests coming from the subprocess debugger via the GUIProxy.

    The IdbAdapter will pass execution and environment requests coming from the
    Idle debugger GUI to the subprocess debugger via the IdbProxy.

    �exec�start_the_debugger)rrrXrmrrkrW)�rpccltZpyshellZ	idb_proxyrlZgui_adaprrr	�start_remote_debuggerZsrwcCst|�|jt�dS)a]Shut down subprocess debugger and Idle side of debugger RPC link

    Request that the RPCServer shut down the subprocess debugger and link.
    Unregister the GUIAdapter, which will cause a GC on the Idle process
    debugger and RPC link objects.  (The second reference to the debugger GUI
    is deleted in PyShell.close_remote_debugger().)

    N)�close_subprocess_debuggerZ
unregisterr)rvrrr	�close_remote_debuggerrs	
rycCs|jddtfi�dS)NrtZstop_the_debugger)rrX)rvrrr	rx~srxcCs7|jddtfi�}|tks3td��dS)Nrtruz Idb restarted with different oid)rrrXr)rvZidb_adap_oid_retrrr	�restart_subprocess_debugger�srz)�__doc__rZidlelibrZ	debuggingrXrrr?rFrr
rrr"rYrZrergrkrmrwryrxrzrrrr	�<module>s.
m*3

?>