
    h                     2   S r SSKrSSKrSSKrSSKrSSKrSSKr SSKJr  Sr	 SSKrSSKr\" \S5      (       a  SS	KJr  OSS
KJr  SSKJr  SrSr\" \\S9r\R8                  " 5       =(       d    SrShS jrS rSiS jr S r!S r"SjS jr# " S S5      r$ " S S5      r% " S S\%5      r&1 Skr'S r( " S S5      r) " S  S!5      r* " S" S#\RV                  5      r, " S$ S%\,5      r- " S& S'\-5      r. " S( S)\R^                  5      r0 " S* S+\05      r1 " S, S-\05      r2 " S. S/\05      r3 " S0 S15      r4\4" 5       r5 " S2 S3\Rl                  \)5      r7 " S4 S5\75      r8 " S6 S7\75      r9 " S8 S9\75      r: " S: S;\)\Rv                  5      r< " S< S=\7\Rz                  5      r> " S> S?\>\R~                  5      r@ " S@ SA\@5      rA " SB SC\>5      rB " SD SE\>5      rC " SF SG\>5      rD " SH SI\75      rE " SJ SK\E5      rF " SL SM\75      rG " SN SO\75      rH " SP SQ\75      rI " SR SS\75      rJST rK " SU SV\75      rL " SW SX\L5      rM " SY SZ5      rN " S[ S\\7\R                  \N5      rP " S] S^\75      rQ " S_ S`\R                  \)5      rS " Sa Sb\S5      rT " Sc Sd\R                  \)5      rU " Se Sf\R                  \)\N5      rV\<" 5       rW\8R                  5       rY\Y\WlY        Sg rZ\Z" 5         g! \
 a    SSKJr  Sr	 GNf = f! \
 a!    Sr\R                   R#                  S5         GNf = f)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                    ^  U 4S jnU$ )Nc                 N   >^  [         R                  " T 5      SUU 4S jj5       nU$ )Nc                    >  U=(       d    [         R                  " 5       nT(       a  UR	                  5       c
  [        5       eT" X/UQ70 UD6$ ! [         a    [         R                  " S5      ef = fNzNo frame is currently selected.)gdbselected_frameRuntimeErrorGdbErrornameNoFunctionNameInFrameError)selfframeargskwargserrfunctions       S/var/www/fran/franai/venv/lib/python3.13/site-packages/Cython/Debugger/libcython.pywrapper>default_selected_gdb_frame.<locals>.decorator.<locals>.wrapper/   sm    F5!3!3!5 uzz|+022D9$9&99   Fll#DEEFs   A !A0N	functoolswraps)r   r   r   s   ` r   	decorator-default_selected_gdb_frame.<locals>.decorator.   s%    		"		: 
#		:      )r   r!   s   ` r   default_selected_gdb_framer%   -   s     r#   c                 X   ^  [         R                  " T 5      [        U 4S j5       5       nU$ )Nc                    > UR                  S5      =(       d    [        R                  " 5       nU R                  U5      (       d  [        R                  " S5      eT" U /UQ70 UD6$ )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   %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                    ^ ^ U U4S jnU$ )Nc                 L   >^  [         R                  " T 5      UU U4S j5       nU$ )Nc                 H  > U R                  5       nU R                  5       nU(       d  U(       a  T(       d  T" U /UQ70 UD6  g U(       a  [        R                  " T5        g U R	                  5       (       a  [        R                  " T5        g [        R
                  " S5      e)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   5dispatch_on_frame.<locals>.decorator.<locals>.wrapperL   s{    ++-E++-E~///N+**,,I&ll $J K Kr#   r   )r   r   r6   r7   s   ` r   r!   $dispatch_on_frame.<locals>.decoratorK   s'    		"	K 
#	K r#   r$   )r6   r7   r!   s   `` r   dispatch_on_framer:   J   s    " r#   c                 F   ^  [         R                  " T 5      U 4S j5       nU$ )Nc                     >  [         R                  " 5         T" U 0 UD6$ ! [         a    [         R                  " S5      ef = fr   )r   r   r   r   )r   r   r   s     r   r   (require_running_program.<locals>.wrapper`   sJ    	B  (((  	B,,@AA	Bs	     !Ar   r,   s   ` r   r+   r+   _   s%    __X) ) Nr#   c                 F   ^  [         R                  " T 5      U 4S j5       nU$ )Nc                 z   > [        U[        R                  5      (       a  UR                  5       nT" X/UQ70 UD6$ r   )
isinstancer   Valuestring)r   rB   r   r   r   s       r   r   .gdb_function_value_to_unicode.<locals>.wrapperl   s4    fcii((]]_F6t6v66r#   r   r,   s   ` r   gdb_function_value_to_unicoderD   k   s%    __X7 7
 Nr#   c                   ^  SSK n[        UR                  T R                  5      R                  5      nU(       a!  U Vs/ s H  oQR                  XU5      PM     snOUnSnU(       a;  [        [        T 5      R                  5       5      nU V	s/ s H  oU;  d  M
  U	PM     nn	SU 4S jjn
SR                  T R                  R                  SSR                  U
" SXd5      5      S	/U
" S
U5      Q5      $ s  snf s  sn	f )a  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      >#    [        X=(       d    U5       H5  u  p4[        [        TU5      5      R                  SS5      nU  U SU 3v   M7     g 7f)N

		 = )zipreprgetattrreplace)prefixattrsr   attrargparamr   s         r   names_and_values%simple_repr.<locals>.names_and_values   sN     UME2IDt,-55dHEEHSEUG,, 3s   AA (,rH   z
	)z
self.r   )inspecttuple	signature__init__
parametersr(   sortedvarskeysjoin	__class____qualname__)r   renamedstaterX   init_arg_namesrQ   
init_attrs
state_reprinstance_attrsrP   rS   s   `          r   simple_reprri   x   s    8 7,,T]];FFGN 4BB>C++c'>B* JT
 12'5P~tZ9Od~
P-
 77NN''HH%h
KL
 'y*=
   C
 Qs   C2	C7C7c                        \ rS rSrS rS rSrg)CythonModule   c                 `    Xl         X l        X0l        0 U l        0 U l        0 U l        0 U l        g r   )r   filename
c_filenameglobalslineno_cy2clineno_c2cy	functions)r   module_namern   ro   s       r   r[   CythonModule.__init__   s/    	 $r#   c                     [        U SS0SS9$ )Nrt   r   F)rc   rd   ri   r   s    r   __repr__CythonModule.__repr__   s    4-)@NNr#   )ro   rn   rs   rp   rr   rq   r   N__name__
__module__rb   __firstlineno__r[   ry   __static_attributes__r$   r#   r   rk   rk      s    	Or#   rk   c                        \ rS rSrS rS rSrg)CythonVariable   c                 T    Xl         X l        X0l        X@l        [	        U5      U l        g r   )r   cnamequalified_nametypeintlineno)r   r   r   r   r   r   s         r   r[   CythonVariable.__init__   s"    	
,	&kr#   c                     [        U 5      $ r   rw   rx   s    r   ry   CythonVariable.__repr__   s    4  r#   )r   r   r   r   r   Nr{   r$   r#   r   r   r      s    "!r#   r   c                   0   ^  \ rS rSr\S4U 4S jjrSrU =r$ )CythonFunction   Falsec	                    > [         T	U ]  UUUUU5        Xl        X@l        US:H  U l        0 U l        / U l        [        5       U l        g )NTrue)	superr[   modulepf_cnameis_initmodule_functionlocals	argumentssetstep_into_functions)
r   r   r   r   r   r   r   r   r   ra   s
            r   r[   CythonFunction.__init__   sQ     	-2-;-1-3		5
  &<&F##&5 r#   )r   r   r   r   r   r   )r|   r}   rb   r~   r   r[   r   __classcell__ra   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                 
   U  S3n[        [        U 5      5       H  nUR                  S5      (       a  M  [        X5      n[	        U5      (       a  UR
                  [        ;   a  U" 5       n[        U5      [        R                  [        R                  [        R                  4;   a*  [        U5      R                  S5      R                  SS5      nX S3[        U[         5      (       a  US:w  a  US S3OU S3-   -  nM     U$ )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
rG   __z
	: linex)r]   dir
startswithrL   callablerb   frame_repr_whitelistr   r   Symtab_and_lineSymbolSymtab
frame_reprrstriprM   r@   r   )r   res	attributevalues       r   r   r      s     G2,CCJ'	%%)E??u115IIGE;3..

CJJGGu%,,T2::4HEB",UC"8"8Y&=P5)2wb\# 	# ( Jr#   c                   2   \ rS rSr\" SS9S 5       r\" SS9S 5       r\" 5       S 5       r\" 5       S 5       r\" 5       S 5       r	\" 5       S	 5       r
\" 5       S
 5       r\" 5       S 5       r\" 5       S 5       r\" SS9SS j5       rS rS rSS jrS rSrg)
CythonBasei  F)r   c                 P    UR                  5       U R                  R                  ;   $ r   )r   cyfunctions_by_cnamer   r   s     r   r)   CythonBase.is_cython_function  s    zz|tww9999r#   c                     UR                  5       S:X  aB  [        R                  " U5      R                  5       nU=(       a    UR	                  5       (       + $ g)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   r1   CythonBase.is_python_function  sD     ::<//ooe,557G=7#;#;#===r#   c                 "    UR                  5       $ r   )r   r   s     r   get_c_function_nameCythonBase.get_c_function_name(  s    zz|r#   c                 6    UR                  5       R                  $ r   )find_salr   r   s     r   get_c_linenoCythonBase.get_c_lineno,  s    ~~$$$r#   c                     U R                   R                  R                  UR                  5       5      nUc
  [	        5       eU$ r   )r   r   r(   r   NoCythonFunctionInFrameError)r   r   results      r   get_cython_functionCythonBase.get_cython_function0  s5    ++//

=>.00r#   c                     U R                  U5      nUR                  R                  R                  U R	                  U5      S5      $ )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   rr   r(   r   )r   r   cyfuncs      r   get_cython_linenoCythonBase.get_cython_lineno8  s=     ))%0}}((,,T->->u-EG[\\r#   c                 f   S =n=p4U R                  U5      (       ao  U R                  U5      R                  R                  nU R	                  U5      nX%S   :X  d   eUS   n[
        (       a  [
        R                  R                  SS9nGOU R                  U5      (       a  [        R                  " U5      R                  5       nU(       d  [        R                  " S5      eUR                  5       nUR                  5       n[
        (       a  [
        R                  R                  SS9nO{UR!                  5       nU(       a  UR"                  (       d  S nSnONUR"                  R%                  5       nUR&                  n[
        (       a  [
        R                  R)                  SS9n[+        X$5      U4$ )Nr      F)stripallz*Unable to read information on python frame)r)   r   r   rn   r   pygmentslexersCythonLexerr1   r   r   r   r   r   current_line_numPythonLexerr   symtabfullnamer   CLexerSourceFileDescriptor)r   r   rn   r   lexerfilename_and_linenopyframeobjectsymbol_and_line_objs           r   get_source_descCythonBase.get_source_descA  so   $(((6""5))//6==FFH"&"8"8"?15555(+Fx 33U3C$$U++%OOE2;;=M llHJ J %--/H"335Fx 33U3C"'.."2&.A.H.H.55>>@,118$OO22E2BE#H4f<<r#   c                 H    U R                  5       u  p#UR                  U5      $ r   )r   
get_source)r   r   source_descr   s       r   get_source_lineCythonBase.get_source_lined  s$    "224%%f--r#   c                    UR                  5       nUR                  5       nU R                  U5      (       d  U R                  U5      (       a  gU(       a5  U R                  U5      (       a  U R	                  U5      nX$R
                  ;   $ g)zT
returns whether we care about a frame on the user-level when debugging
Cython code
TF)r   olderr)   r1   r   r   )r   r   r   older_framecython_funcs        r   r3   CythonBase.is_relevant_functioni  ss     zz|kkm""5))T-D-DU-K-KT44[AA22;?K::::r#   c                   ^ ^ [         R                  " 5       nTR                  5          T R                  T5      u  pVU(       dt  T R                  T5      (       a^  [        R                  " T5      R                  5       nUb  UR                  5       (       a  T R                  TUSS9$ UR                  nSn	/ n
OpT R                  T5      (       a3  T R                  T5      nUU 4S jnUR                  nUR                   n	/ n
O'T R                  T5      u  pVTR                  5       nUn	/ n
 [         R"                  " U	5      nUR$                  n['        U[(        5      (       dC  ['        U[*        [,        45      (       d  [+        U5      n[)        UR/                  5       S   S5      nSR3                  S	 U
 5       5      n[4        R6                  R9                  S
X.X4-  5        UR:                  b1  [4        R6                  R9                  SUR:                  < SU< 35        [4        R6                  R9                  S5         [4        R6                  R9                  SUR=                  U5       S35        UR                  5         g! [         a    [        SU-  5         gf = f! [0         a    Sn GN
f = f! [         R>                   a     NXf = f)zS
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                 L   > TR                   R                  R                  U TS9$ )Nr   )r   	cy_cvalueinvoke)rQ   r   r   s    r   <lambda>-CythonBase.print_stackframe.<locals>.<lambda>  s    DGG--44S4Fr#   r   z, c              3   8   #    U  H  u  pU< S U< 3v   M     g7f)=Nr$   ).0r   vals      r   	<genexpr>.CythonBase.print_stackframe.<locals>.<genexpr>  s     GY	s+Y   z#%-2d 0x%016x in %s(%s)z at :rG       ) r   r   selectr   r   printr1   r   r   r   r   print_stackframeco_namer)   r   r   r   parse_and_evaladdressr@   r   strbytesr   r   r`   sysstdoutwritern   r   r   )r   r   indexr   r   r   r   r   	func_name
func_cname	func_argsr   f	gdb_valuefunc_addressas   ``              r   r  CythonBase.print_stackframez  s\    ++-	"&"6"6u"=K
 //6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0!,e==#&|#4L"<#5#5#7#:A>IIGYGG

2e95XXY+JJK,@,@&IJ

	JJtK$:$:6$B#C2FG 	g * 	9EAB	8  	L	( || 		s5   I? (J <2J0 ?JJJ-,J-0KKc                    [         R                  " S5      n [         R                  " S5      nUR                  UR                  5       5      nUS   $ ! [         a+    [         R                  " [
        R                  " S5      5      ef = f)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_dict)CythonBase.get_remote_cython_globals_dict  s{    y)	2 __-=>N FF>))+,|  	2,,x 00  1 2 2	2s   A 5Bc                     U R                  5       n[        R                  R                  U5      n0 n[	        5       nUR                  5        H  u  pVXcUR                  U5      '   M     U$ )zS
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_dict"CythonBase.get_cython_globals_dict  sa    
 99;!--??Lu!++-DA'(1::d#$ . r#   Nc                     [         R                  " U5      (       a  SnOSUR                  < S3nUc  [        U< U< SU< U< 35        g [        SXCXU4-  5        g )NrU   rV   z) rI   z%s%-*s = %s%s)r   pretty_printer_lookupr   r  )r   r   r   max_name_lengthrN   typenames         r   print_gdb_valueCythonBase.print_gdb_value  sV    **511H 2 #(**.H"645AB/Vde$TTUr#   c                    UR                   U   nU R                  5       S   nSUR                  ;   aN  XAR                  :  a>  UR                  [
        :X  a)  [        [        R                  " UR                  5      5      $ ggXCR                  :  $ )Nr   z->TF)	r   r   r   r   r   r	   r   r   r  )r   r   
local_namecyvar
cur_linenos        r   is_initializedCythonBase.is_initialized  sv    "":.++-a0
5;;...::-s11%++>??LL((r#   r$   )F)NrU   )r|   r}   rb   r~   r%   r)   r1   r   r   r   r   r   r   r3   r  r-  r9  r?  rE  r   r$   r#   r   r   r     s   E*: +:  E* +  ! "  !% "%  ! "  !] "]  ! = " =D  !. ".  ! "   E*?  +? B	V)r#   r   c                   >    \ rS rSrS	S jrS rS rS r  S
S jrSr	g)r   i  Nc                 (    Xl         X l        X0l        g r   )rn   r   	formatter)r   rn   r   rI  s       r   r[   SourceFileDescriptor.__init__  s     
"r#   c                     U R                   S L$ r   )rn   rx   s    r   validSourceFileDescriptor.valid  s    }}D((r#   c                 L   [         (       a  U R                  (       a  [        R                  (       ar  [        R                  R
                  nU R                  c  [         R                  R                  US9nOU R                  n[         R                  " XR                  U5      $ U$ )N)bg)
r   r   r\   colorize_codeterminal_backgroundr   rI  
formattersTerminalFormatter	highlight)r   coderO  rI  s       r   lexSourceFileDescriptor.lex  sn    8

z'?'?//55B~~%$//AARAH	 NN	%%dJJ	BBr#   c              #     #    [        U R                  5       nU(       a4  U(       a-  U R                  UR                  5       5      R	                  5       n[
        R                  " XaS-
  US-
  5      n[        U5       HK  u  pX-   U:X  a  Sn
OSn
U(       a  U(       d  U R                  U	5      n	SXU-   U	R                  5       4-  v   MM     S S S 5        g ! , (       d  f       g = f7f)Nr   > z%s %4d    %s)	openrn   rV  read
splitlines	itertoolsislice	enumerater   )r   startstop
lex_source	mark_line
lex_entirer  sliceidxr   rN   s              r   _get_source SourceFileDescriptor._get_source  s     $-- A
 jHHQVVX&113$$Q	4!8<E&u-	;)+ F Fj88D>D$T[[]'KKK . !  s   C%B3C	C%
C"C%c           	          [         R                  " S5      nU R                  (       d  Ue[        US5      nUc  US-   n SR	                  U R                  XX4U5      5      $ ! [         a    Uef = f)NzUnable to retrieve source coder   rG   )r   r   rn   maxr`   rh  OSError)r   ra  rb  rc  rd  re  excs          r   r   SourceFileDescriptor.get_source  st    ll;<}}IE1<19D	99  jZPR R 	I	s   !A! !A.)rn   rI  r   r   )NTr   F)
r|   r}   rb   r~   r[   rL  rV  rh  r   r   r$   r#   r   r   r     s&    #
)
L, GH#r#   r   c                   ,   ^  \ rS rSrSrU 4S jrSrU =r$ )
CyGDBErrori2  z.
Base class for Cython-command related errors
c                 L   > U=(       d    U R                   4n[        TU ]  " U6   g r   )msgr   r[   )r   r   ra   s     r   r[   CyGDBError.__init__7  s     "{$r#   r$   )r|   r}   rb   r~   __doc__r[   r   r   r   s   @r   rp  rp  2  s       r#   rp  c                       \ rS rSrSrSrSrg)r   i<  zQ
raised when the user requests the current cython function, which is
unavailable
z7Current function is a function cygdb doesn't know aboutr$   Nr|   r}   rb   r~   rt  rr  r   r$   r#   r   r   r   <  s     DCr#   r   c                       \ rS rSrSrSrSrg)r   iD  z]
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 framer$   Nrv  r$   r#   r   r   r   D  s    Cr#   r   c                   :   ^  \ rS rSrSrSU 4S jjrS r\rSrU =r	$ )CythonParameteriO  z"
Base class for cython parameters
c                 ~   > U R                   R                  =U l        U l        [        TU ]  XU5        Ub  X@l        g g r   )ra   rt  show_docset_docr   r[   r   )r   r   command_classparameter_classdefaultra   s        r   r[   CythonParameter.__init__T  s=    '+~~'='==.=	? J r#   c                 ,    [        U R                  5      $ r   )boolr   rx   s    r   __bool__CythonParameter.__bool__[  s    DJJr#   )r|  r{  r   r   )
r|   r}   rb   r~   rt  r[   r  __nonzero__r   r   r   s   @r   ry  ry  O  s    !  Kr#   ry  c                       \ rS rSrSrSrg) CompleteUnqualifiedFunctionNamesib  z@
Have 'cy break' complete unqualified function or method names.
r$   Nr|   r}   rb   r~   rt  r   r$   r#   r   r  r  b      r#   r  c                       \ rS rSrSrSrg)ColorizeSourceCodeih  z-
Tell cygdb whether to colorize source code.
r$   Nr  r$   r#   r   r  r  h  r  r#   r  c                       \ rS rSrSrSrg)TerminalBackgroundin  zB
Tell cygdb about the user's terminal background (light or dark).
r$   Nr  r$   r#   r   r  r  n  r  r#   r  c                       \ rS rSrSrS rSrg)CythonParametersit  z
Simple container class that might get more functionality in the distant
future (mostly to remind us that we're dealing with parameters).
c                    [        S[        R                  [        R                  S5      U l        [        S[        R                  [        R                  S5      U l        [        S[        R                  [        R                  S5      U l
        g )Ncy_complete_unqualifiedTcy_colorize_codecy_terminal_background_colordark)r  r   COMMAND_BREAKPOINTSPARAM_BOOLEANcomplete_unqualifiedr  COMMAND_FILESrP  r  PARAM_STRINGrQ  rx   s    r   r[   CythonParameters.__init__z  su    $D%##	%!
 0	
 $6*	$ r#   )rP  r  rQ  N)r|   r}   rb   r~   rt  r[   r   r$   r#   r   r  r  t  s    
r#   r  c                   P    \ rS rSrSr\R                  r\S 5       r	\S 5       r
Srg)CythonCommandi  z 
Base class for Cython commands
c                     [        U S5      (       d  U " XR                  /UQ70 UD6$ U " XR                  U R                  /UQ70 UD6$ )Ncompleter_class)hasattrr}  r  )clsclsnamer   r   s       r   	_registerCythonCommand._register  sX    s-..w 1 1CDCFCCw 1 133F3F (( &( (r#   c                     [        U SS 5      nU(       a  U R                  U R                  X5        U R                  U R                  X5      $ )Nalias)rL   r  r  r   )r  r   r   r  s       r   registerCythonCommand.register  s:    Wd+MM#))T2}}SXXt44r#   r$   N)r|   r}   rb   r~   rt  r   COMMAND_NONEr}  classmethodr  r  r   r$   r#   r   r  r    s:     $$M( ( 5 5r#   r  c                   `   ^  \ rS rSrSrSr\R                  r\R                  r
U 4S jrSrU =r$ )CyCyi  a  
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           	      b  > [         [        U ]  XUSS9  [        S0 S[        R                  5       _S[        R                  5       _S[        R                  5       _S[        R                  5       _S[        R                  5       _S[        R                  5       _S	[        R                  5       _S
[        R                  5       _S[        R                  5       _S[        R                  5       _S[        R                  5       _S[         R                  5       _S["        R                  5       _S[$        R                  5       _S[&        R                  5       _S[(        R*                  " SS5      _S[,        R                  5       _S[.        R                  5       _S[1        S5      _S[3        S5      _S[5        S5      _S[7        S5      _6nUR9                  5        H  u  pVXl        [=        XU5        M     X l        0 U l        0 U l         0 U l!        [D        RF                  " [H        5      U l%        g )NT)rN   import_break_stepnextruncontfinishupdownr  btlistprint_r   rp   exec_zcy exec-cy-exec_execr   cy_cnamer  	cy_linenocy_evalr$   )&r   r  r[   dictCyImportr  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   r}  r  commandscommand_namecommandra   s          r   r[   CyCy.__init__  s   mT+D,;D 	, 	J  
'')
 %%'
 ??$	

 ??$
 .."
 ??$
 &&(
 
 ??$
 &&(
 %%'
 ??$
 %%'
 &&(
   ((*!
" ++IzB#
$ OO%%
& .."'
, z*-
. !-/
0 {+1
2 Y'3
8 &.^^%5!LJD0 &6  !# ,.( #% "-!8!8!>r#   )r   r  r   r  r  )r|   r}   rb   r~   rt  r   r   r  r}  COMPLETE_COMMANDr  r[   r   r   r   s   @r   r  r    s/    , D$$M**O3? 3?r#   r  c                   p    \ rS rSrSrSr\R                  r\R                  r
\R                  S 5       rSrg)r  i  zV
Import debug information outputted by the Cython compiler
Example: cy import FILE...
z	cy importc           
         [        U[        5      (       a  UR                  [        5      n[	        U5       GH  n [        U5      n[        R                  " U5      nUR                  5        GH  n[        S0 UR                  D6nXR                  R                   UR"                  '   UR%                  S5       H*  n	U	R                  n
['        S0 U
D6UR(                  U
S   '   M,     UR%                  S5       GHc  n[+        SSU0UR                  D6nUR"                  nUR,                  nU R                  R.                  U   R1                  U5        UU R                  R2                  UR,                  '   UU R                  R4                  UR6                  '   U=oR8                  U'   UR%                  S5       H*  nUR                  n
['        S0 U
D6UR:                  U
S   '   M,     UR%                  S	5       H-  nUR                  n
UR<                  R?                  U
S   5        M/     UR@                  RC                  S
 UR%                  S5       5       5        GMf     UR%                  S5       H  n[E        UR                  S   5      nUR                  S   n[G        [I        [D        UR                  S   RK                  5       5      5      n[M        U5      URN                  UU4'   U H  nUU4URP                  U'   M     M     GM     GM     g ! [         a0  n[        R                  " SU< SUR                  S   < 35      eS nAff = f)NzUnable to open file r   r   Globalsr   	Functionsr   LocalsStepIntoFunctionsc              3   8   #    U  H  oR                   v   M     g 7fr   )tag)r  funcargs     r   r
  "CyImport.invoke.<locals>.<genexpr>/  s      5O3M3Mr  	ArgumentsLineNumberMapping
src_linenosrc_path	c_linenosr$   ))r@   r  decode_filesystemencodingr   r[  rl  r   r   r   r   parsegetrootrk   attribr   r  r   findr   rp   r   r   r  appendr  r   r   rs   r   r   addr   extendr   r  mapr   minrq   rr   )r   r   from_ttyrQ   r  etr   cython_modulevariabledr   cython_functionr   qnamelocalstep_into_funcmarkerr  r  r  c_linenos                         r   r  CyImport.invoke  s   dE"";;23D!$'CUI AA))+ , =v}} =?L((););< &I 6H A7E7J7JM))!F)4 !7 !'K 8H&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!LL<J<OQ<O..qy9 "9 +3--8K*L*11';;??&	J +M $--44 5O3;==3M5O O1 !96 %kk*=>F!$V]]<%@!AJ%}}Z8H $SfmmK.H.N.N.P%Q RIFI)nM--h
.BC$-?G>T11(; %. ?G & (  Ull4PQ#STTUs   L
M+MMr$   N)r|   r}   rb   r~   rt  r   r   COMMAND_STATUSr}  COMPLETE_FILENAMEr  r   dont_suppress_errorsr  r   r$   r#   r   r  r    s>    
 D&&M++O##4U $4Ur#   r  c                       \ rS rSrSrSr\R                  rS r	S r
\R                  S 5       r\R                  S 5       rSrg	)
r  i;  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                    UR                  S5      u  p#n[        U5      nU(       a  U R                  R                  U   nOU R	                  5       R
                  nUR                  U4UR                  ;   aH  UR                  UR                  U4   nUR                  < SU< 3n[        R                  " SU-   5        g [        R                  " S5      e)Nr  break z5Not a valid line number. Does it contain actual code?)	partitionr   r   r  r   r   rn   rq   ro   r   r2   r   )r   r   
modulename_r   r  r  
breakpoints           r   
_break_pyxCyBreak._break_pyxV  s     $s 3
vV GG44Z@M 446==M""F+}/H/HH$001G1G1OPH$1$<$<hGJKK:-.,,  > ? ?r#   c                 "   U R                   R                  R                  U5      nU(       a  UR                  (       a  S nU/nU(       GdN  U R                   R                  R                  U5      =(       d    / nU Vs/ s H  oUR                  (       a  M  UPM     nnU(       d  [
        R                  " SU-   5        g [        U5      S:  a  [        S5        [        U5       H  u  pb[        SXbR                  4-  5        M        [        S5      nUR                  5       S:X  a  g UR                  5       S:X  a  UnO[UR                  5       (       a2  S[        U5      s=::  a  [        U5      :  a  O  OU[        U5         /nO[        S	5         M  US   /nU H\  n[
        R                  " S
UR                   -  5        UR"                  (       d  M9  [
        R                  " S
UR"                  -  5        M^     g s  snf ! [         a     g f = f)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   r2   lenr  r`  r   inputlowerisdigitr   EOFErrorr   r   )r   funcnamefuncbreak_funcsfuncsr  rg  r   s           r   _break_funcnameCyBreak._break_funcnamef  s   ww2266x@D//DfGG--11(;ArE %F1-E-EQEFHx/05zA~:;!*5!1IC)s,?,?&@@A "2 7!&G"H "<<>S0"#\\^s2*/K!$nn.. !S[ =3u: =+0V+=*>K!!"56% (  %QxjDKK
TZZ/0}}}J67  E G" $ s   =G<G<H 
HHc                 X   [        U[        5      (       a  UR                  [        5      n[	        U5      nUR                  S5      (       a  USS  nSnOSnU HO  nU(       a  [        R                  " SU-  5        M%  SU;   a  U R                  U5        M>  U R                  U5        MQ     g )Nz-pr   TFzpy-break %sr  )
r@   r  r  r  r   r   r   r2   r  r   )r   function_namesr  argvpython_breakpointsr  s         r   r  CyBreak.invoke  s    ne,,+223FGNn-$$T**8D!%!&H!MH45)$$X. r#   c                    U=(       d    SnU R                   R                  R                  5        VVs/ s H   u  p4[        S U 5       5      (       d  M  UPM"     nnnU R                   R                  R                  5        VVs/ s H  u  p6UR
                  (       a  M  UPM     nnn[        R                  (       a  [        R                  " Xu5      nOUnUR                  5       R                  5       n	U	(       a	  SU	S   ;  aX  [        US [        U5      *  R                  5       5      n
U Vs/ s H$  nUR                  U5      (       d  M  X:;  d  M"  UPM&     sn$ U	S   nU Vs/ s H  o3R                  U5      (       d  M  UPM     nn[        U5      [        U5      :  a+  [        U5      [        U5      -
  nU Vs/ s H  o3US  PM	     nnU$ s  snnf s  snnf s  snf s  snf s  snf )NrU   c              3   B   #    U  H  oR                   (       + v   M     g 7fr   )r   )r  r  s     r   r
  #CyBreak.complete.<locals>.<genexpr>  s     Aq!5555qs   .)r   r  r  anyr  r   r\   r  r^  chainstripr   r   r  r   )r   textwordnLnamesr  qnames	all_nameswordsr6  lastwordcomplstrip_prefix_lengths                 r   completeCyBreak.complete  s    zr !% 9 9 ? ? A C AAqAA  A C $ C C I I K 3 K11  K 3 **!6II

""$59,tKc$iZ(..01D( Cy!\\$/ 45M y C C 9"=Fqll8&<F=x=3t9$ #&h-#d)";6;<e*+,eE<7C3C
 > =s;   GGGG.GGG%G G =G%r$   N)r|   r}   rb   r~   rt  r   r   r  r}  r  r   r   r  r  r:  r   r$   r#   r   r  r  ;  sX    . D++M? /8b ##/ $/$ ##  $ r#   r  c                   P   ^  \ rS rSrSrU 4S jrU 4S jrU 4S jrS rS r	Sr
U =r$ )	
CythonInfoi  zE
Implementation of the interface dictated by libpython.LanguageInfo.
c                 v   > U R                  U5      (       a  U R                  U5      S   $ [        TU ]  U5      $ Nr   )r)   r   r   r   r   r   ra   s     r   r   CythonInfo.lineno  s;    
 ""5))))%033w~e$$r#   c                    >  [         TU ]  U5      nUR                  5       =(       d    S $ ! [        R                   a     g f = fr   )r   r   r.  r   r   )r   r   r   ra   s      r   r   CythonInfo.get_source_line  sB    	(7*51D ::<'4' || 		s   + AAc                 F   > U R                   (       a  [        TU ]	  U5      $ g r   )r1   r   exc_infor@  s     r   rE  CythonInfo.exc_info  s!    ""7#E** #r#   c                 b    U R                  5       (       a  U R                  5       R                  $ g)Nr$   )r)   r   r   rx   s    r   runtime_break_functions"CythonInfo.runtime_break_functions  s)    ""$$++-AAAr#   c                 V    S/nUR                  U R                  R                  5        U$ )Nr   )r  r   r   )r   r   s     r   static_break_functions!CythonInfo.static_break_functions  s%    &'dgg001r#   r$   )r|   r}   rb   r~   rt  r   r   rE  rH  rK  r   r   r   s   @r   r=  r=    s&    %(+
 r#   r=  c                   $    \ rS rSr\S 5       rSrg)CythonExecutionControlCommandi  c                 0    U " U R                   [        5      $ r   )r   cython_info)r  s    r   r  &CythonExecutionControlCommand.register  s    388[))r#   r$   N)r|   r}   rb   r~   r  r  r   r$   r#   r   rN  rN    s     * *r#   rN  c                   D    \ rS rSrSrSrSr\R                  S 5       r	Sr
g)r  i  z&Step through Cython, Python or C code.zcy -stepTc                 8   U R                  5       (       a  U R                  U R                  5        g U R                  5       (       d;  U R                  (       a  SnOSnU R	                  [
        R                  " USS95        g U R                  U R                  S9  g )Nr  r  T	to_string)stepinto)r1   python_steprV  r)   finish_executingr   r2   r  )r   r   r  r  s       r   r  CyStep.invoke  sn    ""$$T]]+((**}}  !!#++g"FGIIt}}I-r#   r$   N)r|   r}   rb   r~   rt  r   rV  r   r  r  r   r$   r#   r   r  r    s'    ,DH##. $.r#   r  c                        \ rS rSrSrSrSrSrg)r  i  z#Step-over Cython, Python or C code.zcy -nextFr$   N)r|   r}   rb   r~   rt  r   rV  r   r$   r#   r   r  r    s    )DHr#   r  c                   T    \ rS rSrSrSr\R                  " \R                  5      r
Srg)r  i  zu
Run a Cython program. This is like the 'run' command, except that it
displays Cython or Python source lines as well
zcy runr$   N)r|   r}   rb   r~   rt  r   r   r  rN  r  r  r   r$   r#   r   r  r    s%    
 D++,I,M,MNFr#   r  c                   T    \ rS rSrSrSr\R                  " \R                  5      r
Srg)r  i"  z{
Continue a Cython program. This is like the 'run' command, except that it
displays Cython or Python source lines as well.
zcy contr$   N)r|   r}   rb   r~   rt  r   r   r  rN  r  r  r   r$   r#   r   r  r  "  s%    
 D++,I,N,NOFr#   r  c                   T    \ rS rSrSrSr\R                  " \R                  5      r
Srg)r  i,  z%
Execute until the function returns.
z	cy finishr$   N)r|   r}   rb   r~   rt  r   r   r  rN  r  r  r   r$   r#   r   r  r  ,  s%     D++,I,P,PQFr#   r  c                   D    \ rS rSrSrSrSr\R                  S 5       r	Sr
g)r  i5  z-
Go up a Cython, Python or relevant C frame.
zcy upr  c                 $    [         R                  " U R                  SS9  U R                  [         R                  " 5       5      (       dJ  [         R                  " U R                  SS9  U R                  [         R                  " 5       5      (       d  MJ  [         R                  " 5       nSnU(       a  UR                  5       nUS-  nU(       a  M  U R                  US-
  S9  g ! [
         a"  n[         R                  " UR                  6 eS nAff = f)NTrT  r   r   )r  )
r   r2   _commandr3   r   r   r   r   r   r  )r   r   r  r   r  s        r   r  CyUp.invoke<  s    	(KK6//0B0B0DEEDMMT: //0B0B0DEE
 ""$KKMEQJE e 	EAI.  	(,,''	(s   BC# #
D-D

Dr$   N)r|   r}   rb   r~   rt  r   r`  r   r  r  r   r$   r#   r   r  r  5  s+     DH##/ $/r#   r  c                        \ rS rSrSrSrSrSrg)r  iN  z/
Go down a Cython, Python or relevant C frame.
zcy downr  r$   N)r|   r}   rb   r~   rt  r   r`  r   r$   r#   r   r  r  N  s     DHr#   r  c                   @    \ rS rSrSrSr\R                  S 5       rSr	g)r  iW  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                     [        U5      n[        R                  " 5       nUR                  5       (       a'  UR                  5       nUR                  5       (       a  M'  [        R                  " U5      n [        R                  " SXA-
  S-
  4-  5        g ! [         a    [        R                  " SU< 35      ef = f! [         a"  n[        R                  " UR                  6 eS nAff = f)NzNot a valid number: z	select %dr   )r   
ValueErrorr   r   r   newerr   
stackdepthr2   r   r   )r   stacknor  r   rg  r  s         r   r  CySelect.invoke_  s    	F'lG ""$kkmmKKME kkmm ))%0
	(KKz';a'?&AAB  	F,,7DEE	F  	(,,''	(s#   B 5B= %B:=
C)C$$C)r$   N)
r|   r}   rb   r~   rt  r   r   r  r  r   r$   r#   r   r  r  W  s&    
 D##( $(r#   r  c                   ~    \ rS rSrSrSrSr\R                  r	\R                  r\R                  \S 5       5       rSrg)r  ir  zPrint the Cython stackzcy btzcy backtracec                    [         R                  " 5       nUR                  5       (       a'  UR                  5       nUR                  5       (       a  M'  US:H  nSnU(       aP   U R                  U5      nU(       d  U(       a  U R                  X55        US-  nUR                  5       nU(       a  MO  g g ! [         a    Sn NMf = f)Nz-ar   Fr   )r   r   r   r3   rp  r  rf  )r   r   r  r   	print_allr  is_relevants          r   r  CyBacktrace.invokez  s     ""$kkmmKKME kkmm DL	$"77> K%%e3QJEKKME e  $#$s   !B1 1C ?C r$   N)r|   r}   rb   r~   rt  r   r  r   COMMAND_STACKr}  COMPLETE_NONEr  r   r  r+   r  r   r$   r#   r   r  r  r  sE    DE%%M''O##"  $"r#   r  c                   p    \ rS rSrSrSr\R                  r\R                  r
\R                  S 5       rSrg)r  i  zU
List Cython source code. To disable to customize colouring see the cy_*
parameters.
zcy listc                 n    U R                  5       u  p4UR                  US-
  US-   USS9n[        U5        g )N   T)rd  re  )r   r   r  )r   r  r  sdr   sources         r   r  CyList.invoke  s?     ))+
vz6A:*.  0fr#   r$   N)r|   r}   rb   r~   rt  r   r   r  r}  rp  r  r   r  r  r   r$   r#   r   r  r    s<    
 D%%M''O## $r#   r  c                   ^    \ rS rSrSrSr\R                  r\	R                  S 5       rS rSrg)r  i  zL
Print a Cython variable using 'cy-print x' or 'cy-print module.function.x'
zcy printc                 X   U R                  5       nU R                  5       R                  R                  nX;   a4  X1   R	                  [
        R                  5      n[        U< SU< 35        g X;   aW  XA   R                  n [        R                  " U5      nUR                  (       d  U R                  X5        g [        SU-  5        g U R                  5       (       a  [        R                  " SU-   5      $ U R!                  5       (       ag  U R"                  R$                  R'                  UR)                  S5      5      nU H  nUS:X  a  UR+                  5       nM    O   U R                  X5        g [        R                  " SU-   5        g ! [         a    [        SU-  5         g f = f)NrI   z%s is optimized outzunable to get value of %sz	py-print *zprint )r9  r   r   rp   get_truncated_reprr   MAX_OUTPUT_LENr  r   r   r  r   r?  r   r1   r2   r)   r   r  r  lstripdereference)r   r   r  global_python_dictmodule_globalsr   r   cs           r   r  CyPrint.invoke  s_   !99;113::BB%&,??	@X@XYEtU+, #"(..E8**51 --((5/$67$$&&;;{T122$$&&GG%%,,T[[-=>E8!--/E	    -KK4('   :1D89:s   F F)(F)c                     U R                  5       (       aD  U R                  5       n[        [        R                  " UR
                  UR                  5      5      $ / $ r   )r)   r   r  r^  r-  r   rp   )r   r  s     r   r:  CyPrint.complete  sB    ""$$((*A	!))<==Ir#   r$   N)r|   r}   rb   r~   rt  r   r   COMMAND_DATAr}  r   r  r  r:  r   r$   r#   r   r  r    s7     D$$M## ) $ )Dr#   r  c                 (    U S   R                  5       $ )Nr   )r  )items    r   r  r    s    tAw}}r#   c                       \ rS rSrSrSr\R                  r\R                  r
\R                  \" SSS9S 5       5       rSrg	)
r  i  z0
List the locals from the current Cython frame.
z	cy localszinfo localsz	py-localsr6   r7   c                 &   U R                  5       nUR                  (       a&  U R                  R                  R	                  X5        g UR
                  n[        [        U[        S95      n[        UR                  5       [        S9 H  u  pgU R                  U R                  5       UR                  5      (       d  M6  [        R                  " UR                  5      nUR                   (       a  Mi  U R#                  UR                  UUS5        M     g )NkeyrU   )r   r   r   rp   r  r   r  rk  r]   r  sortkeyrE  r   r   r  r   r   r?  )	r   r   r  r  local_cython_varsr=  r   rC  r   s	            r   r  CyLocals.invoke  s     22411GGOO""42+22c"3=>!"3"9"9";IKD""4#;#;#=uzzJJ**5;;7---((U)8">	 Jr#   r$   Nr|   r}   rb   r~   rt  r   r   ro  r}  rp  r  r   r  r:   r  r   r$   r#   r   r  r    sL     D%%M''O##{K> L $>r#   r  c                       \ rS rSrSrSr\R                  r\R                  r
\R                  \" SSS9S 5       5       rSrg	)
r  i  z2
List the globals from the current Cython module.
z
cy globalszinfo variablesz
py-globalsr  c                 $   U R                  5       nU R                  5       R                  R                  nSnSnU(       a  [	        [        U[        S95      nU(       a  [	        [        U5      5      n[        XV5      n[        5       n[        S5        [        UR                  5       [        S9 HE  u  pU
R                  [        R                  5      n
UR                  U	5        [        SXyU
4-  5        MG     [        S5        [        UR                  5       [        S9 H^  u  pX;  d  M   [        R                   " UR"                  5      nUR$                  (       d   U R'                  UR(                  UUS5        M^  M`     g ! [*         a     Mp  f = f)Nr   r  zPython globals:z    %-*s = %sz
C globals:r  )r9  r   r   rp   r  rk  r   r  r]   r  r  rz  r   r{  r  r   r  r   r   r?  r   r   )r   r   r  r~  r  max_globals_lenmax_globals_dict_lenr=  r6  r7  r8  r   rC  r   s                 r   r  CyGlobals.invoke   sR    "99;113::BB !#n#">?O#&s+='>#? oDu -3357CDA$$Y%=%=>AHHQK/_$;;< D
 	l!."6"6"8gFKDF..u{{;E !11,,UZZ-<fF 2 G $ s   + F
FFr$   Nr  r$   r#   r   r  r    sO     D%%M''O##!1,OF P $Fr#   r  c                   0    \ rS rSrSrS rS rS rS rSr	g)	EvaluateOrExecuteCodeMixini$  z
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                 t   U R                  5       nUR                  R                  5        H  u  pEUR                  [        :X  d  M  U R                  X45      (       d  M3   [        R                  " UR                  5      nUR                  (       a  Mg   UR                  U5      nSX'UR                  4-  n [        R                  " U5      S:  a,  [        R                  " S5        [        R                  " S5      e UR                  U5        M     g! [         a     M  f = f! UR                  U5        f = f)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  r   r	   rE  r   r  r   r   r   alloc_pystringr   xdecref)	r   executorlocal_dict_pointerr   r   rC  r	  	pystringprU  s	            r   _fill_locals_dict,EvaluateOrExecuteCodeMixin._fill_locals_dict+  s   ..0&--335KD

l*++K>>!,,U[[9C ++  , %33D9	
 *ekkBC0))$/!3**?;!ll+KLL 4
 $$Y/5 6 $ ( $$Y/s    D6AD$
D! D!$D7c                    [         R                  " 5       nU(       aW  U R                  U5      (       d  U R                  U5      (       a  UR	                  5         U$ UR                  5       nU(       a  MW  [         R                  " S5      e)Nz0There is no Cython or Python frame on the stack.)r   r   r)   r1   r  r   r   r   s     r   "_find_first_cython_or_python_frame=EvaluateOrExecuteCodeMixin._find_first_cython_or_python_frameK  sg    ""$''....u55KKME e llMNNr#   c                    [         R                  " 5          [        R                  " S5      n[        R                  " S5      n U R	                  U[         R
                  " U5      5        UR                  X#UU5      nUR                  [         R
                  " U5      5         S S S 5        U$ ! UR                  [         R
                  " U5      5        f = f! , (       d  f       W$ = f)Nz&(PyObject *) PyModule_GetDict(__pyx_m)z(PyObject *) PyDict_New())r   FetchAndRestoreErrorr   r  r  pointervalueevalcoder  )r   r  rU  
input_typeglobal_dict
local_dictr   s          r   _evalcode_cython+EvaluateOrExecuteCodeMixin._evalcode_cythonW  s    ++- ,,8:K++,GHJE&&x'0'='=j'IK!**4[+57   !7!7
!CD .    !7!7
!CD .- s#   -C9B-=%C-'CC
C&c                     U R                  5       n[        R                  " 5       nU R                  U5      (       a  [        R                  " XAU5      $ U R                  XAU5      $ )zQ
Evaluate `code` in a Python or Cython stack frame using the given
`input_type`.
)r  r   PythonCodeExecutorr1   _evalcode_pythonr  )r   rU  r  r   r  s        r   r  #EvaluateOrExecuteCodeMixin.evalcodei  sW    
 779//1""5))--hjII$$XZ@@r#   r$   N)
r|   r}   rb   r~   rt  r  r  r  r  r   r$   r#   r   r  r  $  s    0@
O$	Ar#   r  c                   p    \ rS rSrSrSr\R                  r\R                  r
\R                  S 5       rSrg)r  iu  z<
Execute Python code in the nearest Python or Cython frame.
r  c                     U R                  U5      u  p[        R                  " 5       nUR                  U R	                  XR
                  5      5        g r   )readcoder   r  r  r  Py_file_input)r   exprr  r  r  s        r   r  CyExec.invoke~  s>    ==.//1t-C-CDEr#   r$   N)r|   r}   rb   r~   rt  r   r   ro  r}  rp  r  r   r  r  r   r$   r#   r   r  r  u  s>     D%%M''O##F $Fr#   r  c                   z    \ rS rSrSrSr\R                  r\R                  r
\R                  \S 5       5       rSrg)r  i  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                    UR                  SS5      n[        U5      S:w  a  [        R                  " S5      eUu  pAU R                  R
                  R                  UR                  5       5      n[        R                  " SU< SU< 35        g )Nr  r      z,Invalid expression. Use 'cy set var = expr'.zset rI   )	r   r  r   r   r   r  r  r.  r2   )r   r  r  name_and_exprvarnamer   s         r   r  CySet.invoke  si     

3*}",,MNN%  ''8UD12r#   r$   N)r|   r}   rb   r~   rt  r   r   r  r}  rp  r  r   r  r-   r  r   r$   r#   r   r  r    sD    	 D$$M''O##3  $3r#   r  c                   T    \ rS rSrSr\R                  \\SS j5       5       5       r	Sr
g)r  i  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                    U=(       d    [         R                  " 5       nS nU R                  U5      (       a  U R                  U5      nXR                  ;   a  UR                  U   R
                  nOXR                  R                  ;   a$  UR                  R                  U   R
                  nOYUR                  R                  < SU< 3nXTR                  R                  ;   a#  UR                  R                  U   R
                  nU(       d%  U R                  R                  R                  U5      nU(       d  [         R                  " SU-  5      eU$ )Nr*  zNo such Cython variable: %s)r   r   r)   r   r   r   r   rp   r   rs   r   r  r(   r   )r   cynamer   r   r  r  s         r   r  CyCName.invoke  s    -++-""5))"66u=O///'..v6<<11999'..66v>DD#2#9#9#>#>G22<<<+22<<UCIIEGG77;;FCE,,<vEFFr#   r$   r   )r|   r}   rb   r~   rt  r   r  r-   rD   r  r   r$   r#   r   r  r    s1     ##" #  $r#   r  c                   b   ^  \ rS rSrSr\R                  \\SU 4S jj5       5       5       r	Sr
U =r$ )r  i  z%
Get the value of a Cython variable.
c                   > U R                  5       nU R                  U5      nU R                  XA5      (       a#  [        TU ]  XS9n[
        R                  " U5      $ X;   a  X1   R                  $ [
        R                  " SU-  5      e)Nr  zVariable %s is not initialized.)	r9  r   rE  r   r  r   r  _gdbvalr   )r   r  r   globals_dictr  r   ra   s         r   r  CyCValue.invoke  s     335225977GN6N7E%%e,,#'///,,@6IJJr#   r$   r   )r|   r}   rb   r~   rt  r   r  r-   rD   r  r   r   r   s   @r   r  r    s4     ##"
K #  $
Kr#   r  c                   F    \ rS rSrSr\R                  \S 5       5       rSr	g)r  i  z
Get the current Cython line.
c                 (    U R                  5       S   $ r?  )r   rx   s    r   r  CyLine.invoke  s     %%'**r#   r$   N)
r|   r}   rb   r~   rt  r   r  r-   r  r   r$   r#   r   r  r    s)     ##+  $+r#   r  c                   F    \ rS rSrSr\R                  \S 5       5       rSr	g)r  i  zG
Evaluate Python code in the nearest Python or Cython frame and return
c                 X    [         R                  R                  nU R                  X5      $ r   )r   r  Py_eval_inputr  )r   python_expressionr  s      r   r  CyEval.invoke  s%     11??
}}.;;r#   r$   N)
r|   r}   rb   r~   rt  r   r  rD   r  r   r$   r#   r   r  r    s)     ##"< # $<r#   r  c                      [         R                  " [        R                  " S5      [        R
                  [        R
                  4-  5        g )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  rt  r  r$   r#   r   register_definesr    s7     1 !	  NNFNN+!!, -r#   )Tr   )NT)[rt  r  r(  r   r^  r  r   lxmlr   	have_lxmlImportError	xml.etreer   pygments.lexersr   pygments.formattersstderrr  r  r   shlexr   Cython.Debuggerr   r   r	   r  _data_typesgetfilesystemencodingr  r%   r-   r:   r+   rD   ri   rk   r   r   r   r   r   r   r   rp  r   r   	Parameterry  r  r  r  r  r\   Commandr  r  r  r  
PythonInfor=  ExecutionControlCommandBaserN  PythonStepperMixinr  r  r  r  r  r  r  r  r  r  r  r  r  r  r  PyExecr  r  Functionr  r  r  r  rP  r  r   r  r$   r#   r   <module>r     s`  
      
I
F
 3 !!"- % 7>//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