
     YHh                        d Z ddlZddlZddlZddlZddlZddlZ	 ddlmZ dZ		 ddlZddlZ eed      rdd	lmZ ndd
lmZ ddlmZ dZdZ eee      Z ej8                         xs dZdhdZd ZdidZ d Z!d Z"djdZ# G d d      Z$ G d d      Z% G d de%      Z&h dZ'd Z( G d d      Z) G d  d!      Z* G d" d#ejV                        Z, G d$ d%e,      Z- G d& d'e-      Z. G d( d)ej^                        Z0 G d* d+e0      Z1 G d, d-e0      Z2 G d. d/e0      Z3 G d0 d1      Z4 e4       Z5 G d2 d3ejl                  e)      Z7 G d4 d5e7      Z8 G d6 d7e7      Z9 G d8 d9e7      Z: G d: d;e)ejv                        Z< G d< d=e7ejz                        Z> G d> d?e>ej~                        Z@ G d@ dAe@      ZA G dB dCe>      ZB G dD dEe>      ZC G dF dGe>      ZD G dH dIe7      ZE G dJ dKeE      ZF G dL dMe7      ZG G dN dOe7      ZH G dP dQe7      ZI G dR dSe7      ZJdT ZK G dU dVe7      ZL G dW dXeL      ZM G dY dZ      ZN G d[ d\e7ej                  eN      ZP G d] d^e7      ZQ G d_ d`ej                  e)      ZS G da dbeS      ZT G dc ddej                  e)      ZU G de dfej                  e)eN      ZV e<       ZWe8j                         ZYeYeW_Y        dg ZZ eZ        y# e
$ r ddlmZ dZ	Y w xY w# e
$ r! dZej                   j#                  d       Y w xY w)kz)
GDB extension that adds Cython support.
    N)etreeT)ElementTreeFz,Install pygments for colorized source code.
string_to_argv)r   )split)	libpythonCObjectPythonObject)r   r	   zUTF-8c                       fd}|S )Nc                 H     t        j                         d fd	       }|S )Nc                     	 |xs t        j                         }r|j	                         
t                | |g|i |S # t        $ r t        j                  d      w xY wNzNo frame is currently selected.)gdbselected_frameRuntimeErrorGdbErrornameNoFunctionNameInFrameError)selfframeargskwargserrfunctions       R/var/www/html/planif/env/lib/python3.12/site-packages/Cython/Debugger/libcython.pywrapperz>default_selected_gdb_frame.<locals>.decorator.<locals>.wrapper/   so    F5!3!3!5 uzz|+022D%9$9&99   Fll#DEEFs   A A#N	functoolswraps)r   r   r   s   ` r   	decoratorz-default_selected_gdb_frame.<locals>.decorator.   s%    		"		: 
#		:      )r   r    s   ` r   default_selected_gdb_framer#   -   s     r!   c                 T     t        j                         t         fd              }|S )Nc                     |j                  d      xs t        j                         }| j                  |      st        j                  d       | g|i |S )Nr   zHSelected frame does not correspond with a Cython function we know about.)getr   r   is_cython_functionr   )r   r   r   r   r   s       r   r   z%require_cython_frame.<locals>.wrapper?   s]     

7#;s'9'9';&&u-,,  @ A A.t.v..r!   )r   r   require_running_programr   r   s   ` r   require_cython_framer*   >   s-    __X/  / Nr!   c                       fd}|S )Nc                 H     t        j                          fd       }|S )Nc                    | j                         }| j                         }|s|rs | g|i | y |rt        j                         y | j	                         rt        j                         y t        j
                  d      )NzFNot a function cygdb knows about. Use the normal GDB commands instead.)r'   is_python_functionr   executeis_relevant_functionr   )r   r   r   is_cyis_py	c_commandr   python_commands        r   r   z5dispatch_on_frame.<locals>.decorator.<locals>.wrapperL   sx    ++-E++-E~///N+**,I&ll $J K Kr!   r   )r   r   r3   r4   s   ` r   r    z$dispatch_on_frame.<locals>.decoratorK   s'    		"	K 
#	K r!   r"   )r3   r4   r    s   `` r   dispatch_on_framer5   J   s    " r!   c                 B     t        j                          fd       }|S )Nc                      	 t        j                           | i |S # t        $ r t        j                  d      w xY wr   )r   r   r   r   )r   r   r   s     r   r   z(require_running_program.<locals>.wrapper`   sJ    	B  (((  	B,,@AA	Bs    >r   r)   s   ` r   r(   r(   _   s%    __X) ) Nr!   c                 B     t        j                          fd       }|S )Nc                 r    t        |t        j                        r|j                         } | |g|i |S r   )
isinstancer   Valuestring)r   r<   r   r   r   s       r   r   z.gdb_function_value_to_unicode.<locals>.wrapperl   s3    fcii(]]_Ff6t6v66r!   r   r)   s   ` r   gdb_function_value_to_unicoder=   k   s%    __X7 7
 Nr!   c                     ddl }t        |j                   j                        j                        }|r |D cg c]  }|j                  ||       c}n|}d}|r6t        t               j                               }|D 	cg c]	  }	|	|vs|	 }}	d fd	}
dj                   j                  j                  ddj                   |
d||            d	g |
d
|            S c c}w c c}	w )a7  Prints out all instance variables needed to recreate an object.

    Following the python convention for __repr__, this function prints all the
    information stored in an instance as opposed to its class. The working
    assumption is that most initialization arguments are stored as a property
    using the same name.

    The object contents are displayed as the initialization call followed by,
    optionally, the value of each of the instance's properties in the form:
    ```
    ClassName(
            init_arg_1 = "repr of some example str",
            ...
        )
    self.state_based_property = ...
    ```

    Function arguments:
    self        Instance to be represented

    renamed     Dictionary of initialization arguments that are stored under a
                different property name in the form { argument: property }

    state       Boolean representing whether properties outside the
                initialization parameters should be printed (self.prop = ...).
                Using `False` may make the class more amenable to recursive repr
    r   Nr"   c              3      K   t        ||xs |      D ]5  \  }}t        t        |            j                  dd      }|  | d|  7 y w)N

		 = )zipreprgetattrreplace)prefixattrsr   attrargparamr   s         r   names_and_valuesz%simple_repr.<locals>.names_and_values   sX     UDME2 	-ID#t,-55dHEEHSEUG,,	-s   A
A (,rA   z
	)z
self.r   )inspecttuple	signature__init__
parametersr&   sortedvarskeysjoin	__class____qualname__)r   renamedstaterP   init_arg_namesrJ   
init_attrs
state_reprinstance_attrsrI   rL   s   `          r   simple_reprra   x   s    8 7,,T]];FFGN 4BBC'++c3'B* JT
 12'5PtZ9OdP
P-
 77NN''HH%h
NKL
 'y*=
   C
 Qs   C!	C&C&c                       e Zd Zd Zd Zy)CythonModulec                 f    || _         || _        || _        i | _        i | _        i | _        i | _        y r   )r   filename
c_filenameglobalslineno_cy2clineno_c2cy	functions)r   module_namere   rf   s       r   rS   zCythonModule.__init__   s5    	 $r!   c                 "    t        | ddid      S )Nrk   r   F)r[   r\   ra   r   s    r   __repr__zCythonModule.__repr__   s    4-)@NNr!   N__name__
__module__rZ   rS   ro   r"   r!   r   rc   rc      s    	Or!   rc   c                       e Zd Zd Zd Zy)CythonVariablec                 \    || _         || _        || _        || _        t	        |      | _        y r   )r   cnamequalified_nametypeintlineno)r   r   rv   rw   rx   rz   s         r   rS   zCythonVariable.__init__   s*    	
,	&kr!   c                     t        |       S r   rm   rn   s    r   ro   zCythonVariable.__repr__   s    4  r!   Nrp   r"   r!   r   rt   rt      s    "!r!   rt   c                   $     e Zd Zedf fd	Z xZS )CythonFunctionFalsec	                     t         	|   |||||       || _        || _        |dk(  | _        i | _        g | _        t               | _        y )NTrue)	superrS   modulepf_cnameis_initmodule_functionlocals	argumentssetstep_into_functions)
r   r   r   rv   r   rw   rz   rx   r   rY   s
            r   rS   zCythonFunction.__init__   sU     	-2-;-1-3		5
  &<&F##&5 r!   )rq   rr   rZ   r   rS   __classcell__rY   s   @r   r}   r}      s     (/) )r!   r}   >   Frame.pc
Frame.name
Frame.typeFrame.blockFrame.levelFrame.newerFrame.olderFrame.selectSymbol.valueFrame.find_salFrame.functionFrame.is_validFrame.languageSymbol.is_validSymtab.fullnameSymtab.is_validSymtab.linetableFrame.static_linkFrame.architectureSymtab.global_blockSymtab.static_blockSymtab_and_line.is_validc                    |  d}t        t        |             D ]  }|j                  d      rt        | |      }t	        |      r|j
                  t        v r |       }t        |      t        j                  t        j                  t        j                  fv r*t        |      j                  d      j                  dd      }|| dt        |t               r|dk7  r|ddn| dz   z  } |S )a  Returns a string representing the internal state of a provided GDB frame
    https://sourceware.org/gdb/current/onlinedocs/gdb.html/Frames-In-Python.html

    Created to serve as GDB.Frame.__repr__ for debugging purposes. GDB has many
    layers of abstraction separating the state of the debugger from the
    corresponding source code. This prints a tree of instance properties,
    expanding the values for Symtab_and_line, Symbol, and Symtab.

    Most of these properties require computation to determine, meaning much of
    relevant info is behind a monad, a subset of which are evaluated.

    Arguments
    frame       The GDB.Frame instance to be represented as a string
    r@   __z
	: linex)rU   dir
startswithrE   callablerZ   frame_repr_whitelistrx   r   Symtab_and_lineSymbolSymtab
frame_reprrstriprF   r:   ry   )r   res	attributevalues       r   r   r      s     G2,CCJ' #	%y)E?u115IIGE;3..

CJJGGu%,,T2::4HE)B",UC"8Y&=P5)2wb\# 	## Jr!   c                   8   e Zd Z ed      d        Z ed      d        Z e       d        Z e       d        Z e       d        Z e       d        Z	 e       d	        Z
 e       d
        Z e       d        Z ed      dd       Zd Zd ZddZd Zy)
CythonBaseF)r   c                 N    |j                         | j                  j                  v S r   )r   cyfunctions_by_cnamer   r   s     r   r'   zCythonBase.is_cython_function  s    zz|tww9999r!   c                     |j                         dk(  r8t        j                  |      j                         }|xr |j	                          S y)z
        Tells if a frame is associated with a Python function.
        If we can't read the Python frame information, don't regard it as such.
        PyEval_EvalFrameExF)r   r   Frameget_pyopis_optimized_out)r   r   pyframes      r   r.   zCythonBase.is_python_function  sD     ::<//ooe,557G=7#;#;#===r!   c                 "    |j                         S r   )r   r   s     r   get_c_function_namezCythonBase.get_c_function_name(  s    zz|r!   c                 6    |j                         j                  S r   )find_salr   r   s     r   get_c_linenozCythonBase.get_c_lineno,  s    ~~$$$r!   c                     | j                   j                  j                  |j                               }|
t	               |S r   )r   r   r&   r   NoCythonFunctionInFrameError)r   r   results      r   get_cython_functionzCythonBase.get_cython_function0  s5    ++//

=>.00r!   c                     | j                  |      }|j                  j                  j                  | j	                  |      d      S )z
        Get the current Cython line number. Returns ("<no filename>", 0) if there is no
        correspondence between the C and Cython code.
        )z<no filename>r   )r   r   ri   r&   r   )r   r   cyfuncs      r   get_cython_linenozCythonBase.get_cython_lineno8  s=     ))%0}}((,,T->->u-EG[\\r!   c                 *   d x}x}}| j                  |      rn| j                  |      j                  j                  }| j	                  |      }||d   k(  sJ |d   }t
        r#t
        j                  j                  d      }n| j                  |      rt        j                  |      j                         }|st        j                  d      |j                         }|j                         }t
        rt
        j                  j                  d      }no|j!                         }|r|j"                  sd }d}nL|j"                  j%                         }|j&                  }t
        r t
        j                  j)                  d      }t+        ||      |fS )Nr      F)stripallz*Unable to read information on python frame)r'   r   r   re   r   pygmentslexersCythonLexerr.   r   r   r   r   r   current_line_numPythonLexerr   symtabfullnamer   CLexerSourceFileDescriptor)r   r   re   rz   lexerfilename_and_linenopyframeobjectsymbol_and_line_objs           r   get_source_desczCythonBase.get_source_descA  sh   $(((6E""5)//6==FFH"&"8"8"?215555(+F 33U3C$$U+%OOE2;;=M llHJ J %--/H"335F 33U3C"'.."2&.A.H.H.55>>@,11$OO22E2BE#He4f<<r!   c                 J    | j                         \  }}|j                  |      S r   )r   
get_source)r   r   source_descrz   s       r   get_source_linezCythonBase.get_source_lined  s&    "224V%%f--r!   c                     |j                         }|j                         }| j                  |      s| j                  |      ry|r0| j                  |      r| j	                  |      }||j
                  v S y)zl
        returns whether we care about a frame on the user-level when debugging
        Cython code
        TF)r   olderr'   r.   r   r   )r   r   r   older_framecython_funcs        r   r0   zCythonBase.is_relevant_functioni  sl     zz|kkm""5)T-D-DU-KT44[A22;?K;::::r!   c                 R    t        j                         }j                          	  j                        \  }}|sk j                        rZt        j                        j                         }||j                         r j                  |d      S |j                  }d}	g }
nk j                        r2 j                        } fd}|j                  }|j                   }	g }
n( j                        \  }}j                         }|}	g }
	 t        j"                  |	      }|j$                  }t'        |t(              s?t'        |t*        t,        f      st+        |      }t)        |j/                         d   d      }	 dj3                  d	 |
D              }t4        j6                  j9                  d
||||fz         |j:                  /t4        j6                  j9                  d|j:                  d|       t4        j6                  j9                  d       	 t4        j6                  j9                  d|j=                  |       d       |j                          y# t        $ r t        d|z         Y yw xY w# t0        $ r d}Y w xY w# t         j>                  $ r Y Uw xY w)zk
        Print a C, Cython or Python stack frame and the line of source code
        if available.
        z%#%-2d Unknown Frame (compile with -g)NT)is_cr   c                 R    j                   j                  j                  |       S )Nr   )r   	cy_cvalueinvoke)rJ   r   r   s    r   <lambda>z-CythonBase.print_stackframe.<locals>.<lambda>  s!    DGG--44S4F r!   r   z, c              3   0   K   | ]  \  }}|d |  yw)=Nr"   ).0r   vals      r   	<genexpr>z.CythonBase.print_stackframe.<locals>.<genexpr>  s     G	cs+Gs   z#%-2d 0x%016x in %s(%s)z at :r@       ) r   r   selectr   r   printr.   r   r   r   r   print_stackframeco_namer'   r   r   rv   parse_and_evaladdressr:   ry   strbytesr   r   rX   sysstdoutwritere   r   r   )r   r   indexr   r   r   rz   r   	func_name
func_cname	func_argsr   f	gdb_valuefunc_addressas   ``              r   r   zCythonBase.print_stackframez  sV    ++-	"&"6"6u"=K
 //6ooe,557G'":":"<,,UE,EEI-JI$$U+--e4FFAIJI"&"6"6u"=K

I"JI
	?**:6I %,,LlC0!,e=#&|#4L"<#5#5#7#:A>IIGYGG

2e\9VW5XXY+JJK,@,@&IJ

	JJtK$:$:6$B#C2FG 	g * 	9EAB	8  	L	( || 		s5   I! I> 2J !I;:I;>JJJ&%J&c                 
   t        j                  d      }	 t        j                  d      }|j                  |j                               }|d   S # t        $ r) t        j                  t        j                  d            w xY w)N__pyx_mPyModuleObjectzy                Unable to lookup type PyModuleObject, did you compile python
                with debugging support (-g)?md_dict)	r   r   lookup_typer   r   textwrapdedentcastpointer)r   mr  s      r   get_remote_cython_globals_dictz)CythonBase.get_remote_cython_globals_dict  s{    y)	2 __-=>N FF>))+,|  	2,,x 00  1 2 2	2s   A 2Bc                     | j                         }t        j                  j                  |      }i }t	               }|j                         D ]  \  }}|||j                  |      <    |S )zk
        Get the Cython globals dict where the remote names are turned into
        local strings.
        )r  r   PyObjectPtrfrom_pyobject_ptrr   	iteritemsproxyval)r   remote_dictpyobject_dictr   seenkvs          r   get_cython_globals_dictz"CythonBase.get_cython_globals_dict  sj    
 99;!--??Lu!++- 	)DAq'(F1::d#$	) r!   Nc                     t        j                  |      rd}nd|j                  d}|t        ||d||       y t        d|||||fz         y )NrM   rN   z) rB   z%s%-*s = %s%s)r   pretty_printer_lookuprx   r   )r   r   r   max_name_lengthrG   typenames         r   print_gdb_valuezCythonBase.print_gdb_value  sW    **51H 2 #(**.H"645AB/V_dHe$TTUr!   c                    |j                   |   }| j                         d   }d|j                  v rL||j                  kD  r<|j                  t
        k(  r(t        t        j                  |j                              S yy||j                  kD  S )Nr   z->TF)	r   r   rv   rz   rx   r	   ry   r   r   )r   r   
local_namecyvar
cur_linenos        r   is_initializedzCythonBase.is_initialized  sz    "":.++-a0
5;;K...::-s11%++>??ELL((r!   )F)NrM   )rq   rr   rZ   r#   r'   r.   r   r   r   r   r   r   r0   r   r  r  r  r#  r"   r!   r   r   r     s   E*: +:  E* +  ! "  !% "%  ! "  !] "]  ! = " =D  !. ".  ! "   E*?  +? B	V)r!   r   c                   2    e Zd ZddZd Zd Zd Z	 	 ddZy)	r   Nc                 .    || _         || _        || _        y r   )re   r   	formatter)r   re   r   r&  s       r   rS   zSourceFileDescriptor.__init__  s     
"r!   c                     | j                   d uS r   )re   rn   s    r   validzSourceFileDescriptor.valid  s    }}D((r!   c                 2   t         r| j                  rt        j                  rtt        j                  j
                  }| j                  !t         j                  j                  |      }n| j                  }t        j                  || j                  |      S |S )N)bg)
r   r   rT   colorize_codeterminal_backgroundr   r&  
formattersTerminalFormatter	highlight)r   coder*  r&  s       r   lexzSourceFileDescriptor.lex  sn    

z'?'?//55B~~%$//AARAH	 NN	%%dDJJ	BBr!   c              #     K   t        | j                        5 }|r/|r-| j                  |j                               j	                         }t        j                  ||dz
  |dz
        }t        |      D ]B  \  }}	||z   |k(  rd}
nd}
|r|s| j                  |	      }	d|
||z   |	j                         fz   D 	 d d d        y # 1 sw Y   y xY ww)Nr   > z%s %4d    %s)	openre   r1  read
splitlines	itertoolsislice	enumerater   )r   startstop
lex_source	mark_line
lex_entirer   sliceidxr   rG   s              r   _get_sourcez SourceFileDescriptor._get_source  s     $--  	LA
 jHHQVVX&113$$Q	4!8<E&u- 	L	T3;)+ F Fj88D>D$T[[]'KKK	L	L 	L 	Ls   CBC8	CC
Cc           	          t        j                  d      }| j                  s|t        |d      }||dz   }	 dj	                  | j                  |||||            S # t        $ r |w xY w)NzUnable to retrieve source coder   r@   )r   r   re   maxrX   rB  OSError)r   r;  r<  r=  r>  r?  excs          r   r   zSourceFileDescriptor.get_source  sx    ll;<}}IE1<19D	99  j)ZPR R 	I	s   #A A(r   )NTr   F)rq   rr   rZ   rS   r(  r1  rB  r   r"   r!   r   r   r     s&    #
)
L, GH#r!   r   c                   "     e Zd ZdZ fdZ xZS )
CyGDBErrorz6
    Base class for Cython-command related errors
    c                 @    |xs | j                   f}t        |   |  y r   )msgr   rS   )r   r   rY   s     r   rS   zCyGDBError.__init__7  s     "{$r!   )rq   rr   rZ   __doc__rS   r   r   s   @r   rH  rH  2  s       r!   rH  c                       e Zd ZdZdZy)r   z]
    raised when the user requests the current cython function, which is
    unavailable
    z7Current function is a function cygdb doesn't know aboutNrq   rr   rZ   rK  rJ  r"   r!   r   r   r   <  s     DCr!   r   c                       e Zd ZdZdZy)r   zi
    raised when the name of the C function could not be determined
    in the current C stack frame
    zDC function name could not be determined in the current C stack frameNrM  r"   r!   r   r   r   D  s    Cr!   r   c                   .     e Zd ZdZd fd	Zd ZeZ xZS )CythonParameterz*
    Base class for cython parameters
    c                     | j                   j                  x| _        | _        t        |   |||       ||| _        y y r   )rY   rK  show_docset_docr   rS   r   )r   r   command_classparameter_classdefaultrY   s        r   rS   zCythonParameter.__init__T  sA    '+~~'='==}.=	? DJ r!   c                 ,    t        | j                        S r   )boolr   rn   s    r   __bool__zCythonParameter.__bool__[  s    DJJr!   r   )rq   rr   rZ   rK  rS   rY  __nonzero__r   r   s   @r   rP  rP  O  s    !  Kr!   rP  c                       e Zd ZdZy) CompleteUnqualifiedFunctionNameszH
    Have 'cy break' complete unqualified function or method names.
    Nrq   rr   rZ   rK  r"   r!   r   r\  r\  b      r!   r\  c                       e Zd ZdZy)ColorizeSourceCodez5
    Tell cygdb whether to colorize source code.
    Nr]  r"   r!   r   r`  r`  h  r^  r!   r`  c                       e Zd ZdZy)TerminalBackgroundzJ
    Tell cygdb about the user's terminal background (light or dark).
    Nr]  r"   r!   r   rb  rb  n  r^  r!   rb  c                       e Zd ZdZd Zy)CythonParametersz
    Simple container class that might get more functionality in the distant
    future (mostly to remind us that we're dealing with parameters).
    c                    t        dt        j                  t        j                  d      | _        t        dt        j                  t        j                  d      | _        t        dt        j                  t        j                  d      | _
        y )Ncy_complete_unqualifiedTcy_colorize_codecy_terminal_background_colordark)r\  r   COMMAND_BREAKPOINTSPARAM_BOOLEANcomplete_unqualifiedr`  COMMAND_FILESr+  rb  PARAM_STRINGr,  rn   s    r   rS   zCythonParameters.__init__z  su    $D%##	%!
 0	
 $6*	$ r!   N)rq   rr   rZ   rK  rS   r"   r!   r   rd  rd  t  s    
r!   rd  c                   H    e Zd ZdZej
                  Zed        Zed        Z	y)CythonCommandz(
    Base class for Cython commands
    c                     t        | d      s | || j                  g|i |S  | || j                  | j                  g|i |S )Ncompleter_class)hasattrrT  rr  )clsclsnamer   r   s       r   	_registerzCythonCommand._register  sY    s-.w 1 1CDCFCCw 1 133F3F (( &( (r!   c                     t        | dd       }|r| j                  | j                  ||       | j                  | j                  ||      S )Nalias)rE   rv  rx  r   )rt  r   r   rx  s       r   registerzCythonCommand.register  s>    Wd+MM#))T62}}SXXtV44r!   N)
rq   rr   rZ   rK  r   COMMAND_NONErT  classmethodrv  ry  r"   r!   r   rp  rp    s:     $$M( ( 5 5r!   rp  c                   V     e Zd ZdZdZej                  Zej                  Z	 fdZ
 xZS )CyCyaa  
    Invoke a Cython command. Available commands are:

        cy import
        cy break
        cy step
        cy next
        cy run
        cy cont
        cy finish
        cy up
        cy down
        cy select
        cy bt / cy backtrace
        cy list
        cy print
        cy set
        cy locals
        cy globals
        cy exec
    r   c           	      j   t         t        |   |||d       t        di dt        j                         dt        j                         dt        j                         dt        j                         dt        j                         dt        j                         d	t        j                         d
t        j                         dt        j                         dt        j                         dt        j                         dt         j                         dt"        j                         dt$        j                         dt&        j                         dt)        j*                  dd      dt,        j                         dt.        j                         dt1        d      dt3        d      dt5        d      dt7        d      }|j9                         D ]  \  }}| |_        t=        | ||        | | _        i | _        i | _         i | _!        tE        jF                  tH              | _%        y )NT)rG   import_break_stepnextruncontfinishupdownr   btlistprint_r   rg   exec_zcy exec-cy-exec_execr   cy_cnamer   	cy_linenocy_evalr"   )&r   rp  rS   dictCyImportry  CyBreakCyStepCyNextCyRunCyContCyFinishCyUpCyDownCySelectCyBacktraceCyListCyPrintCyLocals	CyGlobalsr   FixGdbCommandCyExecCySetCyCNameCyCValueCyLineCyEvalitemsr   setattrcython_namespacefunctions_by_qualified_namer   collectionsdefaultdictr  functions_by_name)r   r   rT  rr  commandscommand_namecommandrY   s          r   rS   zCyCy.__init__  s   mT+D-,;D 	, 	J  
'')
 %%'
 ??$	

 ??$
 .."
 ??$
 &&(
 
 ??$
 &&(
 %%'
 ??$
 %%'
 &&(
   ((*!
" ++IzB#
$ OO%%
& .."'
, z*-
. !-/
0 {+1
2 Y'3
8 &.^^%5 	1!L'GJD,0	1  !# ,.( #% "-!8!8!>r!   )rq   rr   rZ   rK  r   r   rz  rT  COMPLETE_COMMANDrr  rS   r   r   s   @r   r}  r}    s/    , D$$M**O3? 3?r!   r}  c                   h    e Zd ZdZdZej                  Zej                  Z	e
j                  d        Zy)r  zb
    Import debug information outputted by the Cython compiler
    Example: cy import FILE...
    z	cy importc           
      l   t        |t              r|j                  t              }t	        |      D ]  }	 t        |      }t        j                  |      }|j                         D ]  }t        di |j                  }|| j                  j                   |j"                  <   |j%                  d      D ])  }	|	j                  }
t'        di |
|j(                  |
d   <   + |j%                  d      D ]_  }t+        dd|i|j                  }|j"                  }|j,                  }| j                  j.                  |   j1                  |       || j                  j2                  |j,                  <   || j                  j4                  |j6                  <   |x}
|j8                  |<   |j%                  d      D ])  }|j                  }
t'        di |
|j:                  |
d   <   + |j%                  d	      D ],  }|j                  }
|j<                  j?                  |
d          . |j@                  jC                  d
 |j%                  d      D               b |j%                  d      D ]  }tE        |j                  d         }|j                  d   }tG        tI        tD        |j                  d   jK                                     }tM        |      |jN                  ||f<   |D ]  }||f|jP                  |<       y # t        $ r-}t        j                  d|d|j                  d         d }~ww xY w)NzUnable to open file r   r   Globalsr   	Functionsr   LocalsStepIntoFunctionsc              3   4   K   | ]  }|j                     y wr   )tag)r   funcargs     r   r   z"CyImport.invoke.<locals>.<genexpr>/  s      5O(/5Os   	ArgumentsLineNumberMapping
src_linenosrc_path	c_linenosr"   ))r:   r   decode_filesystemencodingr   r5  rE  r   r   r   r   parsegetrootrc   attribr   r  r   findrt   rg   r}   rw   r  appendr  r   rv   rj   r   r   addr   extendry   r  mapr   minrh   ri   )r   r   from_ttyrJ   r   etr   cython_modulevariabledr   cython_functionr   qnamelocalstep_into_funcmarkerr  r  r  c_linenos                         r   r   zCyImport.invoke  s   dE";;23D!$' 1	UCUI AA))+ )U , =v}} =?L((););< &I 6 KH A7E7J7JM))!F)4K !'K 8 OH&4 'HM 'H7?'HO +//D+::EGG--d3::?K:I GG77'668 2A GG..'--/ :IHA//6!)x!8 P!LL<J<OQ<O..qy9P +3--8K*L K*11';;??&	JK $--44 5O3;==3M5O O1O6 %kk*=> UF!$V]]<%@!AJ%}}Z8H $SfmmK.H.N.N.P%Q RIFI)nM--h
.BC$- U?G>T11(;UUG)U1	U  Ull4PQ#STTUs   K==	L3(L..L3N)rq   rr   rZ   rK  r   r   COMMAND_STATUSrT  COMPLETE_FILENAMErr  r   dont_suppress_errorsr   r"   r!   r   r  r    s>    
 D&&M++O##4U $4Ur!   r  c                       e Zd ZdZdZej                  Zd Zd Z	e
j                  d        Ze
j                  d        Zy)r  a  
    Set a breakpoint for Cython code using Cython qualified name notation, e.g.:

        cy break cython_modulename.ClassName.method_name...

    or normal notation:

        cy break function_or_method_name...

    or for a line number:

        cy break cython_module:lineno...

    Set a Python breakpoint:
        Break on any function or method named 'func' in module 'modname'

            cy break -p modname.func...

        Break on any function or method named 'func'

            cy break -p func...
    zcy breakc                    |j                  d      \  }}}t        |      }|r| j                  j                  |   }n| j	                         j
                  }|j                  |f|j                  v rE|j                  |j                  |f   }|j                  d|}t        j                  d|z          y t        j                  d      )Nr   break z5Not a valid line number. Does it contain actual code?)	partitionry   r   r  r   r   re   rh   rf   r   r/   r   )r   r   
modulename_rz   r  r  
breakpoints           r   
_break_pyxzCyBreak._break_pyxV  s     $s 3
AvV GG44Z@M 446==M""F+}/H/HH$001G1G1OPH$1$<$<hGJKK:-.,,  > ? ?r!   c                    | j                   j                  j                  |      }|r|j                  rd }|g}|s0| j                   j                  j                  |      xs g }|D cg c]  }|j                  r| }}|st        j                  d|z          y t        |      dkD  rt        d       t        |      D ]  \  }}t        d||j                  fz         ! 	 	 t        d      }|j                         dk(  ry |j                         dk(  r|}nS|j                         r0dt        |      cxk  rt        |      k  rn n|t        |         g}nt        d	       	 |d   g}|D ]S  }t        j                  d
|j                   z         |j"                  s2t        j                  d
|j"                  z         U y c c}w # t        $ r Y y w xY w)Nr  r   z"There are multiple such functions:z%3d) %szMSelect a function, press 'a' for all functions or press 'q' or '^D' to quit: qr  r   zNot understood...zbreak %s)r   r  r&   r   r  r   r/   lenr   r:  rw   inputlowerisdigitry   EOFErrorrv   r   )r   funcnamefuncbreak_funcsfuncsr   rA  r   s           r   _break_funcnamezCyBreak._break_funcnamef  s   ww2266x@D//DfGG--11(;ArE %F1Q-E-EQFEFHx/05zA~:;!*5!1 BIC)sD,?,?&@@AB 7!&G"H "<<>S0"#\\^s2*/K!$nn. !S[ =3u: =+0V+=*>K!!"56% (  %Qxj 	8DKK
TZZ/0}}J67	8E G" $ s   )G;G$G
 
	GGc                 ,   t        |t              r|j                  t              }t	        |      }|j                  d      r|dd  }d}nd}|D ]D  }|rt        j                  d|z         d|v r| j                  |       4| j                  |       F y )Nz-pr   TFzpy-break %sr   )
r:   r   r  r  r   r   r   r/   r  r  )r   function_namesr  argvpython_breakpointsr  s         r   r   zCyBreak.invoke  s    ne,+223FGNn-$$T*8D!%!& 	/H!MH45)$$X.	/r!   c                 ^   |xs d}| j                   j                  j                         D cg c]  \  }}t        d |D              r| }}}| j                   j                  j                         D cg c]  \  }}|j
                  s| }}}t        j                  rt        j                  ||      }n|}|j                         j                         }	|	rd|	d   vrKt        |d t        |        j                               }
|D cg c]  }|j                  |      r||
vr| c}S |	d   }|D cg c]  }|j                  |      s| }}t        |      t        |      kD  r)t        |      t        |      z
  }|D cg c]  }||d  	 }}|S c c}}w c c}}w c c}w c c}w c c}w )NrM   c              3   6   K   | ]  }|j                      y wr   )r   )r   r   s     r   r   z#CyBreak.complete.<locals>.<genexpr>  s     A!Q555As   .)r   r  r  anyr  r   rT   rl  r8  chainstripr   r   r  r   )r   textwordnLnamesr   qnames	all_nameswordsr  lastwordcomplstrip_prefix_lengths                 r   completezCyBreak.complete  s    zr !% 9 9 ? ? A C1AqAA  C C $ C C I I K 3111  3 3 **!6II

""$59,tKc$iZ(..01D( C!\\$/ATM  C C 9"=qall8&<==x=3t9$ #&h-#d)";6;<Q*+,<E<7C3C
 > =s#   F6FF 5F%F%F*N)rq   rr   rZ   rK  r   r   rj  rT  r  r  r   r  r   r  r"   r!   r   r  r  ;  sX    . D++M? /8b ##/ $/$ ##  $ r!   r  c                   B     e Zd ZdZ fdZ fdZ fdZd Zd Z xZ	S )
CythonInfozM
    Implementation of the interface dictated by libpython.LanguageInfo.
    c                 l    | j                  |      r| j                  |      d   S t        |   |      S Nr   )r'   r   r   rz   r   r   rY   s     r   rz   zCythonInfo.lineno  s8    
 ""5)))%033w~e$$r!   c                 ~    	 t         |   |      }|j                         xs d S # t        j                  $ r Y y w xY wr   )r   r   r  r   r   )r   r   r   rY   s      r   r   zCythonInfo.get_source_line  sB    	(7*51D ::<'4' || 		s   & <<c                 <    | j                   rt        | 	  |      S y r   )r.   r   exc_infor
  s     r   r  zCythonInfo.exc_info  s!    ""7#E** #r!   c                 X    | j                         r| j                         j                  S y)Nr"   )r'   r   r   rn   s    r   runtime_break_functionsz"CythonInfo.runtime_break_functions  s&    ""$++-AAAr!   c                 V    dg}|j                  | j                  j                         |S )Nr   )r  r   r   )r   r   s     r   static_break_functionsz!CythonInfo.static_break_functions  s%    &'dgg001r!   )
rq   rr   rZ   rK  rz   r   r  r  r  r   r   s   @r   r  r    s!    %(+
r!   r  c                       e Zd Zed        Zy)CythonExecutionControlCommandc                 0     | | j                   t              S r   )r   cython_info)rt  s    r   ry  z&CythonExecutionControlCommand.register  s    388[))r!   N)rq   rr   rZ   r{  ry  r"   r!   r   r  r    s     * *r!   r  c                   <    e Zd ZdZdZdZej                  d        Zy)r  z&Step through Cython, Python or C code.zcy -stepTc                 $   | j                         r| j                  | j                         y | j                         s8| j                  rd}nd}| j	                  t        j                  |d             y | j                  | j                         y )Nr  r  T	to_string)stepinto)r.   python_stepr  r'   finish_executingr   r/   r  )r   r   r  r  s       r   r   zCyStep.invoke  sh    ""$T]]+((*}}  !!#++g"FGIIt}}I-r!   N)	rq   rr   rZ   rK  r   r  r   r  r   r"   r!   r   r  r    s'    ,DH##. $.r!   r  c                       e Zd ZdZdZdZy)r  z#Step-over Cython, Python or C code.zcy -nextFN)rq   rr   rZ   rK  r   r  r"   r!   r   r  r    s    )DHr!   r  c                   L    e Zd ZdZdZ ej                  ej                        Z	y)r  z
    Run a Cython program. This is like the 'run' command, except that it
    displays Cython or Python source lines as well
    zcy runN)
rq   rr   rZ   rK  r   r   r  r  r  r   r"   r!   r   r  r    s'    
 D+Y++,I,M,MNFr!   r  c                   L    e Zd ZdZdZ ej                  ej                        Z	y)r  z
    Continue a Cython program. This is like the 'run' command, except that it
    displays Cython or Python source lines as well.
    zcy contN)
rq   rr   rZ   rK  r   r   r  r  r  r   r"   r!   r   r  r  "  s'    
 D+Y++,I,N,NOFr!   r  c                   L    e Zd ZdZdZ ej                  ej                        Z	y)r  z-
    Execute until the function returns.
    z	cy finishN)
rq   rr   rZ   rK  r   r   r  r  r  r   r"   r!   r   r  r  ,  s'     D+Y++,I,P,PQFr!   r  c                   <    e Zd ZdZdZdZej                  d        Zy)r  z5
    Go up a Cython, Python or relevant C frame.
    zcy upr  c                    	 t        j                  | j                  d       | j                  t        j                               sEt        j                  | j                  d       | j                  t        j                               sEt        j                         }d}|r|j                         }|dz  }|r| j                  |dz
         y # t
        $ r!}t        j                  |j                   d }~ww xY w)NTr  r   r   )r   )
r   r/   _commandr0   r   r   r   r   r   r   )r   r   r  r   r   s        r   r   zCyUp.invoke<  s    	(KK6//0B0B0DEDMMT: //0B0B0DE
 ""$KKMEQJE  	EAI.  	(,,''	(s   BC 	C;C66C;N)	rq   rr   rZ   rK  r   r#  r   r  r   r"   r!   r   r  r  5  s+     DH##/ $/r!   r  c                       e Zd ZdZdZdZy)r  z7
    Go down a Cython, Python or relevant C frame.
    zcy downr  N)rq   rr   rZ   rK  r   r#  r"   r!   r   r  r  N  s     DHr!   r  c                   8    e Zd ZdZdZej                  d        Zy)r  z
    Select a frame. Use frame numbers as listed in `cy backtrace`.
    This command is useful because `cy backtrace` prints a reversed backtrace.
    z	cy selectc                    	 t        |      }t        j                         }|j                         r!|j                         }|j                         r!t        j                  |      }	 t        j                  d||z
  dz
  fz         y # t        $ r t        j                  d|      w xY w# t        $ r!}t        j                  |j                   d }~ww xY w)NzNot a valid number: z	select %dr   )ry   
ValueErrorr   r   r   newerr   
stackdepthr/   r   r   )r   stacknor  r   r)  r  s         r   r   zCySelect.invoke_  s    	F'lG ""$kkmKKME kkm ))%0
	(KKzG';a'?&AAB  	F,,7DEE	F  	(,,''	(s#   B (B- "B*-	C6CCN)rq   rr   rZ   rK  r   r   r  r   r"   r!   r   r  r  W  s&    
 D##( $(r!   r  c                   v    e Zd ZdZdZdZej                  Zej                  Z
ej                  ed               Zy)r  zPrint the Cython stackzcy btzcy backtracec                 D   t        j                         }|j                         r!|j                         }|j                         r!|dk(  }d}|rA	 | j                  |      }|s|r| j                  ||       |dz  }|j                         }|r@y y # t        $ r d}Y =w xY w)Nz-ar   Fr   )r   r   r   r0   rH  r   r(  )r   r   r  r   	print_allr   is_relevants          r   r   zCyBacktrace.invokez  s     ""$kkmKKME kkm DL	$"77> K%%eU3QJEKKME   $#$s   B BBN)rq   rr   rZ   rK  r   rx  r   COMMAND_STACKrT  COMPLETE_NONErr  r   r  r(   r   r"   r!   r   r  r  r  sE    DE%%M''O##"  $"r!   r  c                   h    e Zd ZdZdZej                  Zej                  Z	e
j                  d        Zy)r  za
    List Cython source code. To disable to customize colouring see the cy_*
    parameters.
    zcy listc                 v    | j                         \  }}|j                  |dz
  |dz   |d      }t        |       y )N   T)r>  r?  )r   r   r   )r   r  r  sdrz   sources         r   r   zCyList.invoke  sA     ))+
Fvz6A:*.  0fr!   N)rq   rr   rZ   rK  r   r   rm  rT  r0  rr  r   r  r   r"   r!   r   r  r    s<    
 D%%M''O## $r!   r  c                   V    e Zd ZdZdZej                  Zej                  d        Z
d Zy)r  zT
    Print a Cython variable using 'cy-print x' or 'cy-print module.function.x'
    zcy printc                 ,   | j                         }| j                         j                  j                  }||v r3||   j	                  t
        j                        }t        |d|       y ||v rS||   j                  }	 t        j                  |      }|j                  s| j                  ||       y t        d|z         y | j                         rt        j                  d|z         S | j!                         re| j"                  j$                  j'                  |j)                  d            }|D ]  }|dk(  r|j+                         } n | j                  ||       y t        j                  d|z          y # t        $ r t        d|z         Y y w xY w)NrB   z%s is optimized outzunable to get value of %sz	py-print *zprint )r  r   r   rg   get_truncated_reprr   MAX_OUTPUT_LENr   rv   r   r   r   r  r   r.   r/   r'   r   r   r   lstripdereference)r   r   r  global_python_dictmodule_globalsr   rv   cs           r   r   zCyPrint.invoke  sk   !99;113::BB%%&t,??	@X@XYEtU+, ^#"4(..E8**51 --((u5/$67$$&;;{T122$$&GG%%,,T[[-=>E 8!--/E	   u-KK4('   :1D89:s    E9 9FFc                     | j                         rC| j                         }t        t        j                  |j
                  |j                              S g S r   )r'   r   r  r8  r  r   rg   )r   r   s     r   r  zCyPrint.complete  s?    ""$((*A	!))<==Ir!   N)rq   rr   rZ   rK  r   r   COMMAND_DATArT  r   r  r   r  r"   r!   r   r  r    s7     D$$M## ) $ )Dr!   r  c                 (    | d   j                         S )Nr   )r  )items    r   r   r     s    tAw}} r!   c                       e Zd ZdZdZej                  Zej                  Z	e
j                   edd      d               Zy)r  z8
    List the locals from the current Cython frame.
    z	cy localszinfo localsz	py-localsr3   r4   c                    | j                         }|j                  r'| j                  j                  j	                  ||       y |j
                  }t        t        |t                    }t        |j                         t              D ]z  \  }}| j                  | j                         |j                        s1t        j                  |j                        }|j                   r]| j#                  |j                  ||d       | y )NkeyrM   )r   r   r   rg   r   r   r  rD  rU   r  sortkeyr#  r   r   r   rv   r   r  )	r   r   r  r  local_cython_varsr  r   r!  r   s	            r   r   zCyLocals.invoke  s     22411GGOO""42+22c"3=>!"3"9"9";I 	>KD%""4#;#;#=uzzJ**5;;7--((U)8">		>r!   Nrq   rr   rZ   rK  r   r   r/  rT  r0  rr  r   r  r5   r   r"   r!   r   r  r    sL     D%%M''O##{K> L $>r!   r  c                       e Zd ZdZdZej                  Zej                  Z	e
j                   edd      d               Zy)r  z:
    List the globals from the current Cython module.
    z
cy globalszinfo variablesz
py-globalsrE  c                    | j                         }| j                         j                  j                  }d}d}|rt	        t        |t                    }|rt	        t        |            }t        ||      }t               }t        d       t        |j                         t              D ]F  \  }	}
|
j                  t        j                        }
|j                  |	       t        d||	|
fz         H t        d       t        |j                         t              D ]U  \  }}||vs	 t        j                   |j"                        }|j$                  r8| j'                  |j(                  ||d       W y # t*        $ r Y dw xY w)Nr   rG  zPython globals:z    %-*s = %sz
C globals:r   )r  r   r   rg   r  rD  r   r   rU   r  rI  r9  r   r:  r  r   r   rv   r   r  r   r   )r   r   r  r=  r>  max_globals_lenmax_globals_dict_lenr  r  r  r  r   r!  r   s                 r   r   zCyGlobals.invoke   sb    "99;113::BB !#n#">?O#&s+='>#? o/CDu -3357C 	=DAq$$Y%=%=>AHHQK/_a$;;<	=
 	l!."6"6"8gF 		FKD%4F..u{{;E !11,,UZZ-<fF		F $ s   *E77	FFNrK  r"   r!   r   r  r    sO     D%%M''O##!1,OF P $Fr!   r  c                   (    e Zd ZdZd Zd Zd Zd Zy)EvaluateOrExecuteCodeMixinz
    Evaluate or execute Python code in a Cython or Python frame. The 'evalcode'
    method evaluations Python code, prints a traceback if an exception went
    uncaught, and returns any return value as a gdb.Value (NULL on exception).
    c                 J   | j                         }|j                  j                         D ]  \  }}|j                  t        k(  s| j                  ||      s-	 t        j                  |j                        }|j                  rZ|j                  |      }d|||j                  fz  }	 t        j                  |      dk  r*t        j                  d       t        j                  d      	 |j                  |        y# t        $ r Y w xY w# |j                  |       w xY w)zBFill a remotely allocated dict with values from the Cython C stackz
                    (PyObject *) PyDict_SetItem(
                        (PyObject *) %d,
                        (PyObject *) %d,
                        (PyObject *) %s)
                r   zPyErr_Print()zUnable to execute Python code.N)r   r   r  rx   r	   r#  r   r   rv   r   r   alloc_pystringr   xdecref)	r   executorlocal_dict_pointerr   r   r!  r   	pystringpr0  s	            r   _fill_locals_dictz,EvaluateOrExecuteCodeMixin._fill_locals_dict+  s   ..0&--335 	0KD%

l*++K>!,,U[[9C ++ $33D9	
 *9ekkBC0))$/!3**?;!ll+KLL 4
 $$Y/5	0 $ ( $$Y/s   D )AD 	DDD"c                     t        j                         }|rG| j                  |      s| j                  |      r|j	                          |S |j                         }|rGt        j                  d      )Nz0There is no Cython or Python frame on the stack.)r   r   r'   r.   r   r   r   r   s     r   "_find_first_cython_or_python_framez=EvaluateOrExecuteCodeMixin._find_first_cython_or_python_frameK  s_    ""$''...u5KKME  llMNNr!   c                    t        j                         5  t        j                  d      }t        j                  d      }	 | j	                  |t        j
                  |             |j                  ||||      }|j                  t        j
                  |             	 d d d        |S # |j                  t        j
                  |             w xY w# 1 sw Y   S xY w)Nz&(PyObject *) PyModule_GetDict(__pyx_m)z(PyObject *) PyDict_New())r   FetchAndRestoreErrorr   r   rX  pointervalueevalcoderT  )r   rU  r0  
input_typeglobal_dict
local_dictr   s          r   _evalcode_cythonz+EvaluateOrExecuteCodeMixin._evalcode_cythonW  s    ++- 	E ,,8:K++,GHJE&&x'0'='=j'IK!**4[+57   !7!7
!CD	E    !7!7
!CD	E s#   +C9B):$C)&CCCc                     | j                         }t        j                         }| j                  |      rt        j                  |||      S | j                  |||      S )zi
        Evaluate `code` in a Python or Cython stack frame using the given
        `input_type`.
        )rZ  r   PythonCodeExecutorr.   _evalcode_pythonrb  )r   r0  r_  r   rU  s        r   r^  z#EvaluateOrExecuteCodeMixin.evalcodei  sX    
 779//1""5)--hjII$$XtZ@@r!   N)rq   rr   rZ   rK  rX  rZ  rb  r^  r"   r!   r   rQ  rQ  $  s    0@
O$	Ar!   rQ  c                   h    e Zd ZdZdZej                  Zej                  Z	e
j                  d        Zy)r  zD
    Execute Python code in the nearest Python or Cython frame.
    r  c                     | j                  |      \  }}t        j                         }|j                  | j	                  ||j
                               y r   )readcoder   rd  rT  r^  Py_file_input)r   exprr  r_  rU  s        r   r   zCyExec.invoke~  sB    ==.j//1tX-C-CDEr!   N)rq   rr   rZ   rK  r   r   r/  rT  r0  rr  r   r  r   r"   r!   r   r  r  u  s>     D%%M''O##F $Fr!   r  c                   r    e Zd ZdZdZej                  Zej                  Z	e
j                  ed               Zy)r  z
    Set a Cython variable to a certain value

        cy set my_cython_c_variable = 10
        cy set my_cython_py_variable = $cy_eval("{'doner': 'kebab'}")

    This is equivalent to

        set $cy_value("my_cython_variable") = 10
    zcy setc                    |j                  dd      }t        |      dk7  rt        j                  d      |\  }}| j                  j
                  j                  |j                               }t        j                  d|d|       y )Nr   r      z,Invalid expression. Use 'cy set var = expr'.zset rB   )	r   r  r   r   r   r  r   r  r/   )r   rj  r  name_and_exprvarnamerv   s         r   r   zCySet.invoke  sk     

3*}",,MNN%  ''8UD12r!   N)rq   rr   rZ   rK  r   r   rA  rT  r0  rr  r   r  r*   r   r"   r!   r   r  r    sD    	 D$$M''O##3  $3r!   r  c                   J    e Zd ZdZej
                  eedd                     Zy)r  z
    Get the C name of a Cython variable in the current context.
    Examples:

        print $cy_cname("function")
        print $cy_cname("Class.method")
        print $cy_cname("module.function")
    Nc                 t   |xs t        j                         }d }| j                  |      r| j                  |      }||j                  v r|j                  |   j
                  }n||j                  j                  v r$|j                  j                  |   j
                  }nV|j                  j                  d|}||j                  j                  v r#|j                  j                  |   j
                  }|s%| j                  j                  j                  |      }|st        j                  d|z        |S )Nr  zNo such Cython variable: %s)r   r   r'   r   r   rv   r   rg   r   rj   r   r  r&   r   )r   cynamer   rv   r  r  s         r   r   zCyCName.invoke  s    -++-""5)"66u=O///'..v6<<?11999'..66v>DD#2#9#9#>#>GO22<<<+22<<UCIIEGG77;;FCE,,<vEFFr!   r   )	rq   rr   rZ   rK  r   r  r*   r=   r   r"   r!   r   r  r    s1     ##" #  $r!   r  c                   V     e Zd ZdZej
                  eed fd	                     Z xZ	S )r  z-
    Get the value of a Cython variable.
    c                    | j                         }| j                  |      }| j                  ||      r&t        |   ||      }t        j                  |      S ||v r||   j                  S t        j                  d|z        )Nr   zVariable %s is not initialized.)	r  r   r#  r   r   r   r   _gdbvalr   )r   rr  r   globals_dictr  rv   rY   s         r   r   zCyCValue.invoke  s     33522597GN6N7E%%e,,|#'///,,@6IJJr!   r   )
rq   rr   rZ   rK  r   r  r*   r=   r   r   r   s   @r   r  r    s4     ##"
K #  $
Kr!   r  c                   >    e Zd ZdZej
                  ed               Zy)r  z&
    Get the current Cython line.
    c                 (    | j                         d   S r	  )r   rn   s    r   r   zCyLine.invoke  s     %%'**r!   N)rq   rr   rZ   rK  r   r  r*   r   r"   r!   r   r  r    s)     ##+  $+r!   r  c                   >    e Zd ZdZej
                  ed               Zy)r  zO
    Evaluate Python code in the nearest Python or Cython frame and return
    c                 Z    t         j                  j                  }| j                  ||      S r   )r   rd  Py_eval_inputr^  )r   python_expressionr_  s      r   r   zCyEval.invoke  s'     11??
}}.
;;r!   N)rq   rr   rZ   rK  r   r  r=   r   r"   r!   r   r  r    s)     ##"< # $<r!   r  c                      t        j                  t        j                  d      t        j
                  t        j
                  fz         y )Nz        define cy step
        cy -step
        end

        define cy next
        cy -next
        end

        document cy step
        %s
        end

        document cy next
        %s
        end
    )r   source_gdb_scriptr	  r
  r  rK  r  r"   r!   r   register_definesr    s7     1 !	  NNFNN+!!, -r!   )Tr   )NT)[rK  r   r	  r   r8  r  r   lxmlr   	have_lxmlImportError	xml.etreer   pygments.lexersr   pygments.formattersstderrr   rs  r   shlexr   Cython.Debuggerr   r   r	   r  _data_typesgetfilesystemencodingr  r#   r*   r5   r(   r=   ra   rc   rt   r}   r   r   r   r   r   rH  r   r   	ParameterrP  r\  r`  rb  rd  rT   Commandrp  r}  r  r  
PythonInfor  ExecutionControlCommandBaser  PythonStepperMixinr  r  r  r  r  r  r  r  r  r  r  rI  r  r  rQ  PyExecr  r  Functionr  r  r  r  r  ry  r   r  r"   r!   r   <module>r     s_  
      
I
F
 3 !"- % 7>/c//1<W 
"	*	.bO O 
! 
!)^ )2 2>Y) Y)x: :~   D: D!= cmm &    . 

5CKK 50N?= N?b?U} ?UDPm Pf"Y11 "J*M$-$I$I*.*I,H,H .*V O) OP* PR, R/= /2T (} (6"- "@] &0m 0f '>} >8*F *FZNA NAbF]I,,.H F 3M 3<"cllJ "JKw K*+S\\: +	<S\\:'A 	< l	]]_-&  w/  .I  FHJJDEFs"   K K$ K! K!$"L
	L
