a
    ö£Be®
  ã                   @   s@   d Z ddlZej e¡Zej ej ej e¡¡¡Zdd„ ZdS )z?Script injected into the debuggee process during attach-to-PID.é    Nc                    s  d }�zÆdd l ‰ dˆ jvr¸z~‡ fdd„}‡ fdd„}‡ fdd„}tj td	d
dd¡}tj |¡sdJ ‚ˆ j d|¡ dd l}|j	|||d� ˆ j 
|¡ W n   dd l}| ¡  ‚ Y n0 ˆ j dt¡ zHdd l}dd l}ddlm}	m} dd l}
W ˆ jd tk�sJ ‚ˆ jd= nˆ jd tk�s$J ‚ˆ jd= 0 |
 ¡ }|d u�rL|jdd� | d d u�rh| | d ¡ | d|	 | ¡¡ | d dk�r˜| | d ¡ n2| d dk�r¾|j| d | d d� ntt| ƒƒ‚W n2   dd l}| ¡  |d u �rò‚ n| ¡  Y n0 | d¡ d S )Nr   Ú	threadingc                    s   t | ˆ jd� d S ©N)Úfile©ÚprintÚstderr©Úmsg©Úsys© úe/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/debugpy/server/attach_pid_injected.pyÚon_warn   s    zattach.<locals>.on_warnc                    s   t | ˆ jd� d S r   r   r   r
   r   r   Úon_exception   s    zattach.<locals>.on_exceptionc                    s   t | ˆ jd� d S r   r   r   r
   r   r   Úon_critical   s    zattach.<locals>.on_criticalÚdebugpyZ	_vendoredÚpydevdZpydevd_attach_to_process)r   r   r   )ÚjsonÚlogF)ÚwaitÚlog_toz!Configuring injected debugpy: {0}ÚmodeÚlistenÚaddressÚconnectZadapter_access_token)Zaccess_tokenzdebugpy injected successfully)r   ÚmodulesÚosÚpathÚjoinÚ_debugpy_dirÚexistsÚinsertÚattach_scriptZfix_main_thread_idÚremoveÚ	tracebackÚ	print_excr   Zdebugpy.serverZdebugpy.commonr   r   r   Zget_global_debuggerZ#dispose_and_kill_all_pydevd_threadsr   ÚinfoÚreprr   r   ÚAssertionErrorZreraise_exception)Úsetupr   r   r   r   Zpydevd_attach_to_process_pathr"   r$   r   r   r   Zpy_dbr   r
   r   Úattach   sp    
ûÿ

ÿ

ÿ
r*   )Ú__doc__r   r   ÚabspathÚ__file__Údirnamer   r*   r   r   r   r   Ú<module>   s   