
bc           @   s   d  Z  d d l Z d d l Z d d l Z d d l Z d d d g Z d e f d     YZ d f  d     YZ d   Z	 d f  d	     YZ
 d
   Z d   Z d e f d     YZ d   Z d   Z d   Z d S(   s   Debugger basicsiNt   BdbQuitt   Bdbt
   Breakpointc           B   s   e  Z d  Z RS(   s   Exception to give up completely(   t   __name__t
   __module__t   __doc__(    (    (    s   /usr/lib/python2.7/bdb.pyR    
   s   c           B   s  e  Z d  Z d, d  Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d   Z d	   Z d
   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d d  Z d   Z d   Z d   Z d   Z d, d  Z d   Z d   Z d d, d, d  Z d   Z d   Z d   Z  d   Z! d    Z" d!   Z# d"   Z$ d#   Z% d$   Z& d%   Z' d& d'  Z( d, d, d(  Z) d, d, d)  Z* d*   Z+ d+   Z, RS(-   s   Generic Python debugger base class.

    This class takes care of details of the trace facility;
    a derived class should implement user interaction.
    The standard debugger class (pdb.Pdb) is an example.
    c         C   s:   | r t  |  n d  |  _ i  |  _ i  |  _ d  |  _ d  S(   N(   t   sett   Nonet   skipt   breakst   fncachet   frame_returning(   t   selfR   (    (    s   /usr/lib/python2.7/bdb.pyt   __init__   s    		c         C   so   | d | d d !d k r | S|  j  j |  } | sk t j j |  } t j j |  } | |  j  | <n  | S(   Nt   <i   it   >(   R
   t   gett   ost   patht   abspatht   normcase(   R   t   filenamet   canonic(    (    s   /usr/lib/python2.7/bdb.pyR      s    c         C   s3   d d  l  } | j   d  |  _ |  j d  d   d  S(   Ni(   t	   linecachet
   checkcacheR   t   botframet   _set_stopinfo(   R   R   (    (    s   /usr/lib/python2.7/bdb.pyt   reset'   s    
	c         C   s   |  j  r d  S| d k r& |  j |  S| d k rB |  j | |  S| d k r^ |  j | |  S| d k rz |  j | |  S| d k r |  j S| d k r |  j S| d k r |  j Sd Gt |  GH|  j S(	   Nt   linet   callt   returnt	   exceptiont   c_callt   c_exceptiont   c_returns*   bdb.Bdb.dispatch: unknown debugging event:(   t   quittingt   dispatch_linet   dispatch_callt   dispatch_returnt   dispatch_exceptiont   trace_dispatcht   repr(   R   t   framet   eventt   arg(    (    s   /usr/lib/python2.7/bdb.pyR(   -   s$    	c         C   sG   |  j  |  s |  j |  r@ |  j |  |  j r@ t  q@ n  |  j S(   N(   t	   stop_heret
   break_heret	   user_lineR#   R    R(   (   R   R*   (    (    s   /usr/lib/python2.7/bdb.pyR$   A   s
    	 c         C   sm   |  j  d  k r" | j |  _  |  j S|  j |  p= |  j |  sD d  S|  j | |  |  j rf t  n  |  j S(   N(	   R   R   t   f_backR(   R-   t   break_anywheret	   user_callR#   R    (   R   R*   R,   (    (    s   /usr/lib/python2.7/bdb.pyR%   G   s    	 	c         C   sd   |  j  |  s | |  j k r] z | |  _ |  j | |  Wd  d  |  _ X|  j r] t  q] n  |  j S(   N(   R-   t   returnframeR   t   user_returnR   R#   R    R(   (   R   R*   R,   (    (    s   /usr/lib/python2.7/bdb.pyR&   T   s    	
	 c         C   s;   |  j  |  r4 |  j | |  |  j r4 t  q4 n  |  j S(   N(   R-   t   user_exceptionR#   R    R(   (   R   R*   R,   (    (    s   /usr/lib/python2.7/bdb.pyR'   ^   s
    	 c         C   s.   x' |  j  D] } t j | |  r
 t Sq
 Wt S(   N(   R   t   fnmatcht   Truet   False(   R   t   module_namet   pattern(    (    s   /usr/lib/python2.7/bdb.pyt   is_skipped_moduleh   s    c         C   s   |  j  r( |  j | j j d   r( t S| |  j k rZ |  j d k rJ t S| j |  j k Sx; | d  k	 r | |  j k	 r | |  j	 k r t
 S| j } q] Wt S(   NR   i(   R   R;   t	   f_globalsR   R8   t	   stopframet
   stoplinenot   f_linenoR   R   R7   R0   (   R   R*   (    (    s   /usr/lib/python2.7/bdb.pyR-   n   s    	c         C   s   |  j  | j j  } | |  j k r( t S| j } | |  j | k rj | j j } | |  j | k rj t Sn  t | | |  \ } } | r | j |  _	 | r | j
 r |  j t | j   n  t St Sd  S(   N(   R   t   f_codet   co_filenameR	   R8   R?   t   co_firstlinenot	   effectivet   numbert	   currentbpt	   temporaryt   do_cleart   strR7   (   R   R*   R   t   linenot   bpt   flag(    (    s   /usr/lib/python2.7/bdb.pyR.   ~   s    	c         C   s   t  d  d  S(   Ns)   subclass of bdb must implement do_clear()(   t   NotImplementedError(   R   R,   (    (    s   /usr/lib/python2.7/bdb.pyRG      s    c         C   s   |  j  | j j  |  j k S(   N(   R   R@   RA   R	   (   R   R*   (    (    s   /usr/lib/python2.7/bdb.pyR1      s    c         C   s   d S(   sn   This method is called when there is the remote possibility
        that we ever need to stop in this function.N(    (   R   R*   t   argument_list(    (    s   /usr/lib/python2.7/bdb.pyR2      s    c         C   s   d S(   s9   This method is called when we stop or break at this line.N(    (   R   R*   (    (    s   /usr/lib/python2.7/bdb.pyR/      s    c         C   s   d S(   s5   This method is called when a return trap is set here.N(    (   R   R*   t   return_value(    (    s   /usr/lib/python2.7/bdb.pyR4      s    c         C   s   | \ } } } d  S(   N(    (   R   R*   t   exc_infot   exc_typet	   exc_valuet   exc_traceback(    (    s   /usr/lib/python2.7/bdb.pyR5      s    i    c         C   s(   | |  _  | |  _ d |  _ | |  _ d  S(   Ni    (   R=   R3   R#   R>   (   R   R=   R3   R>   (    (    s   /usr/lib/python2.7/bdb.pyR      s    			c         C   s   |  j  | | | j d  d S(   sx   Stop when the line with the line no greater than the current one is
        reached or when returning from current framei   N(   R   R?   (   R   R*   (    (    s   /usr/lib/python2.7/bdb.pyt	   set_until   s    c         C   sK   |  j  r7 |  j  j } | r7 | j r7 |  j | _ q7 n  |  j d d  d S(   s   Stop after one line of code.N(   R   R0   t   f_traceR(   R   R   (   R   t   caller_frame(    (    s   /usr/lib/python2.7/bdb.pyt   set_step   s
    	c         C   s   |  j  | d  d S(   s2   Stop on the next line in or below the given frame.N(   R   R   (   R   R*   (    (    s   /usr/lib/python2.7/bdb.pyt   set_next   s    c         C   s   |  j  | j |  d S(   s)   Stop when returning from the given frame.N(   R   R0   (   R   R*   (    (    s   /usr/lib/python2.7/bdb.pyt
   set_return   s    c         C   sq   | d k r t j   j } n  |  j   x( | rR |  j | _ | |  _ | j } q+ W|  j   t j	 |  j  d S(   sp   Start debugging from `frame`.

        If frame is not specified, debugging starts from caller's frame.
        N(
   R   t   syst	   _getframeR0   R   R(   RT   R   RV   t   settrace(   R   R*   (    (    s   /usr/lib/python2.7/bdb.pyt	   set_trace   s    
		
c         C   sm   |  j  |  j d  d  |  j si t j d   t j   j } x+ | re | |  j k	 re | ` | j } q> Wn  d  S(   Ni(	   R   R   R   R	   RY   R[   RZ   R0   RT   (   R   R*   (    (    s   /usr/lib/python2.7/bdb.pyt   set_continue   s    	c         C   s/   |  j  |  _ d  |  _ d |  _ t j d   d  S(   Ni   (   R   R=   R   R3   R#   RY   R[   (   R   (    (    s   /usr/lib/python2.7/bdb.pyt   set_quit   s    		c   
      C   s   |  j  |  } d d  l } | j | |  } | sA d | | f S| |  j k r` g  |  j | <n  |  j | } | | k r | j |  n  t | | | | |  }	 d  S(   Nis   Line %s:%d does not exist(   R   R   t   getlineR	   t   appendR   (
   R   R   RI   RF   t   condt   funcnameR   R   t   listRJ   (    (    s   /usr/lib/python2.7/bdb.pyt	   set_break   s    c         C   sJ   | | f t  j k r, |  j | j |  n  |  j | sF |  j | =n  d  S(   N(   R   t   bplistR	   t   remove(   R   R   RI   (    (    s   /usr/lib/python2.7/bdb.pyt   _prune_breaks
  s    c         C   s   |  j  |  } | |  j k r& d | S| |  j | k rG d | | f Sx& t j | | f D] } | j   q\ W|  j | |  d  S(   Ns   There are no breakpoints in %ss   There is no breakpoint at %s:%d(   R   R	   R   Re   t   deleteMeRg   (   R   R   RI   RJ   (    (    s   /usr/lib/python2.7/bdb.pyt   clear_break  s    c         C   s{   y t  |  } Wn d | SXy t j | } Wn t k
 rH d | SX| sW d | S| j   |  j | j | j  d  S(   Ns"   Non-numeric breakpoint number (%s)s#   Breakpoint number (%d) out of ranges   Breakpoint (%d) already deleted(   t   intR   t
   bpbynumbert
   IndexErrorRh   Rg   t   fileR   (   R   R,   RD   RJ   (    (    s   /usr/lib/python2.7/bdb.pyt   clear_bpbynumber  s    		
c         C   sz   |  j  |  } | |  j k r& d | SxC |  j | D]4 } t j | | f } x | D] } | j   qT Wq4 W|  j | =d  S(   Ns   There are no breakpoints in %s(   R   R	   R   Re   Rh   (   R   R   R   t   blistRJ   (    (    s   /usr/lib/python2.7/bdb.pyt   clear_all_file_breaks+  s    c         C   sA   |  j  s d Sx$ t j D] } | r | j   q q Wi  |  _  d  S(   Ns   There are no breakpoints(   R	   R   Rk   Rh   (   R   RJ   (    (    s   /usr/lib/python2.7/bdb.pyt   clear_all_breaks5  s    	c         C   s/   |  j  |  } | |  j k o. | |  j | k S(   N(   R   R	   (   R   R   RI   (    (    s   /usr/lib/python2.7/bdb.pyt	   get_break=  s    c         C   sH   |  j  |  } | |  j k rD | |  j | k rD t j | | f pG g  S(   N(   R   R	   R   Re   (   R   R   RI   (    (    s   /usr/lib/python2.7/bdb.pyt
   get_breaksB  s    c         C   s1   |  j  |  } | |  j k r) |  j | Sg  Sd  S(   N(   R   R	   (   R   R   (    (    s   /usr/lib/python2.7/bdb.pyt   get_file_breaksH  s    c         C   s   |  j  S(   N(   R	   (   R   (    (    s   /usr/lib/python2.7/bdb.pyt   get_all_breaksO  s    c         C   s   g  } | r' | j  | k r' | j } n  xB | d  k	 rk | j | | j f  | |  j k r_ Pn  | j } q* W| j   t d t	 |  d  } x2 | d  k	 r | j | j  | j
 f  | j } q W| d  k r t d t	 |  d  } n  | | f S(   Ni    i   (   t   tb_framet   tb_nextR   R`   R?   R   R0   t   reverset   maxt   lent	   tb_lineno(   R   t   ft   tt   stackt   i(    (    s   /usr/lib/python2.7/bdb.pyt	   get_stackU  s     
s   : c         C   s2  d d  l  } d d  l } | \ } } |  j | j j  } d | | f } | j j rh | | j j } n
 | d } d | j k r | j d }	 n d  }	 |	 r | | j |	  } n
 | d } d | j k r | j d }
 | d } | | j |
  } n  | j | | | j	  } | r.| | | j
   } n  | S(   Nis   %s(%r)s   <lambda>t   __args__s   ()t
   __return__s   ->(   R   R)   R   R@   RA   t   co_namet   f_localsR   R_   R<   t   strip(   R   t   frame_linenot   lprefixR   R)   R*   RI   R   t   st   argst   rvR   (    (    s   /usr/lib/python2.7/bdb.pyt   format_stack_entryi  s*    


 c         B   s   | d  k r$ d d  l } | j } n  | d  k r9 | } n  |  j   e j |  j  e | e j	  sr | d } n  z& y | | | UWn e
 k
 r n XWd  d |  _ e j d   Xd  S(   Nis   
i   (   R   t   __main__t   __dict__R   RY   R[   R(   t
   isinstancet   typest   CodeTypeR    R#   (   R   t   cmdt   globalst   localsR   (    (    s   /usr/lib/python2.7/bdb.pyt   run  s     	
 	c         C   s   | d  k r$ d d  l } | j } n  | d  k r9 | } n  |  j   t j |  j  t | t j	  sr | d } n  z, y t
 | | |  SWn t k
 r n XWd  d |  _ t j d   Xd  S(   Nis   
i   (   R   R   R   R   RY   R[   R(   R   R   R   t   evalR    R#   (   R   t   exprR   R   R   (    (    s   /usr/lib/python2.7/bdb.pyt   runeval  s     	
 	c         C   s   |  j  | | |  d  S(   N(   R   (   R   R   R   R   (    (    s   /usr/lib/python2.7/bdb.pyt   runctx  s    c         O   si   |  j    t j |  j  d  } z+ y | | |   } Wn t k
 rI n XWd  d |  _ t j d   X| S(   Ni   (   R   RY   R[   R(   R   R    R#   (   R   t   funcR   t   kwdst   res(    (    s   /usr/lib/python2.7/bdb.pyt   runcall  s    
 	N(-   R   R   R   R   R   R   R   R(   R$   R%   R&   R'   R;   R-   R.   RG   R1   R2   R/   R4   R5   R   RS   RV   RW   RX   R\   R]   R^   Rd   Rg   Ri   Rn   Rp   Rq   Rr   Rs   Rt   Ru   R   R   R   R   R   R   (    (    (    s   /usr/lib/python2.7/bdb.pyR      sV   	
					
	
																			
							c           C   s   t    j   d  S(   N(   R   R\   (    (    (    s   /usr/lib/python2.7/bdb.pyR\     s    c           B   s\   e  Z d  Z d Z i  Z d g Z d d d d  Z d   Z d   Z	 d   Z
 d d  Z RS(	   s  Breakpoint class

    Implements temporary breakpoints, ignore counts, disabling and
    (re)-enabling, and conditionals.

    Breakpoints are indexed by number through bpbynumber and by
    the file,line tuple using bplist.  The former points to a
    single instance of class Breakpoint.  The latter points to a
    list of such instances since there may be more than one
    breakpoint per line.

    i   i    c         C   s   | |  _  d  |  _ | |  _ | |  _ | |  _ | |  _ d |  _ d |  _ d |  _	 t
 j |  _ t
 j d t
 _ |  j j |   | | f |  j k r |  j | | f j |   n |  g |  j | | f <d  S(   Ni   i    (   Rb   R   t   func_first_executable_lineRm   R   RF   Ra   t   enabledt   ignoret   hitsR   t   nextRD   Rk   R`   Re   (   R   Rm   R   RF   Ra   Rb   (    (    s   /usr/lib/python2.7/bdb.pyR     s    									c         C   sT   |  j  |  j f } d  |  j |  j <|  j | j |   |  j | sP |  j | =n  d  S(   N(   Rm   R   R   Rk   RD   Re   Rf   (   R   t   index(    (    s   /usr/lib/python2.7/bdb.pyRh     s
    c         C   s   d |  _  d  S(   Ni   (   R   (   R   (    (    s   /usr/lib/python2.7/bdb.pyt   enable  s    c         C   s   d |  _  d  S(   Ni    (   R   (   R   (    (    s   /usr/lib/python2.7/bdb.pyt   disable  s    c         C   s   | d  k r t j } n  |  j r* d } n d } |  j rF | d } n
 | d } | d |  j | |  j |  j f IJ|  j r | d |  j f IJn  |  j	 r | d |  j	 IJn  |  j
 r |  j
 d k r d	 } n d
 } | d |  j
 | f IJn  d  S(   Ns   del  s   keep s   yes  s   no   s   %-4dbreakpoint   %s at %s:%ds   	stop only if %ss   	ignore next %d hitsi   R   t    s!   	breakpoint already hit %d time%s(   R   RY   t   stdoutRF   R   RD   Rm   R   Ra   R   R   (   R   t   outt   dispt   ss(    (    s   /usr/lib/python2.7/bdb.pyt   bpprint  s(    			
			 	N(   R   R   R   R   Re   R   Rk   R   Rh   R   R   R   (    (    (    s   /usr/lib/python2.7/bdb.pyR     s   				c         C   sn   |  j  s# |  j | j k r t St S| j j |  j  k r< t S|  j sT | j |  _ n  |  j | j k rj t St S(   s;   Check whether we should break here because of `b.funcname`.(   Rb   R   R?   R8   R7   R@   R   R   (   t   bR*   (    (    s   /usr/lib/python2.7/bdb.pyt   checkfuncname  s    		c         C   s  t  j |  | f } xt d t |   D] } | | } | j d k rN q) n  t | |  sc q) n  | j d | _ | j s | j d k r | j d | _ q) q| d f Sq) yT t	 | j | j
 | j  } | r| j d k r | j d | _ q| d f Sn  Wq) | d f SXq) Wd S(   s   Determine which breakpoint for this file:line is to be acted upon.

    Called only if we know there is a bpt at this
    location.  Returns breakpoint that was triggered and a flag
    that indicates if it is ok to delete a temporary bp.

    i    i   N(   NN(   R   Re   t   rangeRz   R   R   R   Ra   R   R   R<   R   R   (   Rm   R   R*   t	   possiblesR   R   t   val(    (    s   /usr/lib/python2.7/bdb.pyRC   1  s.    
	t   Tdbc           B   s,   e  Z d    Z d   Z d   Z d   Z RS(   c         C   s,   | j  j } | s d } n  d G| G| GHd  S(   Ns   ???s   +++ call(   R@   R   (   R   R*   R   t   name(    (    s   /usr/lib/python2.7/bdb.pyR2   g  s     	c         C   s}   d d  l  } | j j } | s' d } n  |  j | j j  } | j | | j | j  } d G| G| j G| Gd G| j   GHd  S(   Nis   ???s   +++t   :(	   R   R@   R   R   RA   R_   R?   R<   R   (   R   R*   R   R   t   fnR   (    (    s   /usr/lib/python2.7/bdb.pyR/   k  s     	c         C   s   d G| GHd  S(   Ns
   +++ return(    (   R   R*   t   retval(    (    s   /usr/lib/python2.7/bdb.pyR4   r  s    c         C   s   d G| GH|  j    d  S(   Ns   +++ exception(   R]   (   R   R*   t	   exc_stuff(    (    s   /usr/lib/python2.7/bdb.pyR5   t  s    	(   R   R   R2   R/   R4   R5   (    (    (    s   /usr/lib/python2.7/bdb.pyR   f  s   			c         C   s*   d G|  Gd GHt  |  d  } d G| GHd  S(   Ns   foo(t   )i
   s   bar returned(   t   bar(   t   nt   x(    (    s   /usr/lib/python2.7/bdb.pyt   foox  s    c         C   s   d G|  Gd GH|  d S(   Ns   bar(R   i   (    (   t   a(    (    s   /usr/lib/python2.7/bdb.pyR   }  s    c          C   s   t    }  |  j d  d  S(   Ns   import bdb; bdb.foo(10)(   R   R   (   R}   (    (    s   /usr/lib/python2.7/bdb.pyt   test  s    	(   R   R6   RY   R   R   t   __all__t	   ExceptionR    R   R\   R   R   RC   R   R   R   R   (    (    (    s   /usr/lib/python2.7/bdb.pyt   <module>   s     	T		5		