+
     BiR                         R t ^ RIt^ RIt^ RI5 ^ RIHtHt ^ RIHt ^ RI	H
t
 ^ RIHt  ! R R]P                  4      tR	 tR
 t ! R R4      t ! R R]
4      t ! R R4      t]R8X  d   ^ RIHt ]! R^RR7       R# R# )a  Debug user code with a GUI interface to a subclass of bdb.Bdb.

The Idb instance 'idb' and Debugger instance 'gui' need references to each
other or to an rpc proxy for each other.

If IDLE is started with '-n', so that user code and idb both run in the
IDLE process, Debugger is called without an idb.  Debugger.__init__
calls Idb with its incomplete self.  Idb.__init__ stores gui and gui
then stores idb.

If IDLE is started normally, so that user code executes in a separate
process, debugger_r.start_remote_debugger is called, executing in the
IDLE process.  It calls 'start the debugger' in the remote process,
which calls Idb with a gui proxy.  Then Debugger is called in the IDLE
for more.
N)*)Frame	Scrollbar)macosx)ScrolledList)ListedToplevelc                   B   a a ] tR t^t oRtV 3R ltR tR tRtVt	V ;t
# )Idbz6Supply user_line and user_exception functions for Bdb.c                0   < Wn         \        SV `	  4        R # N)guisuper__init__)selfr   	__class__s   &&'/usr/lib/python3.14/idlelib/debugger.pyr   Idb.__init__    s        c                    \        V4      '       d   V P                  4        R# \        V4      p V P                  P	                  W!4       R#   \
         d     R# i ; i)z]Handle a user stopping or breaking at a line.

Convert frame to a string and send it to gui.
N)_in_rpc_codeset_step_frame2messager   interactionTclError)r   framemessages   && r   	user_lineIdb.user_line$   sN    
 MMO '	HH  0 		s   A AAc                    \        V4      '       d   V P                  4        R# \        V4      pV P                  P	                  W1V4       R# )z)Handle an the occurrence of an exception.N)r   r   r   r   r   )r   r   exc_infor   s   &&& r   user_exceptionIdb.user_exception2   s7    MMO 'WX6r   )r   )__name__
__module____qualname____firstlineno____doc__r   r   r    __static_attributes____classdictcell____classcell__)r   __classdict__s   @@r   r	   r	      s     <7 7r   r	   c                    V P                   P                  P                  R4      '       d   R# V P                  pVf   R# VP                   P                  pRV9   d
   RV9   d   R# \	        V4      # )z)Determine if debugger is within RPC code.zrpc.pyTFidlelibdebugger)f_codeco_filenamecountf_backr   )r   
prev_frame	prev_names   &  r   r   r   :   sb    ||%%h//\\
%%11		!jI&= J''r   c                    V P                   pVP                  pV P                  p\        P                  P                  V4      pV RV 2pVP                  R8w  d   V RVP                   R2pV# )z"Return a message string for frame.:?: z())r.   r/   f_linenoospathbasenameco_name)r   codefilenamelinenor;   r   s   &     r   r   r   I   sj    <<DH^^Fww)H
!F8$G||sIR~R0Nr   c                      a  ] tR t^Ut o RtRtRtRtRtRt	Rt
RtRR ltR tRR ltR tRR ltR tR	 tR
 tR tR tR tR tR tR tR tR tR tR tRR ltR tR t R t!R t"Rt#V t$R# )DebuggerzThe debugger interface.

This class handles the drawing of the debugger window and
the interactions with the underlying debugger session.
Nc                    Vf   \        V 4      pWn        W n        RV n        V P	                  4        RV n        ^ V n        R# )zInstantiate and draw a debugger window.

:param pyshell: An instance of the PyShell Window
:type  pyshell: :class:`idlelib.pyshell.PyShell`

:param idb: An instance of the IDLE debugger (optional)
:type  idb: :class:`idlelib.debugger.Idb`
NF)r	   pyshellidbr   make_guiinteractingnesting_level)r   rC   rD   s   &&&r   r   Debugger.__init__c   s<     ;d)C
 r   c                   a a S P                   ^ 8  d4   S P                  4        S P                  P                  ^dVV 3R l4       R#  RS n        S P
                  P                  ! S!  RS n        #   RS n        i ; i)zRun the debugger.c                  $   < SP                   ! S !  # r   )run)argsr   s   r   <lambda>Debugger.run.<locals>.<lambda>   s    4r   NTF)rG   
abort_looprootafterrF   rD   rK   )r   rL   s   fjr   rK   Debugger.runu   sa    > !OOIIOOC!89	%#D88<<&$DuDs    A0 0	A9c                t    V P                  4        V P                  '       d   V P                  P	                  4        R# V P
                  '       d"   V P
                  P                  4        RV n        V P                  P                  4        V P                  P                  4        R#   \         d     Li ; i)zClose the debugger and window.N)
quit	ExceptionrF   topbellstackviewercloserC   close_debuggerdestroyr   events   &&r   rY   Debugger.close   s    	IIK HHMMO""$d&6 	##%  		s   B) )B76B7c                   V P                   pVP                  V n        VP                  ;V n        p\        V4      ;V n        pV P                  P                  R4       V P                  P                  R4       VP                  RV P                  4       V P                  P                  RV P                  4       \        V4      ;V n        pV P                  P                  RR7       . ;V n        p\        VRV P                  R7      ;V n        pVP#                  V4       \        VR	V P$                  R7      ;V n        pVP#                  V4       \        VR
V P(                  R7      ;V n        pVP#                  V4       \        VRV P,                  R7      ;V n        pVP#                  V4       \        VRV P0                  R7      ;V n        pVP#                  V4       V F'  pVP3                  RR7       VP                  RR7       K)  	  \        V4      ;V n        pV P4                  P                  RR7       V P6                  '       g6   \9        V4      V P:                  n        V P6                  P=                  ^4       \?        VRV P@                  V P6                  R7      V n!        V PB                  PE                  ^ ^ R7       V PF                  '       g   \9        V4      V P:                  n#        \?        VRV PH                  V PF                  R7      V n%        V PJ                  PE                  ^ ^R7       V PL                  '       g6   \9        V4      V P:                  n&        V PL                  P=                  ^4       \?        VRV PN                  V PL                  R7      V n(        V PP                  PE                  ^^ R7       V PR                  '       g   \9        V4      V P:                  n)        \?        VRV PT                  V PR                  R7      V n+        V PV                  PE                  ^^R7       \Y        VRR7      V n-        V PZ                  P                  RR7       \Y        VRR7      V n.        V P\                  P                  RRR7       V P\                  P_                  R4      V n0        \        V^R7      V n1        V Pb                  P                  ^RR7       \        V4      V n2        V Pd                  P                  ^RR7       \        V^R7      V n3        V Pf                  P                  ^RR7       V P6                  Pi                  4       '       d   V PA                  4        V PL                  Pi                  4       '       d   V PO                  4        V PR                  Pi                  4       '       d   V PU                  4        R# R# )z$Draw the debugger gui on the screen.zDebug ControlDebugWM_DELETE_WINDOWz<Escape>w)anchorGo)textcommandStepOverOutQuitdisabledstateleft)sideStack)re   rf   variablerowcolumnSourceLocalsGlobalsx)rc   fill
background)heightbothexpandry   N)5rC   flistrP   r   rV   wm_titlewm_iconnamewm_protocolrY   bindr   bframepackbuttonsButtoncontbcontappendstepbstepnextbnextretbretrT   	configurecframevstack
BooleanVarr   setCheckbutton
show_stackbstackgridvsourceshow_sourcebsourcevlocalsshow_localsblocalsvglobalsshow_globalsbglobalsLabelstatuserrorcgeterrorbgfstackflocalsfglobalsget)r   rC   rP   rV   r   blbr   s   &       r   rE   Debugger.make_gui   s9   ,,]]
"<<'	D'--3/*W%*DJJ7j$**-$Sz)f$rT499EE
Q
		!VTYYGG
Q
		!VTYYGG
Q
		!vE488DD	A
		!vFDIIFF	A
		!AKKjK)FFF   %V},ff%{{{$.sODNN!KKOOA!&$//DKKIQq)|||%/_DNN""64#3#3dllLa*|||%/_DNN"LLQ"64#3#3dllLa*}}}&0oDNN##FD$5$5Oq+C,$3s+


s-zz|4C*/Sz0c!,!&1;;??OO<<== r   c                t   W n         V P                  P                  VR 7       V'       d"   Vw  rEp VP                  pVe	    V RV 2pRpMRpRpV P                  pV P                  P                  WxR7       V P                  p	V	'       d:   V P                  P                  V P                   V4      w  rV	P                  W4       V P                  ^4       V P                  P                  4       '       d   V P                  4        V P                    F  pVP                  RR7       K  	  V P"                  P%                  4        V ;P&                  ^,          un        V P(                  P*                  P-                  R	R
4       V ;P&                  ^,          un        V P                    F  pVP                  RR7       K  	  V P                  P                  RR 7       V P                  P                  RV P                  R7       RV n         R#   \         d    R\        T4      ,          p ELi ; i    EL; i)re   z%sNr7   yellow )re   rz   normalrl   vwait::idledebugwaitrk   )r   r   r   r"   AttributeErrorstrr   r   rX   rD   	get_stack
load_stackshow_variablesr   r   sync_source_liner   rV   wakeuprG   rP   tkcall)r   r   r   infotypevaluetbm1bgsvstackir   s   &&&&         r   r   Debugger.interaction   s   
7+"OD&]]  4r%)B BBBB

"4xx))$**b9HEMM%#A<<!!#AKKhK'  	 	a		'#45aAKKjK) 2&

">
Q " &CI%&s   H H2 H/.H/2H7c                   V P                   pV'       g   R # V P                  V4      w  r#VR,          VRR  ,           R8w  dE   \        P                  P	                  V4      '       d   V P
                  P                  W#4       R # R # R # )N:N   Nz<>)r   _Debugger__frame2fileliner9   r:   existsr   gotofileline)r   r   r>   r?   s   &   r   r   Debugger.sync_source_line.  sh    

007B<(23-'4/BGGNN84L4LJJ##H5 5M/r   c                P    VP                   pVP                  pVP                  pW43# r   )r.   r/   r8   )r   r   r=   r>   r?   s   &&   r   __frame2filelineDebugger.__frame2fileline6  s(    ||##r   c                Z    V P                   P                  4        V P                  4        R # r   )rD   set_continuerO   r   s   &r   r   Debugger.cont<  s    r   c                Z    V P                   P                  4        V P                  4        R # r   )rD   r   rO   r   s   &r   r   Debugger.step@      r   c                p    V P                   P                  V P                  4       V P                  4        R # r   )rD   set_nextr   rO   r   s   &r   r   Debugger.nextD  s"    $**%r   c                p    V P                   P                  V P                  4       V P                  4        R # r   )rD   
set_returnr   rO   r   s   &r   r   Debugger.retH  s"    DJJ'r   c                Z    V P                   P                  4        V P                  4        R # r   )rD   set_quitrO   r   s   &r   rT   Debugger.quitL  r   r   c                T    V P                   P                  P                  R RR4       R# )r   r   1N)rP   r   r   r   s   &r   rO   Debugger.abort_loopP  s    		%!2C8r   c                   V P                   '       g   V P                  P                  4       '       dx   \        V P                  V P
                  V 4      ;V n         pV P                  '       d<   V P                  P                  V P                  R 4      w  r#VP                  W#4       R # R # V P                   pV'       d8   V P                  P                  4       '       g   R V n         VP                  4        ^V P                  R&   R # )Nr{   )rX   r   r   StackViewerr   r   r   rD   r   r   rY   )r   r   r   r   s   &   r   r   Debugger.show_stackS  s    DKKOO$5$5$/TZZ$NNDrzzz88--djj$?e'  !!B$++//++#' 
$%DKK!r   c                j    V P                   P                  4       '       d   V P                  4        R # R # r   )r   r   r   r   s   &r   r   Debugger.show_source`  s&    <<!!# r   c                B    V^ ,          V n         V P                  4        R#     N)r   r   )r   	stackitems   &&r   
show_frameDebugger.show_framed  s    q\
r   c                "   V P                   pV P                  P                  4       '       d%   V'       g   \        V P                  R 4      V n         M.V'       d'   RV n         VP                  4        ^V P                  R&   V P                  4        R# )rv   Nr{   )localsviewerr   r   NamespaceViewerr   rY   r   )r   lvs   & r   r   Debugger.show_localsh  se    <<$3DLL($K!$(!
)*X&r   c                "   V P                   pV P                  P                  4       '       d%   V'       g   \        V P                  R 4      V n         M.V'       d'   RV n         VP                  4        ^V P                  R&   V P                  4        R# )rw   Nr{   )globalsviewerr   r   r   r   rY   r   )r   gvs   & r   r   Debugger.show_globalst  se    ==%4T]]I%N"%)"
*+h'r   c                   V P                   pV P                  pV P                  pV'       g   R ;rVM/VP                  pVP                  pV'       d   V'       d   WVJ d   R pV'       d1   VP                  WQV P                  P                  P                  4       V'       d3   VP                  WaV P                  P                  P                  4       R # R # r   )	r   r   r   f_locals	f_globals	load_dictrC   interprpcclt)r   forcer   r   r   ldictgdicts   &&     r   r   Debugger.show_variables  s    

  EENNEOOEbU^LLt||':':'A'ABLLt||':':'A'AB r   c                <    V P                   P                  W4       R# )zjSet a filename-lineno breakpoint in the debugger.

Called from self.load_breakpoints and EW.setbreakpoint
N)rD   	set_breakr   r>   r?   s   &&&r   set_breakpointDebugger.set_breakpoint  s    
 	8,r   c                <    V P                   P                  W4       R # r   )rD   clear_breakr  s   &&&r   clear_breakpointDebugger.clear_breakpoint  s    X.r   c                <    V P                   P                  V4       R # r   )rD   clear_all_file_breaks)r   r>   s   &&r   clear_file_breaksDebugger.clear_file_breaks  s    &&x0r   c                    V P                   P                  P                   F>  pVP                  P                  p VP
                   F  pV P                  W#4       K  	  K@  	  R#   \         d     KR  i ; i)z>Load PyShellEditorWindow breakpoints into subprocess debugger.N)rC   r   inversedictior>   breakpointsr  r   )r   editwinr>   r?   s   &   r   load_breakpointsDebugger.load_breakpoints  sb    ||))55Gzz**H%11F''9 2 6
 " s   $A%%A43A4)r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rD   rF   r   rG   rC   rP   rX   r   rV   r   )r   )%r"   r#   r$   r%   r&   r   r   r   r   rX   r   r   r   rK   rY   rE   r   r   r   r   r   r   r   rT   rO   r   r   r   r   r   r   r  r  r  r  r'   r(   r*   s   @r   rA   rA   U   s     
 FGGHKLM$'%R$J X0d6 9&$

C -/1 r   rA   c                   ^   a  ] tR tRt o RtR tRR ltR tR tR t	R	 t
R
 tR tR tRtV tR# )r   i  z#Code stack viewer for debugger GUI.c                    \         P                  ! 4       '       d   \        P                  ! W4       M\        P                  ! W^PR7       W n        W0n        . V n        R# )P   )widthN)r   isAquaTkr   r   r   r   r   )r   masterr   r   s   &&&&r   r   StackViewer.__init__  s@    ?? !!$/!!$b9

r   Nc                   Wn         V P                  4        \        \        V4      4       F  pW,          w  rE VP                  R ,          pTP
                  pTP                  pTP                  p	^ RIp
T
P                  Y4      pTP                  4       pT	R9   d   RYeT3,          pMRYiY[3,          pY28X  d
   RT,           pT P                  T4       K  	  Ve   V P                  V4       R# R#    Rp L; i)r"   r6   Nz%s, line %d: %sz%s.%s(), line %d: %sz> )r6   r   N)r   clearrangelenr   r.   r/   r<   	linecachegetlinestripr   select)r   r   indexr   r   r?   modnamer=   r>   funcnamer$  
sourcelineitems   &&&          r   r   StackViewer.load_stack  s    


s5z"A!HME//*5 <<D''H||H"**8<J#))+J?*(GZ+HH-171E Ezd{KK' #( KK !s   C00C6c                V    V P                   '       d   \        P                  ! W4      # R# Override base method.N)r   r   popup_eventr\   s   &&r   r1  StackViewer.popup_event  s!    :::++D88 r   c                    V P                   pVP                  RV P                  R7       VP                  RV P                  R7       R# )r0  zGo to source line)labelrf   zShow stack frameN)menuadd_commandgoto_source_lineshow_stack_frame)r   r5  s   & r   	fill_menuStackViewer.fill_menu  sI    yy2!%!6!6 	 	81!%!6!6 	 	8r   c                    ^ Tu;8:  d   \        V P                  4      8  d3   M R# V P                  P                  V P                  V,          4       R# R# r/  )r#  r   r   r   r   r(  s   &&r   	on_selectStackViewer.on_select  s:    'DJJ''HH

5 12 (r   c                (    V P                  V4       R# r/  )r   r<  s   &&r   	on_doubleStackViewer.on_double  s    r   c                ^    V P                   P                  R 4      pV P                  V4       R# activeN)listboxr(  r   r<  s   & r   r7  StackViewer.goto_source_line  s$    ""8,r   c                    V P                   P                  R 4      p^ Tu;8:  d   \        V P                  4      8  d3   M R# V P                  P                  V P                  V,          4       R# R# rC  )rE  r(  r#  r   r   r   r<  s   & r   r8  StackViewer.show_stack_frame  sN    ""8,'DJJ''HH

5 12 (r   c                j   ^ Tu;8:  d   \        V P                  4      8  g    R#  R# V P                  V,          w  r#VP                  pVP                  p\        P
                  P                  V4      '       d9   V P                  P                  V4      pV'       d   VP                  V4       R# R# R# r   )
r#  r   r.   r/   r9   r:   isfiler   opengotoline)r   r(  r   r?   r=   r>   edits   &&     r   r   StackViewer.show_source  s    U,S_, -

5)||##77>>(##::??8,Df%  $r   )r   r   r   r   )r"   r#   r$   r%   r&   r   r   r1  r9  r=  r@  r7  r8  r   r'   r(   r  s   @r   r   r     s:     )
49
83
  3
	& 	&r   r   c                   B   a  ] tR tRt o RtRR ltR	tR
R ltR tRt	V t
R# )r   i  z/Global/local namespace viewer for debugger GUI.Nc           
        ^ p^(pV'       d   ^\        V4      ,          pWn        W n        ^ RIpVP	                  4       V n        ^<V P
                  n        ^<V P
                  n        \        V4      ;V n	        pV P                  P                  ^RR7       \        Wr^RR7      V n        V P                  P                  RR7       \        VRR	7      ;V n        pVP                  R
RR7       \        V\!        R\#        ^(V4      4      ^ ^ WE3R7      ;V n        p	V	P                  RR^R7       V	P&                  VR&   VP(                  V	R&   \        V	4      ;V n        p
V	P-                  ^ ^ V
RR7      V n        V P1                  V4       R# )r   Nr|   r}   groove)re   borderwidthreliefrx   )ry   vbar)namerighty)ro   ry   ,  )r{   scrollregionrn   )ro   ry   r~   rf   yscrollcommandnw)windowrc   )r#  r  titlereprlibReprrepr	maxstringmaxotherr   r   r   r   r4  r   rT  Canvasminmaxcanvasyviewr   subframecreate_windowsfidr   )r   r  r]  odictr  r{   r^  r   rT  rf  rh  s   &&&&       r   r   NamespaceViewer.__init__  sO   E
]F
LLN	 				"6]*
U

qv.5!HM


S!$U88	D		wS	)%e-0c"fo-F45q%3H J 	Jf 	fQ7 ,,Y#'88 #(=0((Aht(L	ur   c                   WP                   J d   V'       g   R # V P                  pV P                  p\        VP                  P                  4       4       F  pVP                  4        K  	  R V n         V'       g"   \        VRR7      pVP                  ^ ^ R7       MVP                  4       p\        V4      p	^ p
V	 F  pW,          pV P                  P                  V4      pV'       d   V^R p\        WKR7      pVP                  V
^ RR7       \        V^ ^ R7      pVP                  ^ V4       VP                  V
^RR7       V
^,           p
K  	  Wn         VP                  4        VP                  4       pVP!                  4       pV P"                  p^ ^ W3V P"                  R&   VR8  d   RVR	&   VP%                  ^R
7       R # VVR	&   VP%                  ^ R
7       R # )NNoner   rr   r[  )rs   rt   sticky)r  rR  rY  rX  r{   )r~   r   )
prev_odictrh  r   listchildrenvaluesr[   r   r   keyssortedr`  Entryinsertupdate_idletaskswinfo_reqwidthwinfo_reqheightrf  r   )r   rk  r   
rpc_clientrh  r   cl	keys_listnamesrs   rU  r   svaluer  r{   rf  s   &&&&             r   r   NamespaceViewer.load_dict  s   OO#E==

h''..01AIIK 2hV,AFFqF# 

I9%EC. #Ab\F(.3q6(!;F#3q6!e   !!#'')))+'(!U&;N#C<"F8JJaJ %F8JJaJ r   c                :    V P                   P                  4        R # r   )r   r[   r   s   &r   rY   NamespaceViewer.closeR  s    

r   )
rf  r   r4  r  rp  r`  rj  rh  r]  rT  r   r   r   )r"   r#   r$   r%   r&   r   rp  r   rY   r'   r(   r  s   @r   r   r     s$     56 J4!l r   r   __main__)mainzidlelib.idle_test.test_debuggerF)	verbosityexit)r&   bdbr9   tkintertkinter.ttkr   r   r,   r   idlelib.scrolledlistr   idlelib.windowr   Bdbr	   r   r   rA   r   r   r"   unittestr   r   r   <module>r     s   "  	  (  - )7#'' 7:(	P Pf
Q&, Q&hW Wt z	*aeD r   