Pc@sdZddlZddlZddlZddlZdddgZdefdYZdfdYZdZ dfd YZ d Z d Z d efd YZ dZdZdZdS(sDebugger basicsiNtBdbQuittBdbt BreakpointcBseZdZRS(sException to give up completely(t__name__t __module__t__doc__(((s..\python\lib\bdb.pyR scBseZdZd+dZdZdZdZdZdZ dZ dZ d Z d Z d Zd Zd ZdZdZdZdZddZdZdZdZdZd+dZdZdZdd+d+dZdZdZdZ dZ!d Z"d!Z#d"Z$d#Z%d$Z&d%d&Z'd+d+d'Z(d+d+d(Z)d)Z*d*Z+RS(,sGeneric Python debugger base class. This class takes care of details of the trace facility; a derived class should implement user interaction. The standard debugger class (pdb.Pdb) is an example. cCs1|rt|nd|_i|_i|_dS(N(tsettNonetskiptbreakstfncache(tselfR((s..\python\lib\bdb.pyt__init__s cCso|d|dd!dkr|S|jj|}|sktjj|}tjj|}||j|(R tgettostpathtabspathtnormcase(R tfilenametcanonic((s..\python\lib\bdb.pyRscCs3ddl}|jd|_|jdddS(Ni(t linecachet checkcacheRtbotframet _set_stopinfo(R R((s..\python\lib\bdb.pytreset&s   cCs|jr dS|dkr&|j|S|dkrB|j||S|dkr^|j||S|dkrz|j||S|dkr|jS|dkr|jS|dkr|jSdGt|GH|jS( Ntlinetcalltreturnt exceptiontc_callt c_exceptiontc_returns*bdb.Bdb.dispatch: unknown debugging event:(tquittingt dispatch_linet dispatch_calltdispatch_returntdispatch_exceptionttrace_dispatchtrepr(R tframeteventtarg((s..\python\lib\bdb.pyR',s$         cCsG|j|s|j|r@|j||jr@tq@n|jS(N(t stop_heret break_heret user_lineR"RR'(R R)((s..\python\lib\bdb.pyR#@s   cCsm|jdkr"|j|_|jS|j|p=|j|sDdS|j|||jrftn|jS(N( RRtf_backR'R,tbreak_anywheret user_callR"R(R R)R+((s..\python\lib\bdb.pyR$Fs  cCsJ|j|s||jkrC|j|||jrCtqCn|jS(N(R,t returnframet user_returnR"RR'(R R)R+((s..\python\lib\bdb.pyR%Ss  cCs;|j|r4|j|||jr4tq4n|jS(N(R,tuser_exceptionR"RR'(R R)R+((s..\python\lib\bdb.pyR&Ys  cCs.x'|jD]}tj||r tSq WtS(N(RtfnmatchtTruetFalse(R t module_nametpattern((s..\python\lib\bdb.pytis_skipped_modulecscCs|jr(|j|jjdr(tS||jkrZ|jdkrJtS|j|jkSx;|dk r||jk r||j krt S|j }q]WtS(NRi( RR:t f_globalsRR7t stopframet stoplinenotf_linenoRRR6R/(R R)((s..\python\lib\bdb.pyR,is  cCs|j|jj}||jkr(tS|j}||j|krj|jj}||j|krjtSnt|||\}}|r|j|_ |r|j r|j t |jnt StSdS(N(Rtf_codet co_filenameR R7R>tco_firstlinenot effectivetnumbert currentbpt temporarytdo_cleartstrR6(R R)Rtlinenotbptflag((s..\python\lib\bdb.pyR-ys   cCs tddS(Ns)subclass of bdb must implement do_clear()(tNotImplementedError(R R+((s..\python\lib\bdb.pyRFscCs|j|jj|jkS(N(RR?R@R (R R)((s..\python\lib\bdb.pyR0scCsdS(snThis method is called when there is the remote possibility that we ever need to stop in this function.N((R R)t argument_list((s..\python\lib\bdb.pyR1scCsdS(s9This method is called when we stop or break at this line.N((R R)((s..\python\lib\bdb.pyR.scCsdS(s5This method is called when a return trap is set here.N((R R)t return_value((s..\python\lib\bdb.pyR3scCs|\}}}dS(N((R R)texc_infotexc_typet exc_valuet exc_traceback((s..\python\lib\bdb.pyR4sicCs(||_||_d|_||_dS(Ni(R<R2R"R=(R R<R2R=((s..\python\lib\bdb.pyRs   cCs|j|||jddS(sxStop when the line with the line no greater than the current one is reached or when returning from current frameiN(RR>(R R)((s..\python\lib\bdb.pyt set_untilscCs|jdddS(sStop after one line of code.N(RR(R ((s..\python\lib\bdb.pytset_stepscCs|j|ddS(s2Stop on the next line in or below the given frame.N(RR(R R)((s..\python\lib\bdb.pytset_nextscCs|j|j|dS(s)Stop when returning from the given frame.N(RR/(R R)((s..\python\lib\bdb.pyt set_returnscCsq|dkrtjj}n|jx(|rR|j|_||_|j}q+W|jtj |jdS(spStart debugging from `frame`. If frame is not specified, debugging starts from caller's frame. N( Rtsyst _getframeR/RR'tf_traceRRStsettrace(R R)((s..\python\lib\bdb.pyt set_traces       cCsm|j|jdd|jsitjdtjj}x+|re||jk re|`|j}q>WndS(Ni( RRRR RVRYRWR/RX(R R)((s..\python\lib\bdb.pyt set_continues  cCs/|j|_d|_d|_tjddS(Ni(RR<RR2R"RVRY(R ((s..\python\lib\bdb.pytset_quits   c Cs|j|}ddl}|j||}|sAd||fS||jkr`g|j|scCsg}|r'|j|kr'|j}nxB|dk rk|j||jf||jkr_Pn|j}q*W|jtdt |d}x2|dk r|j|j|j f|j}qW|dkrtdt |d}n||fS(Nii( ttb_framettb_nextRR^R>RR/treversetmaxtlent tb_lineno(R tftttstackti((s..\python\lib\bdb.pyt get_stackDs      s: c Cs2ddl}ddl}|\}}|j|jj}d||f}|jjrh||jj}n |d}d|jkr|jd} nd} | r||j| }n |d}d|jkr|jd} |d}||j| }n|j|||j } | r.||| j }n|S(Nis%s(%r)st__args__s()t __return__s->( RR(RR?R@tco_nametf_localsRR]R;tstrip( R t frame_linenotlprefixRR(R)RHRtstargstrvR((s..\python\lib\bdb.pytformat_stack_entryXs*      cBs|dkr$ddl}|j}n|dkr9|}n|jej|je|ej sr|d}nz&y|||UWne k rnXWdd|_ ejdXdS(Nis i( Rt__main__t__dict__RRVRYR't isinstancettypestCodeTypeRR"(R tcmdtglobalstlocalsR((s..\python\lib\bdb.pytrunts          cCs|dkr$ddl}|j}n|dkr9|}n|jtj|jt|tj sr|d}nz,yt |||SWnt k rnXWdd|_ tjdXdS(Nis i( RRRRRVRYR'RRRtevalRR"(R texprRRR((s..\python\lib\bdb.pytrunevals          cCs|j|||dS(N(R(R RRR((s..\python\lib\bdb.pytrunctxscOsi|jtj|jd}z+y|||}Wntk rInXWdd|_tjdX|S(Ni(RRVRYR'RRR"(R tfuncRtkwdstres((s..\python\lib\bdb.pytruncalls   N(,RRRRR RRR'R#R$R%R&R:R,R-RFR0R1R.R3R4RRRRSRTRURZR[R\RbRfRkRmRnRoRpRqRrR}RRRRR(((s..\python\lib\bdb.pyRsT                              cCstjdS(N(RRZ(((s..\python\lib\bdb.pyRZscBs\eZdZdZiZdgZddddZdZdZ dZ ddZ RS( sBreakpoint class Implements temporary breakpoints, ignore counts, disabling and (re)-enabling, and conditionals. Breakpoints are indexed by number through bpbynumber and by the file,line tuple using bplist. The former points to a single instance of class Breakpoint. The latter points to a list of such instances since there may be more than one breakpoint per line. iicCs||_d|_||_||_||_||_d|_d|_d|_ t j |_ t j dt _ |j j|||f|jkr|j||fj|n|g|j||fR7R6R?RR(tbR)((s..\python\lib\bdb.pyt checkfuncnames  cCstj||f}xtdt|D]}||}|jdkrNq)nt||scq)n|jd|_|js|jdkr|jd|_q)q|dfSq)yTt |j|j |j }|r|jdkr|jd|_q|dfSnWq)|dfSXq)WdS(sDetermine which breakpoint for this file:line is to be acted upon. Called only if we know there is a bpt at this location. Returns breakpoint that was triggered and a flag that indicates if it is ok to delete a temporary bp. iiN(NN( RRctrangeRwRRRR_RRR;RR(RjRR)t possiblesR|Rtval((s..\python\lib\bdb.pyRB s.    tTdbcBs,eZdZdZdZdZRS(cCs,|jj}|sd}ndG|G|GHdS(Ns???s+++ call(R?R(R R)Rtname((s..\python\lib\bdb.pyR1Vs  cCs}ddl}|jj}|s'd}n|j|jj}|j||j|j}dG|G|jG|GdG|jGHdS(Nis???s+++t:( RR?RRR@R]R>R;R(R R)RRtfnR((s..\python\lib\bdb.pyR.Zs   cCs dG|GHdS(Ns +++ return((R R)tretval((s..\python\lib\bdb.pyR3ascCsdG|GH|jdS(Ns +++ exception(R[(R R)t exc_stuff((s..\python\lib\bdb.pyR4cs (RRR1R.R3R4(((s..\python\lib\bdb.pyRUs   cCs*dG|GdGHt|d}dG|GHdS(Nsfoo(t)i s bar returned(tbar(tntx((s..\python\lib\bdb.pytfoogs cCsdG|GdGH|dS(Nsbar(Ri((ta((s..\python\lib\bdb.pyRls cCst}|jddS(Nsimport bdb; bdb.foo(10)(RR(Rz((s..\python\lib\bdb.pyttestps (RR5RVRRt__all__t ExceptionRRRZRRRBRRRR(((s..\python\lib\bdb.pyts      T  5