a �DOg�z�@s�ddlZddlZddlZddlmZmZmZgd�ZeeBeBZGdd�de �Z Gdd�d�Z dd �Z Gd d �d �Z d d �Zdd�ZGdd�de �Zdd�Zdd�Zdd�ZdS)�N)� CO_GENERATOR� CO_COROUTINE�CO_ASYNC_GENERATOR)�BdbQuit�Bdb� Breakpointc@s eZdZdS)rN)�__name__� __module__� __qualname__�r r �/usr/lib64/python3.9/bdb.pyr src@sleZdZdYdd�Zdd�Zdd�Zdd �Zd d �Zd d �Zdd�Z dd�Z dd�Z dd�Z dd�Z dd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�ZdZd%d&�Zd[d'd(�Zd)d*�Zd+d,�Zd-d.�Zd\d/d0�Zd1d2�Zd3d4�Zd]d6d7�Zd8d9�Zd:d;�Zdd?�Z d@dA�Z!dBdC�Z"dDdE�Z#dFdG�Z$dHdI�Z%dJdK�Z&dLdM�Z'd^dOdP�Z(d_dQdR�Z)d`dSdT�Z*dUdV�Z+dWdX�Z,dS)arNcCs(|r t|�nd|_i|_i|_d|_dS�N)�set�skip�breaks�fncache�frame_returning)�selfrr r r �__init__sz Bdb.__init__cCsR|d|dd�dkr|S|j�|�}|sNtj�|�}tj�|�}||j|<|S)N�<�������>)r�get�os�path�abspath�normcase)r�filename�canonicr r r r%s    z Bdb.canoniccCs&ddl}|��d|_|�dd�dS)Nr)� linecache� checkcache�botframe� _set_stopinfo)rr r r r �reset6sz Bdb.resetcCs�|jr dS|dkr|�|�S|dkr0|�||�S|dkrD|�||�S|dkrX|�||�S|dkrf|jS|dkrt|jS|dkr�|jStdt|��|jS) N�line�call�return� exceptionZc_callZ c_exceptionZc_returnz*bdb.Bdb.dispatch: unknown debugging event:)�quitting� dispatch_line� dispatch_call�dispatch_return�dispatch_exception�trace_dispatch�print�repr)r�frame�event�argr r r r.=s$    zBdb.trace_dispatchcCs.|�|�s|�|�r(|�|�|jr(t�|jSr )� stop_here� break_here� user_liner)rr.�rr1r r r r*hs  zBdb.dispatch_linecCsd|jdur|j|_|jS|�|�s0|�|�s0dS|jrH|jjt@rH|jS|� ||�|j r^t �|jSr ) r"�f_backr.r4�break_anywhere� stopframe�f_code�co_flags�GENERATOR_AND_COROUTINE_FLAGS� user_callr)r�rr1r3r r r r+ts   zBdb.dispatch_callcCs�|�|�s||jkr||jr,|jjt@r,|jSz||_|�||�Wd|_nd|_0|j r\t �|j|ur||j dkr||� dd�|jS�Nr) r4� returnframer:r;r<r=r.r� user_returnr)r� stoplinenor#r?r r r r,�s  zBdb.dispatch_returncCs�|�|�rF|jjt@r.|dtur.|ddus�|�||�|jr�t�nD|jr�||jur�|jjjt@r�|dtt fvr�|�||�|jr�t�|j S)Nr�) r4r;r<r=� StopIteration�user_exceptionr)rr:� GeneratorExitr.r?r r r r-�s    � �   ��  zBdb.dispatch_exceptioncCs.|dur dS|jD]}t�||�rdSqdS�NFT)r�fnmatch)r� module_name�patternr r r �is_skipped_module�s   zBdb.is_skipped_modulecCsN|jr|�|j�d��rdS||jur@|jdkr4dS|j|jkS|jsJdSdS)NrFrT)rrL� f_globalsrr:rC�f_linenor7r r r r4�s�   z Bdb.stop_herecCs�|�|jj�}||jvrdS|j}||j|vrJ|jj}||j|vrJdSt|||�\}}|r�|j|_|r�|j r�|� t |j��dSdSdSrH) rr;� co_filenamerrN�co_firstlineno� effective�numberZ currentbp� temporary�do_clear�str)rr1r�lineno�bp�flagr r r r5�s  zBdb.break_herecCs td��dS)Nz)subclass of bdb must implement do_clear())�NotImplementedError)rr3r r r rT�sz Bdb.do_clearcCs|�|jj�|jvSr )rr;rOrr7r r r r9�szBdb.break_anywherecCsdSr r )rr1Z argument_listr r r r>sz Bdb.user_callcCsdSr r r7r r r r6sz Bdb.user_linecCsdSr r )rr1Z return_valuer r r rB szBdb.user_returncCsdSr r )rr1�exc_infor r r rF szBdb.user_exceptionrcCs||_||_d|_||_dS�NF)r:rAr)rC)rr:rArCr r r r#szBdb._set_stopinfocCs$|dur|jd}|�|||�dS)Nr)rNr#)rr1rVr r r � set_until"s z Bdb.set_untilcCs0|jr |jj}|r |js |j|_|�dd�dSr )rr8�f_tracer.r#)rZ caller_framer r r �set_step*s  z Bdb.set_stepcCs|�|d�dSr )r#r7r r r �set_next6sz Bdb.set_nextcCs.|jjt@r|�|dd�n|�|j|�dSr@)r;r<r=r#r8r7r r r � set_return:s zBdb.set_returncCsL|durt��j}|��|r4|j|_||_|j}q|��t�|j�dSr ) �sys� _getframer8r$r.r]r"r^�settracer7r r r � set_traceAs z Bdb.set_tracecCsH|�|jdd�|jsDt�d�t��j}|rD||jurD|`|j}q*dSr@)r#r"rrarcrbr8r]r7r r r � set_continuePs  zBdb.set_continuecCs"|j|_d|_d|_t�d�dS�NT)r"r:rAr)rarc�rr r r �set_quit_sz Bdb.set_quitFc Csb|�|�}ddl}|�||�}|s.d||fS|j�|g�}||vrN|�|�t|||||�} dS)NrzLine %s:%d does not exist)rr �getliner� setdefault�appendr) rrrVrS�cond�funcnamer r%�listrWr r r � set_breakps    z Bdb.set_breakcCs4||ftjvr|j|�|�|j|s0|j|=dSr )r�bplistr�remove�rrrVr r r � _prune_breaks�s zBdb._prune_breakscCsj|�|�}||jvrd|S||j|vr6d||fStj||fdd�D] }|��qL|�||�dS)N�There are no breakpoints in %szThere is no breakpoint at %s:%d)rrrrp�deleteMers)rrrVrWr r r � clear_break�s     zBdb.clear_breakc CsXz|�|�}Wn,ty:}zt|�WYd}~Sd}~00|��|�|j|j�dSr )�get_bpbynumber� ValueErrorrUrurs�filer%)rr3rW�errr r r �clear_bpbynumber�szBdb.clear_bpbynumbercCsX|�|�}||jvrd|S|j|D]$}tj||f}|D] }|��qz()Z __return__z->) r �reprlibrr;rO�co_name�f_localsr0rirM�strip) rZ frame_linenoZlprefixr r�r1rVr�s�rvr%r r r �format_stack_entrys    zBdb.format_stack_entryc Cs�|durddl}|j}|dur"|}|��t|t�r@t|dd�}t�|j�z8zt |||�Wnt ypYn0Wd|_ t�d�nd|_ t�d�0dS)Nrz�execT) �__main__�__dict__r$� isinstancerU�compilerarcr.r�rr))r�cmd�globals�localsr�r r r �run5s"     �zBdb.runc Cs�|durddl}|j}|dur"|}|��t�|j�zHz t|||�WWd|_t�d�StyjYn0Wd|_t�d�nd|_t�d�0dS)NrT) r�r�r$rarcr.�evalr)r)r�exprr�r�r�r r r �runevalKs$  �  �z Bdb.runevalcCs|�|||�dSr )r�)rr�r�r�r r r �runctx_sz Bdb.runctxc Osj|��t�|j�d}z:z||i|��}Wnty>Yn0Wd|_t�d�nd|_t�d�0|Srf)r$rarcr.rr))r�func�args�kwds�resr r r �runcallfs   � z Bdb.runcall)N)r)N)N)FNN)r�)NN)NN)-rr r rrr$r.r*r+r,r-rLr4r5rTr9r>r6rBrFr#r\r^r_r`rdrerhrorsrvr{r|r~rwr�r�r�r�r�r�r�r�r�r�r r r r rsX +      �         rcCst���dSr )rrdr r r r rdxsrdc@sVeZdZdZiZdgZddd�Zdd�Zdd �Zd d �Z dd d �Z dd�Z dd�Z dS)rrNFcCs�||_d|_||_||_||_||_d|_d|_d|_t j |_ t j d7_ |j � |�||f|jvr||j||f� |�n|g|j||f<dS)NTrr)rm�func_first_executable_lineryr%rSrl�enabled�ignore�hitsr�nextrRr}rkrp)rryr%rSrlrmr r r r�s zBreakpoint.__init__cCs>|j|jf}d|j|j<|j|�|�|j|s:|j|=dSr )ryr%r}rRrprq)r�indexr r r ru�s    zBreakpoint.deleteMecCs d|_dSrf�r�rgr r r �enable�szBreakpoint.enablecCs d|_dSr[r�rgr r r �disable�szBreakpoint.disablecCs"|durtj}t|��|d�dS)N)ry)ra�stdoutr/�bpformat)r�outr r r �bpprint�szBreakpoint.bpprintcCs�|jr d}nd}|jr |d}n|d}d|j||j|jf}|jrT|d|jf7}|jrj|d|jf7}|jr�|jdkr�d }nd }|d |j|f7}|S) Nzdel zkeep zyes zno z%-4dbreakpoint %s at %s:%dz stop only if %sz ignore next %d hitsrr��z" breakpoint already hit %d time%s)rSr�rRryr%rlr�r�)rZdisp�ret�ssr r r r��s& � zBreakpoint.bpformatcCsd|j|j|jfS)Nzbreakpoint %s at %s:%s)rRryr%rgr r r �__str__�szBreakpoint.__str__)FNN)N) rr r r�rpr}rrur�r�r�r�r�r r r r r}s  rcCsN|js|j|jkrdSdS|jj|jkr,dS|js:|j|_|j|jkrJdSdSrH)rmr%rNr;r�r�)�br1r r r � checkfuncname�s  r�cCs�tj||f}|D]�}|jsqt||�s*q|jd7_|jsh|jdkrZ|jd8_qq�|dfSqzBt|j|j|j �}|r�|jdkr�|jd8_n|dfWSWq|dfYS0qdS)NrrTF)NN) rrpr�r�r�rlr�r�rMr�)ryr%r1Z possiblesr��valr r r rQs*   rQc@s,eZdZdd�Zdd�Zdd�Zdd�Zd S) �TdbcCs |jj}|sd}td||�dS)N�???z+++ call)r;r�r/)rr1r��namer r r r>Dsz Tdb.user_callcCsTddl}|jj}|sd}|�|jj�}|�||j|j�}td||j|d|� ��dS)Nrr�z+++�:) r r;r�rrOrirNrMr/r�)rr1r r��fnr%r r r r6Hs z Tdb.user_linecCstd|�dS)Nz +++ return�r/)rr1Zretvalr r r rBOszTdb.user_returncCstd|�|��dS)Nz +++ exception)r/re)rr1Z exc_stuffr r r rFQs zTdb.user_exceptionN)rr r r>r6rBrFr r r r r�Csr�cCs&td|d�t|d�}td|�dS)Nzfoo(�)� z bar returned)r/�bar)�n�xr r r �fooUs  r�cCstd|d�|dS)Nzbar(r�rDr�)�ar r r r�Zs r�cCst�}|�d�dS)Nzimport bdb; bdb.foo(10))r�r�)r�r r r �test^sr�)rIrar�inspectrrr�__all__r=� Exceptionrrrdrr�rQr�r�r�r�r r r r �s& kt"0