
V]c           @  s  d  Z  d d l m Z d d l Z d d l Z d d l Z d d l Z e j d d k rn e Z	 e
 Z e Z n  d   Z d   Z d   Z d	   Z d
   Z d a d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z e j    Z! d Z" d e# f d     YZ$ d   Z% d   Z& e j d d k r<d   Z' n	 d   Z' y e j( Z) Wn e* k
 rnd   Z) n Xd e# f d      YZ+ d! e, f d"     YZ- d# e, f d$     YZ. d% e. f d&     YZ/ d' e, f d(     YZ0 d)   Z1 d* e, f d+     YZ2 d,   Z3 d e3 _4 d- e. f d.     YZ5 d/ e6 f d0     YZ7 d1 e. f d2     YZ8 d3 e. f d4     YZ9 d5 e, f d6     YZ: d7 e, f d8     YZ; d9 e. f d:     YZ< d; e. f d<     YZ= d= e. f d>     YZ> d? e. f d@     YZ? dA e. f dB     YZ@ dC e@ f dD     YZA dE e. f dF     YZB dG e. f dH     YZC dI e. f dJ     YZD dK e. f dL     YZE dM eE f dN     YZF dO e. f dP     YZG dQ e. f dR     YZH dS   ZI e jJ dT k re	 ZK n	 dU   ZK dV e. f dW     YZL dX e. f dY     YZM dZ   ZN d[   ZO d\ d d]     YZP d^   ZQ d_   ZR eR e jS    d` e, f da     YZT db e jU f dc     YZV eV   dd   ZW de e jU f df     YZX dg e jU f dh     YZY eZ e jT di  reX   eY   n  dj e jU f dk     YZ[ e[   dl e jU f dm     YZ\ e\   dn e jU f do     YZ] e]   dp e jU f dq     YZ^ e^   d d l_ Z_ d d l` Z` d d la Za d d lb Zb d d lc Zc dr e^ f ds     YZd ed dt  du e je f dv     YZf ef dw  dx ef f dy     YZg eg dz  d{ e jU f d|     YZh eh d} e ji e jj  d~ e, f d     YZk el el d  Zm e jm Zn em e _m ek   Zo d   Zp el d  Zq d   Zr d   Zs d e jU f d     YZt d e, f d     YZu d eu f d     YZv d e, f d     YZw d et ew f d     YZx d ex f d     YZy d et f d     YZz d et f d     YZ{ d et f d     YZ| d   Z} d   Z~ d   Z d e, f d     YZ d e f d     YZ d e jU f d     YZ d   Z d e jU f d     YZ e jm d  eZ e d  rex d ev    Z ey d ev    Z er   ez d ev    Z e{ d ev    Z e| d ev    Z e d d  Z e d e j e jj  Z n e` j d  d S(   s-  
From gdb 7 onwards, gdb's build can be configured --with-python, allowing gdb
to be extended with Python code e.g. for library-specific data visualizations,
such as for the C++ STL types.  Documentation on this API can be seen at:
http://sourceware.org/gdb/current/onlinedocs/gdb/Python-API.html


This python module deals with the case when the process being debugged (the
"inferior process" in gdb parlance) is itself python, or more specifically,
linked against libpython.  In this situation, almost every item of data is a
(PyObject*), and having the debugger merely print their addresses is not very
enlightening.

This module embeds knowledge about the implementation details of libpython so
that we can emit useful visualizations e.g. a string, a list, a dict, a frame
giving file/line information and the state of local variables

In particular, given a gdb.Value corresponding to a PyObject* in the inferior
process, we can generate a "proxy value" within the gdb process.  For example,
given a PyObject* in the inferior process that is in fact a PyListObject*
holding three PyObject* that turn out to be PyBytesObject* instances, we can
generate a proxy value within the gdb process that is a list of bytes
instances:
  [b"foo", b"bar", b"baz"]

Doing so can be expensive for complicated graphs of objects, and could take
some time, so we also have a "write_repr" method that writes a representation
of the data to a file-like object.  This allows us to stop the traversal by
having the file-like object raise an exception if it gets too much data.

With both "proxyval" and "write_repr" we keep track of the set of all addresses
visited so far in the traversal, to avoid infinite recursion due to cycles in
the graph of object references.

We try to defer gdb.lookup_type() invocations for python types until as late as
possible: for a dynamically linked python binary, when the process starts in
the debugger, the libpython.so hasn't been dynamically loaded yet, so none of
the type names are known to the debugger

The module also extends gdb with some python-specific commands.
i(   t   print_functionNi    i   c           C  s   t  j d  j   S(   Nt   char(   t   gdbt   lookup_typet   pointer(    (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt   _type_char_ptrD   s    c           C  s   t  j d  j   S(   Ns   unsigned char(   R   R   R   (    (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt   _type_unsigned_char_ptrH   s    c           C  s   t  j d  j   S(   Ns   unsigned short(   R   R   R   (    (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt   _type_unsigned_short_ptrL   s    c           C  s   t  j d  j   S(   Ns   unsigned int(   R   R   R   (    (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt   _type_unsigned_int_ptrP   s    c           C  s   t  j d  j   j S(   Nt   void(   R   R   R   t   sizeof(    (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt   _sizeof_void_pT   s    i   i	   i   i   i   i   i   i   i   i   i   t   0123456789abcdeft   _PyEval_EvalFrameDefaultt   NullPyObjectPtrc           B  s   e  Z RS(    (   t   __name__t
   __module__(    (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR   n   s   c         C  s   t  |  d  S(   Ni  (   t   min(   t   val(    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt   safety_limitr   s    c         C  s   t  t t |     S(   N(   t   xrangeR   t   int(   R   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt
   safe_rangey   s    c         C  s   |  j  |  d  S(   N(   t   write(   t   filet   text(    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt   write_unicode   s    c         C  s5   t  | t  r$ | j t d  } n  |  j |  d  S(   Nt   backslashreplace(   t
   isinstancet   unicodet   encodet   ENCODINGR   (   R   R   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR      s    c         C  s   t  |  t  s |  St j   } | d k r8 |  j |  Sg  } xe |  D]] } d t |  k oh d k n r t t |  d  } n | j |  } | j |  qE Wd j |  S(   Nt   mbcsi  i  i   t    (	   R   R   t   syst   getfilesystemencodingR   t   ordt   chrt   appendt   join(   t   filenamet   encodingt   encodedR   t   byte(    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt   os_fsencode   s    "t   StringTruncatedc           B  s   e  Z RS(    (   R   R   (    (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR-      s   t   TruncatedStringIOc           B  s,   e  Z d  Z d d  Z d   Z d   Z RS(   s^   Similar to io.StringIO, but can truncate the output by raising a
    StringTruncated exceptionc         C  s   d |  _  | |  _ d  S(   NR!   (   t   _valt   maxlen(   t   selfR0   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt   __init__   s    	c         C  ss   |  j  r` t |  t |  j  |  j  k r` |  j | d |  j  t |  j  !7_ t    q` n  |  j | 7_ d  S(   Ni    (   R0   t   lenR/   R-   (   R1   t   data(    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR      s
    	"&c         C  s   |  j  S(   N(   R/   (   R1   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt   getvalue   s    N(   R   R   t   __doc__t   NoneR2   R   R5   (    (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR.      s   		t   PyObjectPtrc           B  s   e  Z d  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 e d    Z e d    Z e d    Z d   Z RS(   sk  
    Class wrapping a gdb.Value that's either a (PyObject*) within the
    inferior process, or some subclass pointer e.g. (PyBytesObject*)

    There will be a subclass for every refined PyObject type that we care
    about.

    Note that at every stage the underlying pointer could be NULL, point
    to corrupt data, etc; this is the debugger, after all.
    t   PyObjectc         C  s(   | r | j  |  |  _ n	 | |  _ d  S(   N(   t   castt   _gdbval(   R1   t   gdbvalt   cast_to(    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR2      s    c         C  s   |  j    r t |    n  | d k rM |  j j t j    } | j   | S| d k r |  j j t j    } | j   | S|  j j   | S(   s  
        Get the gdb.Value for the given field within the PyObject, coping with
        some python 2 versus python 3 differences.

        Various libpython types are defined using the "PyObject_HEAD" and
        "PyObject_VAR_HEAD" macros.

        In Python 2, this these are defined so that "ob_type" and (for a var
        object) "ob_size" are fields of the type in question.

        In Python 3, this is defined as an embedded PyVarObject type thus:
           PyVarObject ob_base;
        so that the "ob_size" field is located insize the "ob_base" field, and
        the "ob_type" is most easily accessed by casting back to a (PyObject*).
        t   ob_typet   ob_size(   t   is_nullR   R;   R:   R8   t   get_gdb_typet   dereferencet   PyVarObjectPtr(   R1   t   namet   pyo_ptr(    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt   field   s    c         C  s   t  j |  j |   S(   s   
        Get a PyObjectPtr for the given PyObject* field within this PyObject,
        coping with some python 2 versus python 3 differences.
        (   R8   t   from_pyobject_ptrRF   (   R1   RD   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt
   pyop_field   s    c         C  s#   |  j  |  } | j | |  d S(   sz   
        Extract the PyObject* field named "name", and write its representation
        to file-like object "out"
        N(   RH   t
   write_repr(   R1   RD   t   outt   visitedt	   field_obj(    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt   write_field_repr   s    c         C  sL   t  |  } y |  j | t    Wn t k
 rA | j   d SX| j   S(   s   
        Get a repr-like string for the data, but truncate it at "maxlen" bytes
        (ending the object graph traversal as soon as you do)
        s   ...(truncated)(   R.   RI   t   setR-   R5   (   R1   R0   RJ   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt   get_truncated_repr   s    c         C  s   t  |  j d   S(   NR>   (   t   PyTypeObjectPtrRF   (   R1   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt   type  s    c         C  s   d t  |  j  k S(   Ni    (   t   longR;   (   R1   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR@     s    c         C  s
   |  j  j S(   s<  
        Is the value of the underlying PyObject* visible to the debugger?

        This can vary with the precise version of the compiler used to build
        Python, and the precise version of gdb.

        See e.g. https://bugzilla.redhat.com/show_bug.cgi?id=556975 with
        PyEval_EvalFrameEx's "f"
        (   R;   t   is_optimized_out(   R1   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyRS   	  s    
c         C  sG   y |  j    j d  j   SWn# t k
 r1 d St k
 rB d SXd  S(   Nt   tp_namet   unknown(   RQ   RF   t   stringR   t   RuntimeError(   R1   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt   safe_tp_name  s    c         C  s2   d t  f d     Y} | |  j   t |  j   S(   si  
        Scrape a value from the inferior process, and try to represent it
        within the gdb process, whilst (hopefully) avoiding crashes when
        the remote data is corrupt.

        Derived classes will override this.

        For example, a PyIntObject* with ob_ival 42 in the inferior process
        should result in an int(42) in this process.

        visited: a set of all gdb.Value pyobject pointers already visited
        whilst generating this value (to guard against infinite recursion when
        visiting object graphs with loops).  Analogous to Py_ReprEnter and
        Py_ReprLeave
        t   FakeReprc           B  s    e  Z d  Z d   Z d   Z RS(   s   
            Class representing a non-descript PyObject* value in the inferior
            process for when we don't have a custom scraper, intended to have
            a sane repr().
            c         S  s   | |  _  | |  _ d  S(   N(   RT   t   address(   R1   RT   RZ   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR2   7  s    	c         S  s'   |  j  d k r d Sd |  j |  j  f S(   Ni    t   0x0s   <%s at remote 0x%x>(   RZ   RT   (   R1   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt   __repr__;  s    (   R   R   R6   R2   R\   (    (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyRY   0  s   	(   t   objectRX   RR   R;   (   R1   RK   RY   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt   proxyval  s    c         C  s   | j  t |  j |    S(   s   
        Write a string representation of the value scraped from the inferior
        process to "out", a file-like object.
        (   R   t   reprR^   (   R1   RJ   RK   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyRI   F  s    c         C  s	  y. | j  d  j   } t | j  d   } Wn t k
 rB |  SXi t d 6t d 6t d 6t d 6t d 6t d 6t	 d	 6t
 d
 6} | | k r | | S| t @r t S| t @r t S| t @r t S| t @r t S| t @r t S| t @r t S| t @r t S| t @rt S|  S(   s  
        Given a PyTypeObjectPtr instance wrapping a gdb.Value that's a
        (PyTypeObject*), determine the corresponding subclass of PyObjectPtr
        to use

        Ideally, we would look up the symbols for the global types, but that
        isn't working yet:
          (gdb) python print gdb.lookup_symbol('PyList_Type')[0].value
          Traceback (most recent call last):
            File "<string>", line 1, in <module>
          NotImplementedError: Symbol type not yet supported in Python scripts.
          Error while executing Python code.

        For now, we use tp_flags, after doing some string comparisons on the
        tp_name for some special-cases that don't seem to be visible through
        flags
        RT   t   tp_flagst   boolt   classobjt   NoneTypet   frameRN   t	   frozensett   builtin_function_or_methods   method-wrapper(   RF   RV   R   RW   t   PyBoolObjectPtrt   PyClassObjectPtrt   PyNoneStructPtrt   PyFrameObjectPtrt   PySetObjectPtrt   PyCFunctionObjectPtrt   wrapperobjectt   Py_TPFLAGS_HEAPTYPEt   HeapTypeObjectPtrt   Py_TPFLAGS_LONG_SUBCLASSt   PyLongObjectPtrt   Py_TPFLAGS_LIST_SUBCLASSt   PyListObjectPtrt   Py_TPFLAGS_TUPLE_SUBCLASSt   PyTupleObjectPtrt   Py_TPFLAGS_BYTES_SUBCLASSt   PyBytesObjectPtrt   Py_TPFLAGS_UNICODE_SUBCLASSt   PyUnicodeObjectPtrt   Py_TPFLAGS_DICT_SUBCLASSt   PyDictObjectPtrt   Py_TPFLAGS_BASE_EXC_SUBCLASSt   PyBaseExceptionObjectPtr(   t   clst   tRT   R`   t   name_map(    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt   subclass_from_typeP  s@    









c         C  sY   y; t  |  } |  j | j    }  |  | d |  j   SWn t k
 rN n X|  |  S(   st   
        Try to locate the appropriate derived class dynamically, and cast
        the pointer accordingly.
        R=   (   R8   R   RQ   RA   RW   (   R~   R<   t   p(    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyRG     s    c         C  s   t  j |  j  j   S(   N(   R   R   t	   _typenameR   (   R~   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyRA     s    c         C  s   t  |  j  S(   N(   RR   R;   (   R1   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt
   as_address  s    N(   R   R   R6   R   R7   R2   RF   RH   RM   RO   RQ   R@   RS   RX   R^   RI   t   classmethodR   RG   RA   R   (    (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR8      s"   
								
	'	
ARC   c           B  s   e  Z d  Z RS(   t   PyVarObject(   R   R   R   (    (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyRC     s   t   ProxyAlreadyVisitedc           B  s    e  Z d  Z d   Z d   Z RS(   s   
    Placeholder proxy to use when protecting against infinite recursion due to
    loops in the object graph.

    Analogous to the values emitted by the users of Py_ReprEnter and Py_ReprLeave
    c         C  s   | |  _  d  S(   N(   t   _rep(   R1   t   rep(    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR2     s    c         C  s   |  j  S(   N(   R   (   R1   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR\     s    (   R   R   R6   R2   R\   (    (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR     s   	c         C  s   |  j  d  |  j  |  t | t  r |  j  d  t } xi | j   D][ \ } } | sk |  j  d  n  t } |  j  | j |   |  j  d  | j |  |  qI W|  j  d  n  |  j  d |  d S(   sX   Shared code for use by all classes:
    write a representation to file-like object "out"t   <t   (s   , t   =t   )s    at remote 0x%x>N(   R   R   R{   t   Truet	   iteritemst   FalseR^   RI   (   RJ   RK   RD   t   pyop_attrdictRZ   t   firstt   pyop_argt   pyop_val(    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt   _write_instance_repr  s    t   InstanceProxyc           B  s   e  Z d    Z d   Z RS(   c         C  s   | |  _  | |  _ | |  _ d  S(   N(   t   cl_namet   attrdictRZ   (   R1   R   R   RZ   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR2     s    		c         C  s|   t  |  j t  rd d j g  |  j j   D] \ } } d | | f ^ q(  } d |  j | |  j f Sd |  j |  j f Sd  S(   Ns   , s   %s=%rs   <%s(%s) at remote 0x%x>s   <%s at remote 0x%x>(   R   R   t   dictR'   R   R   RZ   (   R1   t   argR   t   kwargs(    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR\     s    	2		(   R   R   R2   R\   (    (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR     s   	c         C  se   t  j d  k r$ t j d  t  _ n  |  j d  | |  j d  t   d t   d @j t  j  S(   Nt   size_tt   tp_basicsizet   tp_itemsizei   (   t   _PyObject_VAR_SIZEt   _type_size_tR7   R   R   RF   R   R:   (   t   typeobjt   nitems(    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR     s    Ro   c           B  s)   e  Z d  Z d   Z d   Z d   Z RS(   R9   c         C  s0  y|  j    } t | j d   } | d k r| d k  r t j d  j   } t |  j j |  d  } | d k  r | } n  t | |  } | | 7} | d k s t	  | t
   d k s t	  n  |  j j t    | } t j   j   } | j |  } t j | j    SWn t k
 r+n Xd S(   sw   
        Get the PyDictObject ptr representing the attribute dictionary
        (or None if there's a problem)
        t   tp_dictoffseti    R   R?   N(   RQ   t   int_from_intRF   R   R   R   R;   R:   R   t   AssertionErrorR   R   R8   RA   RG   RB   RW   R7   (   R1   R   t
   dictoffsett   type_PyVarObject_ptrt   tsizet   sizet   dictptrt   PyObjectPtrPtr(    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt   get_attr_dict  s(    

c         C  s~   |  j    | k r t d  S| j |  j     |  j   } | rS | j |  } n i  } |  j   } t | | t |  j   S(   s   
        Support for classes.

        Currently we just locate the dictionary using a transliteration to
        python of _PyObject_GetDictPtr, ignoring descriptors
        s   <...>(	   R   R   t   addR   R^   RX   R   RR   R;   (   R1   RK   t   pyop_attr_dictt	   attr_dictRT   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR^     s    
c         C  sh   |  j    | k r# | j d  d  S| j |  j     |  j   } t | | |  j   | |  j     d  S(   Ns   <...>(   R   R   R   R   R   RX   (   R1   RJ   RK   R   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyRI   !  s    	(   R   R   R   R   R^   RI   (    (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyRo     s   		t   ProxyExceptionc           B  s   e  Z d    Z d   Z RS(   c         C  s   | |  _  | |  _ d  S(   N(   RT   t   args(   R1   RT   R   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR2   -  s    	c         C  s   d |  j  |  j f S(   Ns   %s%r(   RT   R   (   R1   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR\   1  s    (   R   R   R2   R\   (    (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR   ,  s   	R}   c           B  s&   e  Z d  Z d Z d   Z d   Z RS(   s}   
    Class wrapping a gdb.Value that's a PyBaseExceptionObject* i.e. an exception
    within the process being debugged.
    t   PyBaseExceptionObjectc         C  sZ   |  j    | k r t d  S| j |  j     |  j d  j |  } t |  j   |  S(   Ns   (...)R   (   R   R   R   RH   R^   R   RX   (   R1   RK   t	   arg_proxy(    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR^   ;  s    
c         C  s`   |  j    | k r# | j d  d  S| j |  j     | j |  j    |  j d | |  d  S(   Ns   (...)R   (   R   R   R   RX   RM   (   R1   RJ   RK   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyRI   D  s    (   R   R   R6   R   R^   RI   (    (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR}   4  s   		Rh   c           B  s   e  Z d  Z d Z RS(   s~   
    Class wrapping a gdb.Value that's a PyClassObject* i.e. a <classobj>
    instance within the process being debugged.
    t   PyClassObject(   R   R   R6   R   (    (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyRh   N  s   t   BuiltInFunctionProxyc           B  s   e  Z d    Z d   Z RS(   c         C  s   | |  _  d  S(   N(   t   ml_name(   R1   R   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR2   W  s    c         C  s   d |  j  S(   Ns   <built-in function %s>(   R   (   R1   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR\   Z  s    (   R   R   R2   R\   (    (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR   V  s   	t   BuiltInMethodProxyc           B  s   e  Z d    Z d   Z RS(   c         C  s   | |  _  | |  _ d  S(   N(   R   t   pyop_m_self(   R1   R   R   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR2   ^  s    	c         C  s&   d |  j  |  j j   |  j j   f S(   Ns0   <built-in method %s of %s object at remote 0x%x>(   R   R   RX   R   (   R1   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR\   b  s    (   R   R   R2   R\   (    (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR   ]  s   	Rl   c           B  s   e  Z d  Z d Z d   Z RS(   s|   
    Class wrapping a gdb.Value that's a PyCFunctionObject*
    (see Include/methodobject.h and Objects/methodobject.c)
    t   PyCFunctionObjectc         C  sU   |  j  d  } | d j   } |  j d  } | j   rD t |  St | |  Sd  S(   Nt   m_mlR   t   m_self(   RF   RV   RH   R@   R   R   (   R1   RK   R   R   R   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR^   p  s    
(   R   R   R6   R   R^   (    (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyRl   i  s   t   PyCodeObjectPtrc           B  s   e  Z d  Z d Z d   Z RS(   sy   
    Class wrapping a gdb.Value that's a PyCodeObject* i.e. a <code> instance
    within the process being debugged.
    t   PyCodeObjectc         C  s   |  j  d  j t    } t |  j d   } d } xg t | d d d  | d d d   D]< \ } } | t |  7} | | k r | S| t |  7} q` W| S(   s   
        Get the line number for a given bytecode offset

        Analogous to PyCode_Addr2Line; translated from pseudocode in
        Objects/lnotab_notes.txt
        t	   co_lnotabt   co_firstlinenoi    Ni   i   (   RH   R^   RN   R   RF   t   zipR$   (   R1   t   addrqR   t   linenot   addrt	   addr_incrt	   line_incr(    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt	   addr2line  s    6(   R   R   R6   R   R   (    (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR   {  s   R{   c           B  s8   e  Z d  Z d Z d   Z d   Z d   Z d   Z RS(   sw   
    Class wrapping a gdb.Value that's a PyDictObject* i.e. a dict instance
    within the process being debugged.
    t   PyDictObjectc   	      c  s   |  j  d  } |  j  d  } |  j |  \ } } x t |  D]r } | | } t |  rr t j | |  } n t j | d  } | j   s@ t j | d  } | | f Vq@ q@ Wd S(   sx   
        Yields a sequence of (PyObjectPtr key, PyObjectPtr value) pairs,
        analogous to dict.iteritems()
        t   ma_keyst	   ma_valuest   me_valuet   me_keyN(   RF   t   _get_entriesR   RR   R8   RG   R@   (	   R1   t   keyst   valuest   entriest   nentriest   it   ept
   pyop_valuet   pyop_key(    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR     s    
c         C  s~   |  j    | k r t d  S| j |  j     i  } xB |  j   D]4 \ } } | j |  } | j |  } | | | <qB W| S(   Ns   {...}(   R   R   R   R   R^   (   R1   RK   t   resultR   R   t	   proxy_keyt   proxy_value(    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR^     s    
c         C  s   |  j    | k r# | j d  d  S| j |  j     | j d  t } xc |  j   D]U \ } } | sx | j d  n  t } | j | |  | j d  | j | |  qV W| j d  d  S(   Ns   {...}t   {s   , s   : t   }(   R   R   R   R   R   R   RI   (   R1   RJ   RK   R   R   R   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyRI     s    c         C  s   t  | d  } t  | d  } y | d | f SWn t k
 rE n X| d k r[ | } n< | d k rt d | } n# | d k r d | } n
 d	 | } | d
 d j } | j t    | } t j d  j   } | j |  } | | f S(   Nt   dk_nentriest   dk_sizet
   dk_entriesi   i  i   I    i   i   t
   dk_indicest   as_1t   PyDictKeyEntry(   R   RW   RZ   R:   R   R   R   R   (   R1   R   R   R   t   offsett   ent_addrt	   ent_ptr_t(    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR     s$    	
(   R   R   R6   R   R   R^   RI   R   (    (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR{     s   			Rs   c           B  s)   e  Z d  Z d   Z d   Z d   Z RS(   t   PyListObjectc         C  s   |  j  d  } | | S(   Nt   ob_item(   RF   (   R1   R   t   field_ob_item(    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt   __getitem__  s    c         C  sw   |  j    | k r t d  S| j |  j     g  t t |  j d    D]" } t j |  |  j |  ^ qK } | S(   Ns   [...]R?   (	   R   R   R   R   R   RF   R8   RG   R^   (   R1   RK   R   R   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR^     s    
Ac         C  s   |  j    | k r# | j d  d  S| j |  j     | j d  xb t t |  j d    D]E } | d k r | j d  n  t j |  |  } | j | |  q_ W| j d  d  S(   Ns   [...]t   [R?   i    s   , t   ](	   R   R   R   R   R   RF   R8   RG   RI   (   R1   RJ   RK   R   t   element(    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyRI     s    "(   R   R   R   R   R^   RI   (    (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyRs     s   		
Rq   c           B  s    e  Z d  Z d   Z d   Z RS(   t   PyLongObjectc         C  s   t  |  j d   } | d k r% d S|  j d  } t j d  j d k rU d } n d } g  t t |   D]" } t  | |  d | | ^ qn } t |  } | d k  r | } n  | S(   sG  
        Python's Include/longobjrep.h has this declaration:
           struct _longobject {
               PyObject_VAR_HEAD
               digit ob_digit[1];
           };

        with this description:
            The absolute value of a number is equal to
                 SUM(for i=0 through abs(ob_size)-1) ob_digit[i] * 2**(SHIFT*i)
            Negative numbers are represented with ob_size < 0;
            zero is represented by ob_size == 0.

        where SHIFT can be either:
            #define PyLong_SHIFT        30
            #define PyLong_SHIFT        15
        R?   i    t   ob_digitt   digiti   i   i   (   RR   RF   R   R   R
   R   t   abst   sum(   R1   RK   R?   R   t   SHIFTR   t   digitsR   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR^     s    	8
c         C  s$   |  j  |  } | j d |  d  S(   Ns   %s(   R^   R   (   R1   RJ   RK   t   proxy(    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyRI   3  s    (   R   R   R   R^   RI   (    (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyRq     s   	$Rg   c           B  s   e  Z d  Z d   Z RS(   s   
    Class wrapping a gdb.Value that's a PyBoolObject* i.e. one of the two
    <bool> instances (Py_True/Py_False) within the process being debugged.
    c         C  s   t  j |  |  r t St Sd  S(   N(   Rq   R^   R   R   (   R1   RK   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR^   >  s    (   R   R   R6   R^   (    (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyRg   9  s   Ri   c           B  s   e  Z d  Z d Z d   Z RS(   s   
    Class wrapping a gdb.Value that's a PyObject* pointing to the
    singleton (we hope) _Py_NoneStruct with ob_type PyNone_Type
    R9   c         C  s   d  S(   N(   R7   (   R1   RK   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR^   K  s    (   R   R   R6   R   R^   (    (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyRi   D  s   Rj   c           B  sk   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 RS(   t   PyFrameObjectc         C  s   t  j |  | |  |  j   s t j |  j d   |  _ |  j j d  |  _ |  j j d  |  _	 t
 |  j d   |  _ t
 |  j d   |  _ t
 |  j j d   |  _ t j |  j j d   |  _ n  d  S(   Nt   f_codet   co_namet   co_filenamet   f_linenot   f_lastit
   co_nlocalst   co_varnames(   R8   R2   RS   R   RG   RF   t   coRH   R   R   R   R   R   R   Ru   R   (   R1   R<   R=   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR2   R  s    c         c  s   |  j    r d S|  j d  } xZ t |  j  D]I } t j | |  } | j   s/ t j |  j |  } | | f Vq/ q/ Wd S(   s   
        Yield a sequence of (name,value) pairs of PyObjectPtr instances, for
        the local variables of this frame
        Nt   f_localsplus(   RS   RF   R   R   R8   RG   R@   R   (   R1   R   R   R   t	   pyop_name(    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt   iter_locals_  s    c         C  s)   |  j    r d S|  j d  } | j   S(   s   
        Yield a sequence of (name,value) pairs of PyObjectPtr instances, for
        the global variables of this frame
        t	   f_globals(    (   RS   RH   R   (   R1   t   pyop_globals(    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt   iter_globalsn  s    c         C  s)   |  j    r d S|  j d  } | j   S(   st   
        Yield a sequence of (name,value) pairs of PyObjectPtr instances, for
        the builtin variables
        t
   f_builtins(    (   RS   RH   R   (   R1   t   pyop_builtins(    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt   iter_builtinsy  s    c         C  s   x< |  j    D]. \ } } | | j t    k r | d f Sq Wx< |  j   D]. \ } } | | j t    k rL | d f SqL Wx< |  j   D]. \ } } | | j t    k r | d f Sq Wd S(   s   
        Look for the named local variable, returning a (PyObjectPtr, scope) pair
        where scope is a string 'local', 'global', 'builtin'

        If not found, return (None, None)
        t   localt   globalt   builtinN(   NN(   R   R^   RN   R   R  R7   (   R1   RD   R   R   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt   get_var_by_name  s    c         C  s#   |  j    r d S|  j j t    S(   s;   Get the path of the current Python source file, as a strings!   (frame information optimized out)(   RS   R   R^   RN   (   R1   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR(     s    c         C  sO   |  j    r d S|  j d  } t |  d k r8 |  j S|  j j |  j  Sd S(   s   Get current line number as an integer (1-based)

        Translated from PyFrame_GetLineNumber and PyCode_Addr2Line

        See Objects/lnotab_notes.txt
        t   f_tracei    N(   RS   R7   RF   RR   R   R   R   R   (   R1   R  (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt   current_line_num  s    c         C  sy   |  j    r d S|  j   } y t t |  d  } Wn t k
 rI d SX| # | j   } | |  j   d SWd QXd S(   s^   Get the text of the current source line as a string, with a trailing
        newline characters!   (frame information optimized out)t   ri   N(   RS   R(   t   openR,   t   IOErrorR7   t	   readlinesR	  (   R1   R(   t   ft	   all_lines(    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt   current_line  s    c         C  s   |  j    r | j d  d  S| j d |  j   |  j j |  |  j   |  j j |  f  t } xi |  j   D][ \ } } | s | j d  n  t	 } | j | j |   | j d  | j
 | |  qq W| j d  d  S(   Ns!   (frame information optimized out)s)   Frame 0x%x, for file %s, line %i, in %s (s   , R   R   (   RS   R   R   R   R^   R	  R   R   R   R   RI   (   R1   RJ   RK   R   R   R   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyRI     s"    			c         C  sh   |  j    r  t j j d  d  St   } t j j d |  j j |  |  j   |  j j |  f  d  S(   Ns$     (frame information optimized out)
s     File "%s", line %i, in %s
(	   RS   R"   t   stdoutR   RN   R   R^   R	  R   (   R1   RK   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt   print_traceback  s    		N(   R   R   R   R7   R2   R   R   R  R  R(   R	  R  RI   R  (    (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyRj   O  s   								Rk   c           B  s8   e  Z d  Z e d    Z d   Z d   Z d   Z RS(   t   PySetObjectc         C  s   t  j d  j   S(   Nt   _PySet_Dummy(   R   t   lookup_global_symbolt   value(   R1   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt
   _dummy_key  s    c         c  s   |  j    } |  j d  } x^ t |  j d  d  D]C } | | } | d } | d k r5 | | k r5 t j |  Vq5 q5 Wd  S(   Nt   tablet   maski   t   keyi    (   R  RF   R   R8   RG   (   R1   t	   dummy_ptrR  R   t   setentryR  (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt   __iter__  s     

c           sy   |  j      k r& t d |  j    S  j |  j       f d   |  D } |  j   d k rk t |  St |  Sd  S(   Ns   %s(...)c         3  s   |  ] } | j     Vq d  S(   N(   R^   (   t   .0R  (   RK   (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pys	   <genexpr>  s    Re   (   R   R   RX   R   Re   RN   (   R1   RK   t   members(    (   RK   s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR^     s    
c         C  s  |  j    } |  j   | k r/ | j d  d  S| j |  j    |  j d  so | j |  | j d  d  S| d k r | j |  | j d  n  | j d  t } x: |  D]2 } | s | j d  n  t } | j | |  q W| j d  | d k r| j d	  n  d  S(
   Ns   (...)t   useds   ()RN   R   R   s   , R   R   (   RX   R   R   R   RF   R   R   RI   (   R1   RJ   RK   RT   R   R  (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyRI     s,    (   R   R   R   R   R  R  R^   RI   (    (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyRk     s
   			Rw   c           B  s)   e  Z d  Z d   Z d   Z d   Z RS(   t   PyBytesObjectc         C  sc   |  j  d  } |  j  d  } | j j t    } d j g  t |  D] } t | |  ^ qF  S(   NR?   t   ob_svalR!   (   RF   RZ   R:   R   R'   R   R%   (   R1   t   field_ob_sizet   field_ob_svalt   char_ptrR   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt   __str__  s    c         C  s
   t  |   S(   N(   t   str(   R1   RK   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR^   $  s    c         C  sp  |  j  |  } d } d | k r6 d | k r6 d } n  | j d  | j |  x| D]} | | k su | d k r | j d  | j |  qW | d k r | j d  qW | d k r | j d  qW | d	 k r | j d
  qW | d k  st |  d k rN| j d  | j t t |  d @d ? | j t t |  d @ qW | j |  qW W| j |  d  S(   Nt   't   "t   bs   \s   	s   \ts   
s   \ns   s   \rt    i   s   \xi   i   i   (   R^   R   R$   t	   hexdigits(   R1   RJ   RK   R   t   quoteR+   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyRI   '  s,    	(   R   R   R   R&  R^   RI   (    (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyRw     s   		t   PyStringObjectPtrc           B  s   e  Z d  Z RS(   t   PyStringObject(   R   R   R   (    (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR.  G  s   Ru   c           B  s)   e  Z d  Z d   Z d   Z d   Z RS(   t   PyTupleObjectc         C  s   |  j  d  } | | S(   NR   (   RF   (   R1   R   R   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR   N  s    c           sg     j     k r t d  S j   j     t    f d   t t   j d    D  } | S(   Ns   (...)c         3  s+   |  ]! } t  j   |  j   Vq d  S(   N(   R8   RG   R^   (   R  R   (   R1   RK   (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pys	   <genexpr>Y  s   R?   (   R   R   R   t   tupleR   R   RF   (   R1   RK   R   (    (   R1   RK   s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR^   S  s    
"c         C  s   |  j    | k r# | j d  d  S| j |  j     | j d  xb t t |  j d    D]E } | d k r | j d  n  t j |  |  } | j | |  q_ W|  j d  d k r | j d  n | j d  d  S(	   Ns   (...)R   R?   i    s   , i   s   ,)R   (	   R   R   R   R   R   RF   R8   RG   RI   (   R1   RJ   RK   R   R   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyRI   ]  s    "(   R   R   R   R   R^   RI   (    (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyRu   K  s   		
RP   c           B  s   e  Z d  Z RS(   t   PyTypeObject(   R   R   R   (    (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyRP   o  s   c         C  s/   |  d k r t  Sd d  l } | j |   d k S(   Nu    it   Ct   Z(   R3  R4  (   R   t   unicodedatat   category(   R   R5  (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt   _unichr_is_printables  s    i   c         C  sP   |  d k  r t  |   S|  d 8}  d |  d ?B} d |  d @B} t  |  t  |  S(   Ni   i   i
   i   i  (   t   unichr(   t   xt   ch1t   ch2(    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt   _unichr~  s    

Ry   c           B  s)   e  Z d  Z d   Z d   Z d   Z RS(   t   PyUnicodeObjectc         C  s   t  j d  } | j S(   Nt
   Py_UNICODE(   R   R   R
   (   R1   t   _type_Py_UNICODE(    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt
   char_width  s    c         C  s*  t  d  k rL t j d  j   j   } d g  | D] } | j ^ q1 k a  n  t  rt } |  j d  } | d } | d } t	 | d  o t	 | d  } t	 | d  s t
 | d  }	 t } | d	 }
 qt
 | d
  }	 | r | j d }
 n3 t	 | d  r| j d }
 n |  j d  d }
 t	 | d  } | d k rX|
 j t    }
 q| d k ry|
 j t    }
 q| d k r|
 j t    }
 qn6 t
 |  j d
   }	 |  j d  }
 |  j   d k } | sg  t |	  D] } t	 |
 |  ^ q} n g  } d } t |	  } x | | k  rt	 |
 |  } | d 7} | d k  sj| d k sj| |	 k r}| j |  q n  t	 |
 |  } | d k  s | d k rq n  | d @d >} | | d @O} | d 7} | j |  | d 7} q Wd j g  | D]$ } | d k rt |  n d ^ q } | S(   NR=  R4   t   _baset   statet   asciit   compactt   readyt   wstr_lengtht   wstrt   lengthi   t   anyt   kindi   i   R'  i    i   i   i  i  i
   i   u    i s   \ufffd(   t
   _is_pep393R7   R   R   t   targett   fieldsRD   R   RF   R   RR   R   RZ   R:   R   R   R   R@  R   R   R&   R'   R<  (   R1   RK   RM  R  t   may_have_surrogatesRD  RC  RB  t   is_compact_asciit   field_lengtht	   field_strt	   repr_kindR   t   Py_UNICODEst   limitt   ucst   ucs2t   codeR   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR^     sh    %

 ,
$
1c         C  s  |  j  |  } d | k r0 d | k r0 d } n d } | j |  d } x&| t |  k  rq| | } | d 7} | | k s | d k r | j d  | j |  qL | d k r | j d  qL | d k r | j d	  qL | d
 k r | j d  qL | d k  s| d k r]| j d  | j t t |  d ?d @ | j t t |  d @ qL t |  d k  r| j |  qL | } d  } t j d k  r| t |  k  rd t |  k od k  n rd t | |  k od k n r| | } | | } | d 7} qn  t |  }	 |	 rXy | j	 t
  WqXt k
 rTt }	 qXXn  |	 sE| d  k	 rt |  d @d >}
 |
 t |  d @O}
 |
 d 7}
 n t |  }
 |
 d k r| j d  | j t |
 d ?d @ | j t |
 d @ qn|
 d k r| j d  | j t |
 d ?d @ | j t |
 d ?d @ | j t |
 d ?d @ | j t |
 d ?d @ | j t |
 d ?d @ | j t |
 d ?d @ | j t |
 d ?d @ | j t |
 d @ qn| j d  | j t |
 d ?d @ | j t |
 d ?d @ | j t |
 d ?d @ | j t |
 d @ qL | j |  | d  k	 rL | j |  qL qL W| j |  d  S(    NR(  R)  i    i   s   \s   	s   \ts   
s   \ns   s   \rR+  i   s   \xi   i   i   i   i   i  i  i
   i   s   \Ui   i   i   i   i   i   s   \u(   R^   R   R3   R,  R$   R7   R"   t
   maxunicodeR7  R   R   t   UnicodeEncodeErrorR   (   R1   RJ   RK   R   R-  R   t   chRU  R;  t	   printableRW  (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyRI     s    	

"&

(   R   R   R   R@  R^   RI   (    (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyRy     s   		HRm   c           B  s;   e  Z d  Z d   Z d   Z d   Z d   Z d   Z RS(   Rm   c         C  sJ   y+ |  j  d  d d j   } t |  SWn t t f k
 rE d SXd  S(   Nt   descrt   d_baseRD   s   <unknown name>(   RF   RV   R_   R   RW   (   R1   RD   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt	   safe_nameF  s
    c         C  s>   y |  j  d  d d j   SWn t t f k
 r9 d SXd  S(   NR1   R>   RT   s   <unknown tp_name>(   RF   RV   R   RW   (   R1   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyRX   M  s    c         C  s@   y! t  |  j d   } d | SWn t t f k
 r; d SXd  S(   NR1   s   %#xs   <failed to get self address>(   RR   RF   R   RW   (   R1   RZ   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt   safe_self_addresssS  s
    c         C  s5   |  j    } |  j   } |  j   } d | | | f S(   Ns&   <method-wrapper %s of %s object at %s>(   R^  RX   R_  (   R1   RK   RD   RT   t   self_address(    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR^   Z  s
    c         C  s    |  j  |  } | j |  d  S(   N(   R^   R   (   R1   RJ   RK   R   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyRI   a  s    (   R   R   R   R^  RX   R_  R^   RI   (    (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyRm   C  s   				c         C  s   t  t |    S(   N(   R   R'  (   R<   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR   f  s    c         C  s.   t  r t |   Sd d l m } | |   Sd  S(   Ni(   t   pformat(   R   R_   t   pprintRa  (   R   Ra  (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt	   stringifyj  s    
t   PyObjectPtrPrinterc           B  s    e  Z d  Z d   Z d   Z RS(   s   Prints a (PyObject*)c         C  s   | |  _  d  S(   N(   R<   (   R1   R<   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR2   w  s    c         C  sE   t  j |  j  } t r% | j t  S| j t    } t |  Sd  S(   N(	   R8   RG   R<   R   RO   t   MAX_OUTPUT_LENR^   RN   Rc  (   R1   t   pyopR^   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt	   to_stringz  s
    (   R   R   R6   R2   Rg  (    (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyRd  t  s   	c         C  s]   |  j  j   } | j t j k r% d  S| j   j   } t |  } | d k rY t |   Sd  S(   NR9   R   R=  Rm   (   R9   R   R=  Rm   (	   RQ   t   unqualifiedRW  R   t   TYPE_CODE_PTRR7   RL  R'  Rd  (   R<   RQ   R   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt   pretty_printer_lookup  s    c         C  s)   |  d  k r t }  n  |  j j t  d  S(   N(   R7   R   t   pretty_printersR&   Rj  (   t   obj(    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt   register  s    	t   Framec           B  s   e  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 e d    Z e d    Z e d    Z d   Z d   Z RS(   s7   
    Wrapper for gdb.Frame, adding various methods
    c         C  s   | |  _  d  S(   N(   t	   _gdbframe(   R1   t   gdbframe(    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR2     s    c         C  s'   |  j  j   } | r t |  Sd  Sd  S(   N(   Ro  t   olderRn  R7   (   R1   Rq  (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyRq    s    
c         C  s'   |  j  j   } | r t |  Sd  Sd  S(   N(   Ro  t   newerRn  R7   (   R1   Rr  (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyRr    s    
c         C  s1   t  |  j d  s  t d  t S|  j j   t S(   s   If supported, select this frame and return True; return False if unsupported

        Not all builds have a gdb.Frame.select method; seems to be present on Fedora 12
        onwards, but absent on Ubuntu buildbott   selectsS   Unable to select frame: this build of gdb does not expose a gdb.Frame.select method(   t   hasattrRo  t   printR   Rs  R   (   R1   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyRs    s
    
c         C  s9   d } |  } x& | j    r4 | d 7} | j    } q W| S(   sW   Calculate index of frame, starting at 0 for the newest frame within
        this threadi    i   (   Rr  (   R1   t   indext
   iter_frame(    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt	   get_index  s    
c         C  s$   |  j    r t S|  j   r  t St S(   s   Is this a _PyEval_EvalFrameDefault frame, or some other important
        frame? (see is_other_python_frame for what "important" means in this
        context)(   t   is_evalframeR   t   is_other_python_frameR   (   R1   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt   is_python_frame  s
    c         C  s8   |  j  j   t k r4 |  j  j   t j k r4 t Sn  t S(   s)   Is this a _PyEval_EvalFrameDefault frame?(   Ro  RD   t	   EVALFRAMERQ   R   t   NORMAL_FRAMER   R   (   R1   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyRy    s    c         C  s   |  j    r d S|  j   r  d S|  j } | j   } | s? t S| d
 k r d } y | j |  } t |  SWq t k
 r d | SXn  | d k r y | j d  } t |  SWq t k
 r d	 SXn  t S(   s  Is this frame worth displaying in python backtraces?
        Examples:
          - waiting on the GIL
          - garbage-collecting
          - within a CFunction
         If it is, return a descriptive string
         For other frames, return False
         s   Waiting for the GILs   Garbage-collectingt   _PyCFunction_FastCallDictt   _PyCFunction_FastCallKeywordst   funcs*   PyCFunction invocation (unable to read %s)t   wrapper_callt   wps   <wrapper_call invocation>(   R~  R  (   t   is_waiting_for_gilt   is_gc_collectRo  RD   R   t   read_varR'  RW   (   R1   Rd   t   callert   arg_nameR  (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyRz    s.    			c         C  s#   |  j  j   } | r d | k Sd S(   s!   Is this frame waiting on the GIL?t   pthread_cond_timedwaitN(   Ro  RD   (   R1   RD   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR  +  s    c         C  s   |  j  j   d k S(   s5   Is this frame "collect" within the garbage-collector?t   collect(   Ro  RD   (   R1   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR  2  s    c         C  s   y |  j  j d  } t j |  } | j   s4 | S| } |  j  j   } | r | j d  } t j |  } | j   s | Sn  | SWn t k
 r d  SXd  S(   NR  (   Ro  R  Rj   RG   RS   Rq  t
   ValueErrorR7   (   R1   R  Rd   t
   orig_frameR  (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt   get_pyop6  s    c         C  s    t  j   } | r t |  Sd  S(   N(   R   t   selected_frameRn  R7   (   R~   Ro  (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt   get_selected_frameJ  s    
c         C  sU   y |  j    } Wn t j k
 r' d SXx& | rP | j   rA | S| j   } q+ Wd S(   sZ   Try to obtain the Frame for the python-related code in the selected
        frame, or NoneN(   R  R   t   errorR7   R{  Rq  (   R~   Rd   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt   get_selected_python_frameQ  s    	c         C  s9   |  j    } x& | r4 | j   r% | S| j   } q Wd S(   sf   Try to obtain the Frame for the python bytecode interpreter in the
        selected GDB frame, or NoneN(   R  Ry  Rq  R7   (   R~   Rd   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt   get_selected_bytecode_framec  s    	c         C  s  |  j    r |  j   } | r | j t  } t t j d |  j   | f  | j   s | j	   } | d  k	 r t j j d | j    q q q t j j d |  j    nO |  j   } | r t j j d |  j   | f  n t j j d |  j    d  S(   Ns   #%i %s
s       %s
s.   #%i (unable to read python frame information)
s   #%i
(   Ry  R  RO   Re  R   R"   R  Rx  RS   R  R7   R   t   stripRz  (   R1   Rf  t   linet   info(    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt   print_summaryq  s     ##c         C  s   |  j    r |  j   } | ro | j   | j   s | j   } | d  k	 rl t j j d | j	    ql q q t j j d  n9 |  j
   } | r t j j d |  n t j j d  d  S(   Ns       %s
s,     (unable to read python frame information)
s     %s
s     (not a python frame)
(   Ry  R  R  RS   R  R7   R"   R  R   R  Rz  (   R1   Rf  R  R  (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR    s    
#(   R   R   R6   R2   Rq  Rr  Rs  Rx  R{  Ry  Rz  R  R  R  R   R  R  R  R  R  (    (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyRn    s"   						
		.				t   PyListc           B  s    e  Z d  Z d   Z d   Z RS(   s   List the current Python source code, if any

    Use
       py-list START
    to list at a different line number within the python source.

    Use
       py-list START, END
    to list a specific range of lines within the python source.
    c         C  s#   t  j j |  d t  j t  j  d  S(   Ns   py-list(   R   t   CommandR2   t   COMMAND_FILESt   COMPLETE_NONE(   R1   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR2     s    c      	   C  s  d d  l  } d  } d  } | j d |  } | rR t | j d   } | d } n  | j d |  } | r t t | j    \ } } n  t j   } | s t	 d  d  S| j
   } | s | j   r t	 d  d  S| j   }	 | j   }
 | d  k r|
 d } |
 d } n  | d	 k  r%d	 } n  y t t |	  d
  } Wn. t k
 rn} t j j d |	 | f  d  SX|  | j   } xl t | | d	 | ! D]S \ } } t | |  } | | |
 k rd | } n  t j j d | | f  qWWd  QXd  S(   Nis   \s*(\d+)\s*i    i
   s   \s*(\d+)\s*,\s*(\d+)\s*s:   Unable to locate gdb frame for python bytecode interpreters*   Unable to read information on python framei   i   R
  s   Unable to open %s: %s
t   >s	   %4s    %s(   t   reR7   t   matchR   t   groupt   mapt   groupsRn  R  Ru  R  RS   R(   R	  R  R,   R  R"   R  R   R  t	   enumerateR'  (   R1   R   t   from_ttyR  t   startt   endt   mRd   Rf  R(   R   R  t   errR  R   R  t   linestr(    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt   invoke  sL    


	$(   R   R   R6   R2   R  (    (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR    s   
	c         C  s   t  j   } | s  t d  d Sxd | r |  r> | j   } n | j   } | sT Pn  | j   r} | j   ry | j   n  d S| } q# W|  r t d  n
 t d  d S(   s9   Move up or down the stack (for the py-up/py-down command)s   Unable to locate python frameNs$   Unable to find an older python frames#   Unable to find a newer python frame(   Rn  R  Ru  Rq  Rr  R{  Rs  R  (   t   move_upRd   Rw  (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt   move_in_stack  s$    
	
t   PyUpc           B  s    e  Z d  Z d   Z d   Z RS(   sE   Select and print the python stack frame that called this one (if any)c         C  s#   t  j j |  d t  j t  j  d  S(   Ns   py-up(   R   R  R2   t   COMMAND_STACKR  (   R1   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR2     s    c         C  s   t  d t  d  S(   NR  (   R  R   (   R1   R   R  (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR  	  s    (   R   R   R6   R2   R  (    (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR     s   	t   PyDownc           B  s    e  Z d  Z d   Z d   Z RS(   sC   Select and print the python stack frame called by this one (if any)c         C  s#   t  j j |  d t  j t  j  d  S(   Ns   py-down(   R   R  R2   R  R  (   R1   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR2     s    c         C  s   t  d t  d  S(   NR  (   R  R   (   R1   R   R  (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR    s    (   R   R   R6   R2   R  (    (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR    s   	Rs  t   PyBacktraceFullc           B  s    e  Z d  Z d   Z d   Z RS(   sR   Display the current python frame and all the frames within its call stack (if any)c         C  s#   t  j j |  d t  j t  j  d  S(   Ns
   py-bt-full(   R   R  R2   R  R  (   R1   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR2     s    c         C  sV   t  j   } | s  t d  d  Sx/ | rQ | j   rB | j   n  | j   } q# Wd  S(   Ns   Unable to locate python frame(   Rn  R  Ru  R{  R  Rq  (   R1   R   R  Rd   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR  &  s    
	(   R   R   R6   R2   R  (    (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR    s   	t   PyBacktracec           B  s    e  Z d  Z d   Z d   Z RS(   sR   Display the current python frame and all the frames within its call stack (if any)c         C  s#   t  j j |  d t  j t  j  d  S(   Ns   py-bt(   R   R  R2   R  R  (   R1   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR2   5  s    c         C  sf   t  j   } | s  t d  d  St j j d  x/ | ra | j   rR | j   n  | j   } q3 Wd  S(   Ns   Unable to locate python frames$   Traceback (most recent call first):
(	   Rn  R  Ru  R"   R  R   R{  R  Rq  (   R1   R   R  Rd   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR  <  s    
	(   R   R   R6   R2   R  (    (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR  3  s   	t   PyPrintc           B  s    e  Z d  Z d   Z d   Z RS(   s4   Look up the given python variable name, and print itc         C  s#   t  j j |  d t  j t  j  d  S(   Ns   py-print(   R   R  R2   t   COMMAND_DATAR  (   R1   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR2   L  s    c         C  s   t  |  } t j   } | s, t d  d  S| j   } | sL t d  d  S| j |  \ } } | r t d | | | j t  f  n t d |  d  S(   Ns   Unable to locate python frames*   Unable to read information on python frames
   %s %r = %ss   %r not found(   R'  Rn  R  Ru  R  R  RO   Re  (   R1   R   R  RD   Rd   t
   pyop_framet   pyop_vart   scope(    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR  S  s     

(   R   R   R6   R2   R  (    (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR  J  s   	t   PyLocalsc           B  s,   e  Z d  Z d d  Z d   Z d   Z RS(   s4   Look up the given python variable name, and print its	   py-localsc         C  s#   t  j j |  | t  j t  j  d  S(   N(   R   R  R2   R  R  (   R1   t   command(    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR2   n  s    c         C  s   t  |  } t j   } | s, t d  d  S| j   } | sL t d  d  S|  j |  } g  | D]$ \ } } | j t    | f ^ qb } | r t | d d   \ } } t	 |  } x= | D]2 \ } }	 |	 j
 t  }
 t d | | |
 f  q Wn  d  S(   Ns   Unable to locate python frames*   Unable to read information on python frameR  c         S  s   t  |  d  S(   Ni    (   R3   (   t   item(    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt   <lambda>  R!   s	   %-*s = %s(   R'  Rn  R  Ru  R  t   get_namespaceR^   RN   t   maxR3   RO   Re  (   R1   R   R  RD   Rd   R  t	   namespaceR   t   max_name_lengthR   R  (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR  u  s"    

1c         C  s
   | j    S(   N(   R   (   R1   R  (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR    s    (   R   R   R6   R2   R  R  (    (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR  l  s   	t	   PyGlobalsc           B  s   e  Z d  Z d   Z RS(   s9   List all the globals in the currently select Python framec         C  s
   | j    S(   N(   R   (   R1   R  (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR    s    (   R   R   R6   R  (    (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR    s   s
   py-globalst   PyNameEqualsc           B  s   e  Z d    Z d   Z RS(   c         C  sd   t  t j    } | j   r` | j   } | d  k rG t j d  d  St | |  j	 t
    Sd  S(   NsB   Use a Python debug build, Python breakpoints won't work otherwise.(   Rn  R   R  t   is_evalframeexR  R7   t   warningst   warnt   getattrR^   RN   (   R1   t   attrRd   t   pyframe(    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt   _get_pycurframe_attr  s    c         C  s+   |  j  d  } | d  k	 o* | | j   k S(   NR   (   R  R7   RV   (   R1   t   funcnameR  (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR    s    (   R   R   R  R  (    (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR    s   	t   pyname_equalst   PyModEqualsc           B  s   e  Z d    Z RS(   c         C  sS   |  j  d  } | d  k	 rO t j j t j j |   \ } } | | j   k St S(   NR   (   R  R7   t   ost   patht   splitextt   basenameRV   R   (   R1   t   modnameR  R(   t   ext(    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR    s
    $(   R   R   R  (    (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR    s   t   pymod_equalst   PyBreakc           B  s   e  Z d  Z d   Z RS(   s   
    Set a Python breakpoint. Examples:

    Break on any function or method named 'func' in module 'modname'

        py-break modname.func

    Break on any function or method named 'func'

        py-break func
    c         C  sV   d | k r7 | j  d  \ } } } d | | f } n
 d | } t j d |  d  S(   Nt   .s+   $pyname_equals("%s") && $pymod_equals("%s")s   $pyname_equals("%s")s   break PyEval_EvalFrameEx if (   t
   rpartitionR   t   execute(   R1   R  R  R  t   dott   cond(    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR    s    
(   R   R   R6   R  (    (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR    s   s   py-breakt   _LoggingStatec           B  s2   e  Z d  Z d   Z d   Z d   Z d   Z RS(   sI   
    State that helps to provide a reentrant gdb.execute() function.
    c         C  sQ   t  j d  } | |  _ | j |  _ | j   |  _ t d |  j  g  |  _ d  S(   Ns   r+s   set logging file %s(	   t   tempfilet   NamedTemporaryFileR   RD   R(   t   filenot   fdt   _executet   file_position_stack(   R1   R  (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR2     s    	c         C  sM   |  j  s* t d  t d  t d  n  |  j  j t j |  j  j  |  S(   Ns   set logging redirect ons   set logging ons   set pagination off(   R  R  R&   R  t   fstatR  t   st_size(   R1   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt	   __enter__  s    	

c         C  s4   t  j   |  j j |  j d  |  j j   } | S(   Ni(   R   t   flushR   t   seekR  t   read(   R1   R   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt	   getoutput  s    
c         C  sZ   |  j  j   } |  j j |  |  j j   |  j  sV t d  t d  t d  n  d  S(   Ns   set logging offs   set logging redirect offs   set pagination on(   R  t   popR   R  t   truncateR  (   R1   t   exc_typet   exc_valt   tbt   startpos(    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt   __exit__  s    	

(   R   R   R6   R2   R  R  R  (    (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR    s
   				c         C  s@   | r/ t   } t |  |  | j   SWd QXn t |  |  d S(   s   
    Replace gdb.execute() with this function and have it accept a 'to_string'
    argument (new in 7.2). Have it properly capture stderr also. Ensure
    reentrancy.
    N(   t   _logging_stateR  R  (   R  R  Rg  RB  (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR  	  s
    	c          C  s\   t  j   d St  j   }  x; t  j   D]- } x$ | j   D] } | |  k r: | Sq: Wq' Wd S(   s.   
    Return the selected inferior in gdb.
    i    N(   R   t	   inferiorst   selected_threadt   threads(   R  t   inferiort   thread(    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt   get_selected_inferior  s    c         C  sc   t  j   \ } } t j | d  } | j |   | j   t j d | d | t j |  d S(   s  
    Source a gdb script with script_contents passed as a string. This is useful
    to provide defines for py-step and py-next to make them repeatable (this is
    not possible with gdb.execute()). See
    http://sourceware.org/bugzilla/show_bug.cgi?id=12216
    t   ws	   source %sRg  N(	   R  t   mkstempR  t   fdopenR   t   closeR   R  t   remove(   t   script_contentsRg  R  R(   R  (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt   source_gdb_script,  s    
c           C  s'   t  t j d  t j t j f  d  S(   Ns           define py-step
        -py-step
        end

        define py-next
        -py-next
        end

        document py-step
        %s
        end

        document py-next
        %s
        end
    (   R  t   textwrapt   dedentt   PyStepR6   t   PyNext(    (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt   register_defines;  s    	c         C  s-   d } x  |  r( |  j    }  | d 7} q	 W| S(   s$   Tells the stackdepth of a gdb frame.i    i   (   Rq  (   Rd   t   depth(    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt
   stackdepthO  s
    	t   ExecutionControlCommandBasec           B  s}   e  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 RS(   s   
    Superclass for language specific execution control. Language specific
    features should be implemented by lang_info using the LanguageInfo
    interface. 'name' is the name of the command.
    c         C  s/   t  t |   j | t j t j  | |  _ d  S(   N(   t   superR  R2   R   t   COMMAND_RUNNINGR  t	   lang_info(   R1   RD   R  (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR2   `  s    c         c  sl   t  j |  j j   |  j j    } xA | D]9 } t j d | d t } t j	 d |  j
 d  Vq+ Wd  S(   Ns   break %sRg  s   Breakpoint (\d+)i   (   t	   itertoolst   chainR  t   static_break_functionst   runtime_break_functionsR   R  R   R  t   searchR  (   R1   t   all_locationst   locationR   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt   install_breakpointse  s    c         C  s&   x | D] } t  j d |  q Wd  S(   Ns	   delete %s(   R   R  (   R1   t   breakpoint_listt   bp(    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt   delete_breakpointsn  s    c           s   t  j } d | t  j Bf d d | f g } d | f d | f g }   f d   } t  j d   t  j  } | r d	 | j d
  } n d } | |  | | |  f S(   Ns   ^Program received signal .*s   .*[Ww]arning.*i    s   ^Program exited .*s   ^(Old|New) value = .*s   ^\d+: \w+ = .*c           s`   g  } xJ |  D]B \ } } x3 t  j |   |  D] } | j | j d   q/ Wq Wd j |  S(   Ni    s   
(   R  t   finditerR&   R  R'   (   t   regexest   outputt   regext   flagsR  (   R   (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt   filter_output  s
    s   ^Value returned is \$\d+ = (.*)s   Value returned: %s
i   R!   (   s   .*[Ww]arning.*i    (   R  t	   MULTILINEt   DOTALLR  R  (   R1   R   t   reflagst   output_on_haltt   output_alwaysR  t   match_finisht   finish_output(    (   R   s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR  r  s    				c         C  s   t    j d k S(   Ni    (   R  t   pid(   R1   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt   stopped  s    c         C  s   |  j  |  \ } } |  j   r8 t |  t |  n t j   } |  j j |  } |  j j |  r |  j j |  } | r t |  q n  | r | j	   r t | j	    n  t |  n
 t |  d S(   s   
        After doing some kind of code running in the inferior, print the line
        of source code or the result of the last executed gdb command (passed
        in as the `result` argument).
        N(
   R  R  Ru  R   R  R  t   get_source_linet   is_relevant_functiont   exc_infot   rstrip(   R1   R   R  R  Rd   t   source_linet   raised_exception(    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt   finish_executing  s    
c         C  sB   t  j   j   d k	 r+ t  j d d t St  j d d t Sd S(   sd   
        Execute until the function returns (or until something else makes it
        stop)
        t   finishRg  t   contN(   R   R  Rq  R7   R  R   (   R1   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt   _finish  s    c         C  s   x{ t  r} |  j   } y t j   } Wn t k
 r9 Pn Xt j d |  } |  j j |  } | sv | sv |  j	   r Pq q W| S(   sJ   
        Execute until the function returns to a relevant caller.
        s   Breakpoint (\d+)(
   R   R&  R   R  RW   R  R  R  R  R  (   R1   R   Rd   t   hitbpt   is_relevant(    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt   _finish_frame  s    	c         G  s   |  j    } |  j |  d S(   s   Implements the finish command.N(   R)  R#  (   R1   R   R   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR$    s    t   nextc         C  s  | r t  |  j    } n  t j   } |  j j |  rc |  j j |  } | sc t |  } qc n  | } x:t r|  j j |  r t j	 | d t } n |  j
   } |  j   r Pn  t j   } |  j j |  }	 y | j   }
 Wn t k
 r d }
 n Xt j d |  } | r:|	 r:| j d  | k r:Pq:n  | | k rz| smt |  } | | k  og|	 }	 n  |	 rPqql |  j j |  } | rl | | k rl Pql ql W| r|  j |  n  |  j |  d S(   s  
        Do a single step or step-over. Returns the result of the last gdb
        command that made execution stop.

        This implementation, for stepping, sets (conditional) breakpoints for
        all functions that are deemed relevant. It then does a step over until
        either something halts execution, or until the next line is reached.

        If, however, stepover_command is given, it should be a string gdb
        command that continues execution in some way. The idea is that the
        caller has set a (conditional) breakpoint or watchpoint that can work
        more efficiently than the step-over loop. For Python this means setting
        a watchpoint for f->f_lasti, which means we can then subsequently
        "finish" frames.
        We want f->f_lasti instead of f->f_lineno, because the latter only
        works properly with local trace functions, see
        PyFrameObjectPtr.current_line_num and PyFrameObjectPtr.addr2line.
        Rg  s   Breakpoint (\d+)i   N(   t   listR
  R   R  R  R  R   R  R   R  R)  R  RD   RW   R7   R  R  R  R  R#  (   R1   t   stepintot   stepover_commandR  t
   beginframet	   beginlineR  t   newframeR   R  t	   framenameR  t   newdepthR   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt   step  sJ    	
	c         C  s$   |  j  t j d | d t  d  S(   Ns   run Rg  (   R#  R   R  R   (   R1   R   R  (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt   run(	  s    c         G  s    |  j  t j d d t  d  S(   NR%  Rg  (   R#  R   R  R   (   R1   R   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR%  +	  s    (   R   R   R6   R2   R
  R  R  R  R#  R&  R)  R$  R3  R4  R%  (    (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR  Y  s   					#					S	t   LanguageInfoc           B  s    e  Z d  Z d   Z d   Z RS(   s  
    This class defines the interface that ExecutionControlCommandBase needs to
    provide language-specific execution control.

    Classes that implement this interface should implement:

        lineno(frame)
            Tells the current line number (only called for a relevant frame).
            If lineno is a false value it is not checked for a difference.

        is_relevant_function(frame)
            tells whether we care about frame 'frame'

        get_source_line(frame)
            get the line of source code for the current line (only called for a
            relevant frame). If the source code cannot be retrieved this
            function should return None

        exc_info(frame) -- optional
            tells whether an exception was raised, if so, it should return a
            string representation of the exception value, None otherwise.

        static_break_functions()
            returns an iterable of function names that are considered relevant
            and should halt step-into execution. This is needed to provide a
            performing step-into

        runtime_break_functions() -- optional
            list of functions that we should break into depending on the
            context
    c         C  s   d S(   s   See this class' docstring.N(    (   R1   Rd   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR  P	  R!   c         C  s   d S(   sc   
        Implement this if the list of step-into functions depends on the
        context.
        (    (    (   R1   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR  S	  s    (   R   R   R6   R  R  (    (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR5  /	  s   	t
   PythonInfoc           B  s>   e  Z d    Z d   Z d   Z d   Z d   Z d   Z RS(   c         C  s/   t  |  j   } | r | St j d   d  S(   Nsu   Unable to find the Python frame, run your code with a debug build (configure with --with-pydebug or compile with -g).(   Rn  R  R   RW   (   R1   Rd   R  (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR  ]	  s
    c         C  s   |  j  |  j   S(   N(   R  R	  (   R1   Rd   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR   f	  s    c         C  s   t  |  j   S(   N(   Rn  R  (   R1   Rd   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR  i	  s    c         C  sL   y3 |  j  |  } d | j   | j   j   f SWn t k
 rG d  SXd  S(   Ns	   %4d    %s(   R  R	  R  R   R  R7   (   R1   Rd   R  (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR  l	  s    c         C  sn   yP | j  d  j   } t j d  rO | d } | d } | rO d | f Sn  Wn t t f k
 ri n Xd  S(   Nt   tstates   tstate->frame == ft   curexc_typet   curexc_values   An exception was raised: %s(   R  RB   R   t   parse_and_evalR  RW   (   R1   Rd   R7  t   inf_typet	   inf_value(    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR  t	  s    

c         c  s	   d Vd  S(   Nt   PyEval_EvalFrameEx(    (   R1   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR  	  s    (   R   R   R  R   R  R  R  R  (    (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR6  [	  s   						t   PythonStepperMixinc           B  s   e  Z d  Z d   Z RS(   sr   
    Make this a mixin so CyStep can also inherit from this and use a
    CythonCodeStepper at the same time.
    c         C  sa   t  j d d t } t t j d |  j d   } |  j d | d d  t  j d |  d	 S(
   sq   
        Set a watchpoint on the Python bytecode instruction pointer and try
        to finish the frame
        s   watch f->f_lastiRg  s   [Ww]atchpoint (\d+):i   R,  R-  R$  s	   delete %sN(   R   R  R   R   R  R  R  R3  (   R1   R,  R  t
   watchpoint(    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt   python_step	  s    !(   R   R   R6   R@  (    (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR>  	  s   R  c           B  s   e  Z d  Z e Z d   Z RS(   s   Step through Python code.c         C  s   |  j  d |  j  d  S(   NR,  (   R@  R,  (   R1   R   R  (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR  	  s    (   R   R   R6   R   R,  R  (    (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR  	  s   R  c           B  s   e  Z d  Z e Z RS(   s   Step-over Python code.(   R   R   R6   R   R,  (    (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR  	  s   t   PyFinishc           B  s   e  Z d  Z e j Z RS(   s+   Execute until function returns to a caller.(   R   R   R6   R  R$  R  (    (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyRA  	  s   t   PyRunc           B  s   e  Z d  Z e j Z RS(   s   Run the program.(   R   R   R6   R  R4  R  (    (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyRB  	  s   t   PyContc           B  s   e  Z e j Z RS(    (   R   R   R  R%  R  (    (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyRC  	  s   c         C  s*   |  j  d k	 r t |  j   St |   Sd S(   sb   
    Return the value of the pointer as a Python int.

    gdbval.type must be a pointer type
    N(   RZ   R7   R   (   R<   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt   _pointervalue	  s    c         C  sF   t  |   } y" | d k  r- t j d   n  Wn t k
 rA n X| S(   Ni    s:   Negative pointer value, presumably a bug in gdb, aborting.(   RD  R   t   GdbErrorRW   (   R<   R   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt   pointervalue	  s    c           C  sW   y t  j d  Wn; t k
 rN y t  j d  Wn t k
 rF d SXd Sn Xd Sd  S(   Nt   PyUnicode_FromEncodedObjectt   PyUnicodeUCS2_FromEncodedObjectt   UCS4t   UCS2R!   (   R   R:  RW   (    (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt   get_inferior_unicode_postfix	  s    t   PythonCodeExecutorc           B  s_   e  Z d  Z d Z d Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d
 d
 d	  Z RS(   i   i  i  c         C  sA   t  j d |  } t |  } | d k r= t  j d   n  | S(   Ns   (void *) malloc((size_t) %d)i    s-   No memory could be allocated in the inferior.(   R   R:  RF  RE  (   R1   R   t   chunkR   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt   malloc	  s
    c         C  s,   |  j  t |   } t   j | |  | S(   N(   RN  R3   R  t   write_memory(   R1   RV   R   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt   alloc_string	  s    c         C  s   |  j  |  } d } y t j |  Wn! t k
 rI d t   f } n Xz& t j d | | t |  f  } Wd  |  j |  Xt |  } | d k r t j d   n  | S(   Nt   PyString_FromStringAndSizes   PyUnicode%s_FromStringAndSizes)   (PyObject *) %s((char *) %d, (size_t) %d)i    s1   Unable to allocate Python string in the inferior.(	   RP  R   R:  RW   RK  R3   t   freeRF  RE  (   R1   RV   t   stringpRQ  R   R   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt   alloc_pystring	  s     c         C  s   t  j d |  d  S(   Ns   free((void *) %d)(   R   R:  (   R1   R   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyRR  
  s    c         C  s   t  j d |  d S(   sA   Increment the reference count of a Python object in the inferior.s   Py_IncRef((PyObject *) %d)N(   R   R:  (   R1   R   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt   incref
  s    c         C  s   t  j d |  d S(   sA   Decrement the reference count of a Python object in the inferior.s   Py_DecRef((PyObject *) %d)N(   R   R:  (   R1   R   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt   xdecref
  s    c   	   
   C  s   d | k r t  j d   n  | d 7} |  j |  } t |  } t |  } | d k sg | d k ry t  j d   n  d t d | d | d | d	 |  } t   ) z t  j |  } Wd
 |  j |  XWd
 QX| S(   sH  
        Evaluate python code `code` given as a string in the inferior and
        return the result as a gdb.Value. Returns a new reference in the
        inferior.

        Of course, executing any code in the inferior may be dangerous and may
        leave the debuggee in an unsafe state or terminate it altogether.
        s    s   String contains NUL byte.i    s-   Unable to obtain or create locals or globals.s   
            PyRun_String(
                (char *) %(code)d,
                (int) %(start)d,
                (PyObject *) %(globals)s,
                (PyObject *) %(locals)d)
        RW  R  t   globalst   localsN(   R   RE  RP  RF  R   t   FetchAndRestoreErrorR:  RR  (	   R1   RW  t
   input_typet   global_dictt
   local_dictR   t   globalspt   localspt   pyobject_return_value(    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt   evalcode
  s    	

N(   R   R   t   Py_single_inputt   Py_file_inputt   Py_eval_inputRN  RP  RT  RR  RU  RV  R7   R`  (    (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyRL  	  s   							RY  c           B  s)   e  Z d  Z d   Z d   Z d   Z RS(   sg   
    Context manager that fetches the error indicator in the inferior and
    restores it on exit.
    c         C  sw   t  j d  j   j |  _ |  j |  j d  |  _ |  j } |  j |  j } |  j |  j d } | | | f |  _ d  S(   NR9   i   i   (   R   R   R   R
   t   sizeof_PyObjectPtrRN  t   errstate(   R1   RQ   R  t	   traceback(    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR2   L
  s    	c         C  s   t  j d |  j  d  S(   Ns   PyErr_Fetch(%d, %d, %d)(   R   R:  Re  (   R1   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR  V
  s    c         G  sU   t  j d  r t  j d  n  d } z t  j | |  j  Wd  |  j |  j  Xd  S(   Ns   (int) PyErr_Occurred()s   PyErr_Print()sA   PyErr_Restore((PyObject *) *%d,(PyObject *) *%d,(PyObject *) *%d)(   R   R:  Re  RR  R   (   R1   R   t   pyerr_restore(    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR  Y
  s    (   R   R   R6   R2   R  R  (    (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyRY  F
  s   	
	t   FixGdbCommandc           B  s#   e  Z d    Z d   Z d   Z RS(   c         C  s/   t  t |   j | t j t j  | |  _ d  S(   N(   R   Rh  R2   R   R  R  t   actual_command(   R1   R  Ri  (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR2   j
  s    
c         C  sT   t  j d d t t j t   y t t j d   d k Wn t	 k
 rO n Xd S(   s  
        It seems that invoking either 'cy exec' and 'py-exec' work perfectly
        fine, but after this gdb's python API is entirely broken.
        Maybe some uncleared exception value is still set?
        sys.exc_clear() didn't help. A demonstration:

        (gdb) cy exec 'hello'
        'hello'
        (gdb) python gdb.execute('cont')
        RuntimeError: Cannot convert value to int.
        Error while executing Python code.
        (gdb) python gdb.execute('cont')
        [15148 refs]

        Program exited normally.
        t   ignores   .*s
   (void *) 0i    N(
   R  t   filterwarningst   RuntimeWarningR  t   escapeR   R   R   R:  RW   (   R1   (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt   fix_gdbo
  s    c         C  sa   |  j    y t j d |  j | f  Wn( t k
 rR } t j t |    n X|  j    d  S(   Ns   %s %s(   Rn  R   R  Ri  RW   RE  R'  (   R1   R   R  t   e(    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR  
  s    
(   R   R   R2   Rn  R  (    (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyRh  h
  s   		c         C  sj   t  j d  } t  j d  } t |  d k sB t |  d k rT t  j d   n  |  j | | | |  S(   s=   
    Execute Python code in the most recent stack frame.
    s   PyEval_GetGlobals()s   PyEval_GetLocals()i    si   Unable to find the locals or globals of the most recent Python function (relative to the selected frame).(   R   R:  RF  RE  R`  (   t   executorRW  RZ  R[  R\  (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt   _evalcode_python
  s
    $t   PyExecc           B  s   e  Z d    Z d   Z RS(   c         C  s   | r | t  j f Sg  } xR t rm y t d  } Wn t k
 rF Pq X| j   d k r] Pn  | j |  q Wd j |  t  j f Sd  S(   NR  R  s   
(	   RL  Ra  R   t   inputt   EOFErrorR   R&   R'   Rb  (   R1   t   exprt   linesR  (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt   readcode
  s    	c         C  s>   |  j  |  \ } } t   } | j t | | t t   d  S(   N(   Rw  RL  RV  Rq  R[  R\  (   R1   Ru  R  RZ  Rp  (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyR  
  s    	(   R   R   Rw  R  (    (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyRr  
  s   	s   set breakpoint pending onRE  s   -py-steps   -py-nexts	   py-finishs   py-runs   py-conts   py-execs   -py-execs1   Use gdb 7.2 or higher to use the py-exec command.i   i   i   i   i   i   i    i   @I       (    (   R6   t
   __future__R    R   R  t   localeR"   t   version_infoR%   R8  t   rangeR   R   RR   R   R   R   R   R   R7   RK  Rn   Rp   Rr   Rt   Rv   Rx   Rz   R|   t   Py_TPFLAGS_TYPE_SUBCLASSRe  R,  t   getpreferredencodingR   R|  RW   R   R   R   R   t   fsencodeR,   t   AttributeErrorR-   R]   R.   R8   RC   R   R   R   R   R   Ro   t	   ExceptionR   R}   Rh   R   R   Rl   R   R{   Rs   Rq   Rg   Ri   Rj   Rk   Rw   R.  Ru   RP   R7  RX  R<  Ry   Rm   R   Rc  Rd  Rj  Rm  t   current_objfileRn  R  R  R  R  R  Rt  R  R  R  R  R  R  R  R  R  R  t   FunctionR  R  R  R  R  R  R   R  R  R  R  R  R  R  R  R5  R6  R>  R  R  RA  RB  RC  RD  RF  RK  RL  RY  Rh  Rq  Rr  t   py_stept   py_nextt	   py_finisht   py_runt   py_contt   py_execR  t   _py_execR  (    (    (    s8   lib/python2.7/site-packages/Cython/Debugger/libpython.pyt   <module>0   s"  													BS!->,$				#		
		K	
 $

	
&						
,+				d")	