
5	Pc           @   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   s1   | r t  |  n d  |  _ i  |  _ i  |  _ d  S(   N(   t   sett   Nonet   skipt   breakst   fncache(   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#   @   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$   F   s    	 	c         C   sJ   |  j  |  s | |  j k rC |  j | |  |  j rC t  qC n  |  j S(   N(   R,   t   returnframet   user_returnR"   R    R'   (   R   R)   R+   (    (    s   /usr/lib/python2.7/bdb.pyR%   S   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&   Y   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_modulec   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   R7   t	   stopframet
   stoplinenot   f_linenoR   R   R6   R/   (   R   R)   (    (    s   /usr/lib/python2.7/bdb.pyR,   i   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	   R7   R>   t   co_firstlinenot	   effectivet   numbert	   currentbpt	   temporaryt   do_cleart   strR6   (   R   R)   R   t   linenot   bpt   flag(    (    s   /usr/lib/python2.7/bdb.pyR-   y   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.pyRF      s    c         C   s   |  j  | j j  |  j k S(   N(   R   R?   R@   R	   (   R   R)   (    (    s   /usr/lib/python2.7/bdb.pyR0      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.pyR1      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.pyR3      s    c         C   s   | \ } } } d  S(   N(    (   R   R)   t   exc_infot   exc_typet	   exc_valuet   exc_traceback(    (    s   /usr/lib/python2.7/bdb.pyR4      s    i    c         C   s(   | |  _  | |  _ d |  _ | |  _ d  S(   Ni    (   R<   R2   R"   R=   (   R   R<   R2   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   s   |  j  d d  d S(   s   Stop after one line of code.N(   R   R   (   R   (    (    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   R/   (   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	   _getframeR/   R   R'   t   f_traceR   RS   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	   RV   RY   RW   R/   RX   (   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   R2   R"   RV   RY   (   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   RH   RE   t   condt   funcnameR   R   t   listRI   (    (    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   RH   (    (    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   Rc   t   deleteMeRe   (   R   R   RH   RI   (    (    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
   IndexErrorRf   Re   t   fileR   (   R   R+   RC   RI   (    (    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   Rc   Rf   (   R   R   R   t   blistRI   (    (    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   Ri   Rf   (   R   RI   (    (    s   /usr/lib/python2.7/bdb.pyt   clear_all_breaks(  s    	c         C   s/   |  j  |  } | |  j k o. | |  j | k S(   N(   R   R	   (   R   R   RH   (    (    s   /usr/lib/python2.7/bdb.pyt	   get_break0  s    c         C   sH   |  j  |  } | |  j k rD | |  j | k rD t j | | f pG g  S(   N(   R   R	   R   Rc   (   R   R   RH   (    (    s   /usr/lib/python2.7/bdb.pyt
   get_breaks5  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_breaks;  s    c         C   s   |  j  S(   N(   R	   (   R   (    (    s   /usr/lib/python2.7/bdb.pyt   get_all_breaksB  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   R/   t   reverset   maxt   lent	   tb_lineno(   R   t   ft   tt   stackt   i(    (    s   /usr/lib/python2.7/bdb.pyt	   get_stackH  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?   R@   t   co_namet   f_localsR   R]   R;   t   strip(   R   t   frame_linenot   lprefixR   R(   R)   RH   R   t   st   argst   rvR   (    (    s   /usr/lib/python2.7/bdb.pyt   format_stack_entry\  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   RV   RY   R'   t
   isinstancet   typest   CodeTypeR    R"   (   R   t   cmdt   globalst   localsR   (    (    s   /usr/lib/python2.7/bdb.pyt   runx  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   RV   RY   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   RV   RY   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-   RF   R0   R1   R.   R3   R4   R   RR   RS   RT   RU   RZ   R[   R\   Rb   Re   Rg   Rl   Rn   Ro   Rp   Rq   Rr   Rs   R~   R   R   R   R   R   (    (    (    s   /usr/lib/python2.7/bdb.pyR      sV   	
						
																			
							c           C   s   t    j   d  S(   N(   R   RZ   (    (    (    s   /usr/lib/python2.7/bdb.pyRZ     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    (   R`   R   t   func_first_executable_lineRk   R   RE   R_   t   enabledt   ignoret   hitsR   t   nextRC   Ri   R^   Rc   (   R   Rk   R   RE   R_   R`   (    (    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(   Rk   R   R   Ri   RC   Rc   Rd   (   R   t   index(    (    s   /usr/lib/python2.7/bdb.pyRf     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   RV   t   stdoutRE   R   RC   Rk   R   R_   R   R   (   R   t   outt   dispt   ss(    (    s   /usr/lib/python2.7/bdb.pyt   bpprint  s(    			
			 	N(   R   R   R   R   Rc   R   Ri   R   Rf   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`.(   R`   R   R>   R7   R6   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   Rc   t   rangeRx   R   R   R   R_   R   R   R;   R   R   (   Rk   R   R)   t	   possiblesR}   R   t   val(    (    s   /usr/lib/python2.7/bdb.pyRB   $  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.pyR1   Z  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   R@   R]   R>   R;   R   (   R   R)   R   R   t   fnR   (    (    s   /usr/lib/python2.7/bdb.pyR.   ^  s     	c         C   s   d G| GHd  S(   Ns
   +++ return(    (   R   R)   t   retval(    (    s   /usr/lib/python2.7/bdb.pyR3   e  s    c         C   s   d G| GH|  j    d  S(   Ns   +++ exception(   R[   (   R   R)   t	   exc_stuff(    (    s   /usr/lib/python2.7/bdb.pyR4   g  s    	(   R   R   R1   R.   R3   R4   (    (    (    s   /usr/lib/python2.7/bdb.pyR   Y  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   fook  s    c         C   s   d G|  Gd GH|  d S(   Ns   bar(R   i   (    (   t   a(    (    s   /usr/lib/python2.7/bdb.pyR   p  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   testt  s    	(   R   R5   RV   R   R   t   __all__t	   ExceptionR    R   RZ   R   R   RB   R   R   R   R   (    (    (    s   /usr/lib/python2.7/bdb.pyt   <module>   s     	T		5		