m %UIc@sdZdkZdkZdkZdddgZdefdYZdfdYZdZdfdYZ d Z d Z d efd YZ d Z dZdZdS(sDebugger basicsNtBdbQuittBdbt BreakpointcBstZdZRS(sException to give up completely(t__name__t __module__t__doc__(((t /data/zmath/lib/python2.4/bdb.pyR s cBsvtZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZdZdZdZdZedZdZdZdeedZdZdZdZdZdZdZ dZ!d Z"d!Z#d"d#Z$eed$Z%eed%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. cCsh|_h|_dS(N(tselftbreakstfncache(R((Rt__init__s cCsv|d|dd!djo|Sn|ii|}|p5tii|}tii|}||i|( tfilenameRR tgettcanonictostpathtabspathtnormcase(RR R((RRscCs;dk}|id|_d|_d|_d|_dS(Ni(t linecachet checkcachetNoneRtbotframet stopframet returnframetquitting(RR((Rtreset$s      cCs|iodSn|djo|i|Sn|djo|i||Sn|djo|i||Sn|djo|i||Sn|djo |i Sn|djo |i Sn|djo |i SndGt |GH|i S( Ntlinetcalltreturnt exceptiontc_callt c_exceptiontc_returns*bdb.Bdb.dispatch: unknown debugging event:( RRteventt dispatch_linetframet dispatch_calltargtdispatch_returntdispatch_exceptionttrace_dispatchtrepr(RR%R#R'((RR*,s$           cCsL|i|p|i|o%|i||io tqEn|iS(N(Rt stop_hereR%t break_heret user_lineRRR*(RR%((RR$@s    cCsz|idjo|i|_|iSn|i|p |i|pdSn|i|||i o t n|iS(N( RRRR%tf_backR*R,tbreak_anywheret user_callR'RR(RR%R'((RR&Fs    cCsO|i|p||ijo(|i|||io tqHn|iS(N( RR,R%Rt user_returnR'RRR*(RR%R'((RR(Ss   cCs?|i|o(|i|||io tq8n|iS(N(RR,R%tuser_exceptionR'RRR*(RR%R'((RR)Ys  cCsb||ijotSnxC|dj o5||ij o%||ijotSn|i}qWtS(N(R%RRtTrueRRR/tFalse(RR%((RR,cscCs|i|ii}||ijotSn|i}||i|jo,|ii }||i|jotSqvnt |||\}}|o?|i|_|o$|io|it|intSntSdS(N(RRR%tf_codet co_filenameR RR5tf_linenotlinenotco_firstlinenot effectivetbptflagtnumbert currentbpt temporarytdo_cleartstrR4(RR%R R=R<R9((RR-ns    cCs tddS(Ns)subclass of bdb must implement do_clear()(tNotImplementedError(RR'((RRAscCs|ii|i|iiS(N(RRthas_keyRR%R6R7(RR%((RR0scCsdS(snThis method is called when there is the remote possibility that we ever need to stop in this function.N((RR%t argument_list((RR1scCsdS(s9This method is called when we stop or break at this line.N((RR%((RR.scCsdS(s5This method is called when a return trap is set here.N((RR%t return_value((RR2scCs|\}}}dS(smThis method is called if an exception occurs, but only if we are to stop at or just below this level.N(texc_typet exc_valuet exc_traceback(RR%t.4RGRHRI((RR3scCsd|_d|_d|_dS(sStop after one line of code.iN(RRRRR(R((Rtset_steps  cCs||_d|_d|_dS(s2Stop on the next line in or below the given frame.iN(R%RRRRR(RR%((Rtset_nexts  cCs"|i|_||_d|_dS(s)Stop when returning from the given frame.iN(R%R/RRRR(RR%((Rt set_returns  cCsu|djotii}n|ix*|o"|i|_||_ |i}q-W|i ti |idS(spStart debugging from `frame`. If frame is not specified, debugging starts from caller's frame. N( R%Rtsyst _getframeR/RRR*tf_traceRRKtsettrace(RR%((Rt set_traces     cCsz|i|_d|_d|_|ipNtidti i }x/|o#||ij o|` |i }qGWndS(Ni( RRRRRRRRNRQROR/R%RP(RR%((Rt set_continues     cCs/|i|_d|_d|_tiddS(Ni(RRRRRRRNRQ(R((Rtset_quits   ic Cs|i|}dk}|i||} | pd||fSn||ijog|i|Rt bpbynumberR<t IndexErrorRR^tfileR(RR'R>R<((Rtclear_bpbynumbers   cCs|i|}||ijo d|SnxC|i|D]4}ti||f}x|D]}|i qYWq9W|i|=dS(NsThere are no breakpoints in %s( RRR RRRR[tblistR<R\(RR RdR<R((Rtclear_all_file_breaks s cCsH|ipdSnx&tiD]}|o|iqqWh|_dS(NsThere are no breakpoints(RRRR`R<R\(RR<((Rtclear_all_breakss  cCs0|i|}||ijo||i|jS(N(RRR RR9(RR R9((Rt get_breakscCsK|i|}||ijo(||i|joti||fpgS(N(RRR RR9RR[(RR R9((Rt get_breaks!scCs6|i|}||ijo|i|SngSdS(N(RRR R(RR ((Rtget_file_breaks'scCs|iS(N(RR(R((Rtget_all_breaks.scCsg}|o|i|jo |i}nxF|dj o8|i||if||i joPn|i }q-W|i t dt |d}x4|dj o&|i|i|if|i}qW||fS(Nii(tstackttttb_frametfttb_nextRRWR8RRR/treversetmaxtlentit tb_lineno(RRnRlRsRk((Rt get_stack4s     s: c Cs0dk}dk}|\} } |i| ii}d|| f}| ii o|| ii }n |d}d| i jo| i d}nd}|o||i|}n |d}d| i jo.| i d}|d}||i|}n|i|| } | o||| i}n|S(Ns%s(%r)st__args__s()t __return__s->(RR+t frame_linenoR%R9RRR6R7R tstco_nametf_localstargsRtrvRURtlprefixtstrip( RRxR~R|R+R RRyR}RR%R9((Rtformat_stack_entryFs*      cBs|djodk}|i}n|djo |}n|iei|i e |e i p|d}nz(y|||UWnej onXWdd|_eidXdS(Ns i(tglobalsRt__main__t__dict__tlocalsRRRNRQR*t isinstancetcmdttypestCodeTypeRR(RRRRR((Rtrunbs"        cCs|djodk}|i}n|djo |}n|iti|i t |t i p|d}nz.yt|||SWntj onXWdd|_tidXdS(Ns i(RRRRRRRRNRQR*RtexprRRtevalRR(RRRRR((Rtrunevalus"        cCs|i|||dS(N(RRRRR(RRRR((RtrunctxscOsk|iti|id}z-y|||}Wnt j onXWdd|_ tidX|S(Ni( RRRNRQR*RtrestfuncR|tkwdsRR(RRR|RR((Rtruncalls   ()RRRR RRR*R$R&R(R)R,R-RAR0R1R.R2R3RKRLRMRRRRSRTRZR^RcReRfRgRhRiRjRuRRRRR(((RR sL                           cCstidS(N(RRR(((RRRscBsYtZdZdZhZegZdeedZdZdZ dZ dZ 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 i |_ t i dt _ |ii||ii||fo|i||fi|n|g|i||fR`RWR[RD(RRbRR@RXRY((RR s          cCsV|i|if}d|i|i<|i|i||i|p|i|=ndS(N( RRbRtindexRR`R>R[R](RR((RR\s cCs d|_dS(Ni(RR(R((RtenablescCs d|_dS(Ni(RR(R((RtdisablescCs|io d}nd}|io|d}n |d}d|i||i|ifGH|iod|ifGHn|iod|iGHn|i o6|i djo d }nd }d |i |fGHndS( Nsdel skeep syes sno s%-4dbreakpoint %s at %s:%ds stop only if %ss ignore next %d hitsiRyts! breakpoint already hit %d time%s( RR@tdispRR>RbRRXRRtss(RRR((Rtbpprints         ( RRRRR[RR`R R\RRR(((RRs     cCs|ip#|i|ijotSntSn|ii|ijotSn|i p|i|_ n|i |ijotSntS(s;Check whether we should break here because of `b.funcname`.N( tbRYRR%R8R5R4R6RzR(RR%((Rt checkfuncnames  cCs*ti||f}xtdt|D]}||}|i djoq)nt ||pq)n|i d|_ |i p5|idjo|id|_q)q"|dfSq)yXt|i |i|i}|o2|idjo|id|_q |dfSnWq)|dfSq)Xq)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(RR[RbRt possiblestrangeRrRsRRRR%RRXRRt f_globalsR{tvalR(RbRR%RRRsR((RR;s2   tTdbcBs,tZdZdZdZdZRS(NcCs.|ii}|p d}ndG|G|GHdS(Ns???s+++ call(R%R6RztnameR|(RR%R|R((RR1Es  cCsvdk}|ii}|p d}n|i|ii}|i ||i }dG|G|i G|GdG|i GHdS(Ns???s+++t:( RR%R6RzRRRR7tfnRUR8RR(RR%RRRR((RR.Is   cCs dG|GHdS(Ns +++ return(tretval(RR%R((RR2PscCsdG|GH|idS(Ns +++ exception(t exc_stuffRRS(RR%R((RR3Rs (RRR1R.R2R3(((RRDs   cCs*dG|GdGHt|d}dG|GHdS(Nsfoo(t)i s bar returned(tntbartx(RR((RtfooVs cCsdG|GdGH|dS(Nsbar(Ri(ta(R((RR[s cCst}|iddS(Nsimport bdb; bdb.foo(10)(RRlR(Rl((Rttest_s (RRNRRt__all__t ExceptionRRRRRRR;RRRR(RR;RRRRRRRNRRRRRR((Rt?s    R  5