[?@sddlZddlZddlTddlmZddlmZddlmZGdddej Z Gdd d Z Gd d d eZ Gd d d Z dS)N)*)ListedToplevel) ScrolledList) macosxSupportc@sLeZdZddZddZddZddZd d Zd S) IdbcCs||_tjj|dS)N)guibdbBdb__init__)selfrr &/usr/lib/python3.4/idlelib/Debugger.pyr s z Idb.__init__cCsC|j|r|jdS|j|}|jj||dS)N) in_rpc_codeset_step_Idb__frame2messager interaction)r framemessager r r user_lines  z Idb.user_linecCsF|j|r|jdS|j|}|jj|||dS)N)rrrrr)r rinforr r r user_exceptions  zIdb.user_exceptioncCsL|jjjdrdS|j}|jjjdr;dS|j|SdS)Nzrpc.pyTz Debugger.pyF)f_code co_filenamecountf_backr)r rZ prev_framer r r rs  zIdb.in_rpc_codecCsf|j}|j}|j}tjj|}d||f}|jdkrbd||jf}n|S)Nz%s:%s?z%s: %s())rrf_linenoospathbasenameco_name)r rcodefilenamelinenorrr r r Z__frame2message's   zIdb.__frame2messageN)__name__ __module__ __qualname__r rrrrr r r r r s     rc@sHeZdZdZZZZdddZddZdddZ dd Z dd d Z d d Z ddZ ddZddZddZddZddZdZddZddZddZdZdZd d!Zd"d#Zd$d%d&Zd'd(Zd)d*Zd+d,Zd-d.ZdS)/DebuggerNcCsM|dkrt|}n||_||_d|_|jd|_dS)Nr)rpyshellidbrmake_gui interacting)r r(r)r r r r 6s     zDebugger.__init__c Gs.zd|_|jj|SWdd|_XdS)Nr)r+r)run)r argsr r r r-?s z Debugger.runcCsZ|jr|jjdS|jr<|jjd|_n|jj|jjdS)N)r+topZbell stackviewercloser(Zclose_debuggerdestroy)r eventr r r r1Fs     zDebugger.closecCs|j}|j|_|j|_}t||_}|jjd|jjd|jd|j|jj d|jt ||_ }|j j ddg|_ }t|ddd |j|_}|j|t|dd d |j|_}|j|t|dd d |j|_}|j|t|dd d |j|_}|j|t|dd d |j|_}|j|x.|D]&}|jdd|j ddqWt ||_}|jj dd|js$t||j_|jjdnt|ddd |j d|j|_!|j!j"dddd|j#st||j_#nt|ddd |j$d|j#|_%|j%j"dddd|j&st||j_&|j&jdnt|ddd |j'd|j&|_(|j(j"dddd|j)sNt||j_)nt|ddd |j*d|j)|_+|j+j"ddddt,|dd|_-|j-j ddt,|dd|_.|j.j dddd|j.j/d|_0t |dd|_1|j1j dddd t ||_2|j2j dddd t |dd|_3|j3j dddd |jj4r|j n|j&j4r|j'n|j)j4r|j*ndS)!Nz Debug ControlZDebugZWM_DELETE_WINDOWzanchorwtextZGocommandZStepZOverZOutZQuitstatedisabledsideleftr,ZStackZvariablerowrcolumnZSourceLocalsGlobalsfillx backgroundheightexpandboth)5r(flistrootrr/Zwm_titleZ wm_iconnameZ wm_protocolr1ZbindFramebframepackbuttonsZButtoncontZbcontappendstepZbstepnextZbnextretZbretquit configurecframevstackZ BooleanVar __class__setZ Checkbutton show_stackZbstackgridvsource show_sourceZbsourcevlocals show_localsZblocalsvglobals show_globalsZbglobalsLabelstatuserrorZcgeterrorbgfstackflocalsfglobalsget)r r(rGr/rIZblbrSr r r r*Ss   " " " " "            zDebugger.make_guic Cs||_|jjd||r|\}}}y |j}Wn"tk rbdt|}YnX|dk ryd|t|f}WqYqXnd}nd}d}|j}|jjd|d||j} | r|j j |j|\} } | j | | n|j d|j jr7|jnx!|jD]} | jdd qAW|jj|jjx!|jD]} | jdd qW|jjdd|jjddd|jd|_dS) Nr6z%sz%s: %sZyellowrBr,r8Znormalr9)rr`rRr$AttributeErrorstrrbrar0r) get_stack load_stackshow_variablesrYrfsync_source_linerKr/wakeuprGZmainloop) r rrrtypevaluetbZm1Zbgsvstackirgr r r rsD           zDebugger.interactioncCsx|j}|sdS|j|\}}|dd|dddkrttjj|rt|jj||ndS)Nr,z<>)r_Debugger__frame2filelinerrexistsrFZ gotofileline)r rr"r#r r r rns  6zDebugger.sync_source_linecCs%|j}|j}|j}||fS)N)rrr)r rr!r"r#r r r Z__frame2filelines   zDebugger.__frame2filelinecCs|jj|jjdS)N)r)Z set_continuerGrQ)r r r r rLs z Debugger.contcCs|jj|jjdS)N)r)rrGrQ)r r r r rNs z Debugger.stepcCs$|jj|j|jjdS)N)r)Zset_nextrrGrQ)r r r r rOsz Debugger.nextcCs$|jj|j|jjdS)N)r)Z set_returnrrGrQ)r r r r rPsz Debugger.retcCs|jj|jjdS)N)r)Zset_quitrGrQ)r r r r rQs z Debugger.quitcCs|j ru|jjrut|j|j||_}|jr|jj|jd\}}|j ||qnB|j}|r|jj rd|_|j nd|jdr,rC) localsviewerr[rfNamespaceViewerrdr1rm)r lvr r r r\s   zDebugger.show_localscCsp|j}|jjr9|sbt|jd|_qbn)|rbd|_|jd|jd )rrhN) rtclearrangelenrrrr linecachegetlinestriprMZselect) r rtindexrurr#modnamer!r"ZfuncnamerZ sourcelineitemr r r rlOs.              zStackViewer.load_stackcCs|jrtj||SdS)zoverride base methodN)rtr popup_event)r r3r r r ris zStackViewer.popup_eventcCs?|j}|jddd|j|jddd|jdS)zoverride base methodlabelzGo to source liner7zShow stack frameN)menuZ add_commandgoto_source_lineshow_stack_frame)r rr r r fill_menuns   zStackViewer.fill_menucCsCd|ko t|jknr?|jj|j|ndS)zoverride base methodrN)rrtrrz)r rr r r on_selectvs%zStackViewer.on_selectcCs|j|dS)zoverride base methodN)rZ)r rr r r on_double{szStackViewer.on_doublecCs#|jjd}|j|dS)Nactive)listboxrrZ)r rr r r rszStackViewer.goto_source_linecCsU|jjd}d|ko2t|jknrQ|jj|j|ndS)Nrr)rrrrtrrz)r rr r r rs%zStackViewer.show_stack_framecCsd|ko t|jkns)dS|j|\}}|j}|j}tjj|r|jj|}|r|j |qndS)Nr) rrtrrrrisfilerFopenZgotoline)r rrr#r!r"Zeditr r r rZs%  zStackViewer.show_source) r$r%r&r rlrrrrrrrZr r r r ryAs        ryc@sCeZdZdddZd ZddddZdd ZdS) r|Nc Csd}d}|r%dt|}n||_||_ddl}|j|_d|j_d|j_t||_ }|j j ddddt |d |d d d d |_ |j j ddt |dd|_}|j ddddt|dtdtd|ddd||f|_} | j dddddd| j|d<|j| ds   )S