m %UIc @sMdZdkZdkZdkZdkZdklZdkZdkZdk Z dk Z eZ de _ e iZ dddddd d d d g Zd ZdZdeieifdYZeedZeedZdZdZdZdZdZdZdZdZdZe djo endS(sA Python debugger.N(sRepritruntpmtPdbtrunevaltrunctxtruncallt set_tracet post_mortemthelpcCstid|}yt|}Wntj o dSnXd}d}xQ|i }|djoPn|i |o|||f}Pn|d}qLW|i|S(Nsdef\s+%s\s*[(]it(tretcompiletfuncnametcretopentfilenametfptIOErrortNonetlinenotanswertreadlinetlinetmatchtclose(R RRRR RR((t /data/zmath/lib/python2.4/pdb.pyt find_functions$    s -> cBstZdZdZdZdZdZdZdZdZ d Z d Z d Z d Z eiiZd dZdZeZdZdZdZdZdZdZdZdZeZdZeZeZ dZ!e!Z"dZ#e#Z$dZ%e%Z&dZ'e'Z(dZ)e)Z*dZ+e+Z,Z-dZ.e.Z/d Z0d!Z1e1Z2e1Z3d"Z4d#Z5e5Z6d$Z7e7Z8d%Z9d&Z:d'Z;d(Z<e<Z=d)Z>d*Z?d+Z@d,ZAeBd-ZCd.ZDd/ZEd0ZFd1ZGeGZHd2ZId3ZJd4ZKd5ZLd6ZMd7ZNd8ZOd9ZPd:ZQd;ZRd<ZSd=ZTd>ZUd?ZVd@ZWdAZXdBZYdCZZdDZ[dEZ\dFZ]dGZ^dHZ_dIZ`dJZadKZbdLZcdMZddNZedOZfdPZgdQZhdRZidSZjejZkdTZldUZmdVZndWZodXZpdYZqdZZrRS([NcCsRtii|tii|d|_h|_d|_d|_ y dk }Wnt j onXg|_ dt ijowt id}ytt ii|d}Wntj oqXx$|iD]}|i i|qW|inytd}Wntj on3Xx$|iD]}|i i|q*W|idS(Ns(Pdb) R itHOMEs.pdbrc(tbdbtBdbt__init__tselftcmdtCmdtprompttaliasest mainpyfilet_wait_for_mainpyfileRt ImportErrortrcLinestostenvirontenvHomeRtpathtjointrcFileRt readlinesRtappendR(RRRR*R-((RR7s:         cCstii||idS(N(RRtresetRtforget(R((RR0YscCs(d|_g|_d|_d|_dS(Ni(RRRtstacktcurindextcurframe(R((RR1]s   cCsM|i|i||\|_|_|i|id|_|idS(Ni( RR1t get_stacktfttR2R3R4t execRcLines(RR6R7((Rtsetupcs cCst|iof|i}g|_xQ|D]E}|d }t|djo"|ddjo|i|q#q#WndS(Niit#(RR'Rtlentonecmd(RR'R((RR8js    $cCs?|iodSn|i|odGH|i|dndS(snThis method is called when there is the remote possibility that we ever need to stop in this function.Ns--Call--(RR%t stop_heretframet interactionR(RR>t argument_list((Rt user_callws  cCsb|ioD|i|i|iijp|idjodSnd|_n|i|ddS(s;This function is called when we stop or break at this line.iN( RR%R$tcanonicR>tf_codet co_filenametf_linenoR?R(RR>((Rt user_lines  / cCs&||idtf_localsRR?R(RR>RH((Rt user_returns cCsu|\}}}||f|idRIttypet exc_type_namet__name__t _safereprRR?(RR>t.4RMRNRORQ((Rtuser_exceptions  cCs?|i|||i|i|i|i|idS(N( RR9R>t tracebacktprint_stack_entryR2R3tcmdloopR1(RR>RV((RR?s cBs|d djo|d}n|ii}|ii}y$e|ddd}|||UWnZe i d \}}e |e djo |}n |i}dG|d G|GHnXdS( Nit!s stsingleiR s***RL(RRR4RItlocalst f_globalstglobalsR tcodetsystexc_infoR7tvRPRQRR(RRR^RQR]R7RaR[((Rtdefaults    cCs'|ip|Sn|i}x|d|ijo|i|d}d}x8|dD],}|idt ||}|d}qZW|iddi |d}|i}q$W|ddjoX|i d}|djo8||di }|ii||| i}q#n|S( s*Handle alias expansion and ';;' separator.iit%s%*t taliass;;iN(RtstriptsplittargsRR#tiittmpArgtreplacetstrR,tfindtmarkertlstriptnexttcmdqueueR/trstrip(RRRhRpRiRnRj((Rtprecmds,     icCs|pG|io5dGHx-tiiD]} | o| iq#q#WndSnd}d} d}|i d}|djo(||di}|| i}n|id}d}|djo|| i}|i|}|pdGt|GdGHdSn|}||di}yt|} WqRtj o} dG|GHdSqRXnyt|} Wntj oy"t||ii|ii}Wn |}nXyEt|d o |i}n|i }|i"}|i#} |i$}WqR|i%|\} }}| p d Gt|Gd GHd GHdSn| }t|} qRXnX|p|i(}n|i)|| } | od|i+|| |||}|o d G|GHq|i.|| d} d| i/| i0| i*fGHndS(Ns!Num Type Disp Enb Wheret,iiRLs*** snot found from sys.paths*** Bad lineno:tim_funcs*** The specified objectsis not a functions or was not found along sys.path.s***isBreakpoint %d at %s:%d(1targRtbreaksRt Breakpointt bpbynumbertbptbpprintRRRtcondRmtcommaRoRrtrfindtcolonR t lookupmoduleR6treprtintt ValueErrortmsgtevalR4R\RItfuncthasattrRut func_codeR^tco_nametco_firstlinenoRDtlineinfotoktlnt defaultFilet checklineRt set_breakt temporaryterrt get_breakstnumbertfile(RRvRR^RR|RRRRRRzRRRR6R R}((Rtdo_breaks               cCs7|iii}|djo|io |i}n|S(sProduce a reasonable default.sN(RR4RCRDRR$(RR((RR"s  cCs|i|ddS(Ni(RRRv(RRv((Rt do_tbreak+sc Cs7d}|id}t|djo|di} n,t|djo|di} n|S| djo|Sn| id}|ddjo&|d=t|djo|Sqn|i }t|djo|d}n/|i |d}|o |}n|d}t||}|p|S( Nt'iiiR t.R(NNN(Rtfailedt identifierRgtidstringR;RftidtpartsRRtfnametitemRR6RR( RRRRR6RRRRR((RR.s.     cCs~ti||}|p dGHdSn|i}| p3|ddjp"|d djp|d djo dGHdSn|S( sCheck whether specified line seems to be executable. Return `lineno` if it is, 0 if not (e.g. a docstring, comment, blank line or EOF). Warning: testing is not comprehensive. s End of fileiR:is"""s'''s*** Blank or commentN(t linecachetgetlineRRRRf(RRRR((RROs ;cCs|i}x|D]}yt|}Wntj od|GHqnXd|jottii jnpdG|GHqntii |}|o|i qqWdS(Ns#Breakpoint index %r is not a numberisNo breakpoint numbered( RvRgRhtiRRR;RRxRyRztenable(RRvRRhRz((Rt do_enableas  * cCs|i}x|D]}yt|}Wntj od|GHqnXd|jottii jnpdG|GHqntii |}|o|i qqWdS(Ns#Breakpoint index %r is not a numberisNo breakpoint numbered( RvRgRhRRRR;RRxRyRztdisable(RRvRRhRz((Rt do_disablers  * cCs|idd}t|di}y|d}Wn d}nXti i |}|o%||_|pdG|GdGHqndS(NRdiiRxsis now unconditional.( RvRgRhRRftbpnumR|RRRxRyRz(RRvRhR|RzR((Rt do_conditions  cCs|i}t|di}yt|di}Wn d}nXtii |}|og||_ |djo@d}|djo|d|}n |d}|d|GHqdG|GdGHnd S( s*arg is bp number followed by ignore count.iisWill ignore next s %d crossingss 1 crossings of breakpoint %d.sWill stop next time breakpoints is reached.N( RvRgRhRRfRtcountRRxRyRztignoretreply(RRvRRhRzRR((Rt do_ignores$      cCs|paytd}Wntj o d}nX|ii}|djo|indSnd|jo|id}|| }||d}yt |}Wnt j od|}nX|i||}|o d G|GHndSn|i}x|D]}yt |}Wnt j od |GHq nXd |jottiijnpd G|GHq n|i|}|o d G|GHq d G|GHq WdS(sThree possibilities, tried in this order: clear -> clear all breaks, ask for confirmation clear file:lineno -> clear all breaks at file:lineno clear bpno bpno ... -> clear breakpoints by numbersClear all breaks? tnotytyesNRLisInvalid line number (%s)s***s#Breakpoint index %r is not a numberisNo breakpoint numberedsDeleted breakpoint(Rsyes(Rvt raw_inputRtEOFErrorRftlowerRtclear_all_breaksR~RRRRRRt clear_breakRgt numberlistR;RRxRytclear_bpbynumber(RRvRRRRRR((Rtdo_clearsJ       *  cCs|idS(N(Rtprint_stack_trace(RRv((Rtdo_wherescCsd|idjo dGHnH|id|_|i|id|_|i|i|id|_dS(Nis*** Oldest framei(RR3R2R4RWRR(RRv((Rtdo_ups  cCsq|idt|ijo dGHnH|id|_|i|id|_|i|i|id|_dS(Nis*** Newest framei(RR3R;R2R4RWRR(RRv((Rtdo_downs  cCs|idS(Ni(Rtset_step(RRv((Rtdo_steps cCs|i|idS(Ni(Rtset_nextR4(RRv((Rtdo_nextscCs|i|idS(Ni(Rt set_returnR4(RRv((Rt do_returnscCs|idS(Ni(Rt set_continue(RRv((Rt do_continues cCs|idt|ijo dGHdSnyt|}Wntj o dGHnnXyK||i_|i|id|f|i|i<|i |i|iWntj o}dG|GHnXdS(Nis-*** You can only jump within the bottom frames.*** The 'jump' command requires a line number.is*** Jump failed:( RR3R;R2RRvRR4RERWte(RRvR((Rtdo_jumps  $cCstid|ii}|ii}t }d|i i |_ dGHti |i|||fdGHti|i|i|_dS(Ns(%s) sENTERING RECURSIVE DEBUGGERsLEAVING RECURSIVE DEBUGGER(R_tsettraceRRR4R\R]RIR[RtpR"Rft call_tracingRRvttrace_dispatchtlastcmd(RRvRR]R[((Rtdo_debugs    cCsd|_|idS(Ni(Rt_user_requested_quittset_quit(RRv((Rtdo_quit!s  cCsHd|_|idS(Ni(RRR(RRv((Rtdo_EOF)s  cCs|i}|i}|i}|i}|i d@o|d}n|i d@o|d}nxHt |D]:}|i |}|GdG||jo ||GHqidGHqiWdS(Niiit=s*** undefined ***(RR4R6RCtcoRItdictt co_argcounttntco_flagstrangeRt co_varnamestname(RRvRRR6RRR((Rtdo_args/s       cCs/d|iijo|iidGHndGHdS(NRGs*** Not yet returned!(RR4RI(RRv((Rt do_retval=scCsy t||ii|iiSWnZtid \}}t |t o |}n |i }dG|dGt|GHnXdS(Nis***RL(RRvRR4R\RIR_R`R7Rat isinstanceRlRQRRR(RRvRQR7Ra((Rt_getvalDs  cCs&yt|i|GHWnnXdS(N(RRRRv(RRv((Rtdo_pPscCs(yti|i|WnnXdS(N(tpprintRRRv(RRv((Rtdo_ppVsc Cs%d|_d}|oyt|hh}t|tfjoC|\} }t | } t |}|| jo| |}qnt dt |d} WqdGt |GHdSqXn;|i djot d|i id} n|i d} |djo| d}n|i ii}|i|}yxt| |dD]}ti||}|p dGHPqLt |id}t|djo|d }n||jo|d }n |d }||i ijo|d }n|d |G||_ qLWWntj onXdS( Ntlistiis*** Error in argument:i s[EOF]iiRdtBs->s (RRRtlastRvRtxRPtfirstRtmaxRRR4RERCRDRtget_file_breakst breaklistRRRRtrjusttsR;tKeyboardInterrupt( RRvRRRRRRRR((Rtdo_list\sR           cCsy"t||ii|ii}Wndtid \}}t |t djo |}n |i }dG|dGt|GHdSnXd}y |i}WnnX|odG|iGHdSny|ii}WnnX|odG|iGHdSnt |GHdS(NiR s***RLtFunctiontMethod(RRvRR4R\RItvalueR_R`R7RaRPRQRRRRR^RRRu(RRvR^RQRR7Ra((Rt do_whatiss4     cCs|i}t|djoH|ii}|ix$|D]}d||i|fGHq?WdSn|d|ijo5t|djo"d|d|i|dfGHndi |d|i|dRd(RR>RRR4tformat_stack_entryt prompt_prefix(RRRR>R((RRWs  cCs|idS(N(Rthelp_h(R((Rt help_helpscCs dGHdS(Nsh(elp) Without argument, print the list of available commands. With a command name as argument, print help about that command "help pdb" pipes the full documentation file to the $PAGER "help exec" gives help on the ! command((R((RRscCs|idS(N(Rthelp_w(R((Rt help_wherescCs dGHdS(Nsw(here) Print a stack trace, with the most recent frame at the bottom. An arrow indicates the "current frame", which determines the context of most commands. 'bt' is an alias for this command.((R((RRscCs|idS(N(Rthelp_d(R((Rt help_downscCs dGHdS(NsSd(own) Move the current frame one level down in the stack trace (to a newer frame).((R((RRscCs|idS(N(Rthelp_u(R((Rthelp_upscCs dGHdS(NsPu(p) Move the current frame one level up in the stack trace (to an older frame).((R((RRscCs|idS(N(Rthelp_b(R((Rt help_breakscCs dGHdS(NsFb(reak) ([file:]lineno | function) [, condition] With a line number argument, set a break there in the current file. With a function name, set a break at first executable line of that function. Without argument, list all breaks. If a second argument is present, it is a string specifying an expression which must evaluate to true before the breakpoint is honored. The line number may be prefixed with a filename and a colon, to specify a breakpoint in another file (probably one that hasn't been loaded yet). The file is searched for on sys.path; the .py suffix may be omitted.((R((RRscCs|idS(N(Rthelp_cl(R((Rt help_clearscCsdGHdGHdS(Nscl(ear) filename:linenoscl(ear) [bpnumber [bpnumber...]] With a space separated list of breakpoint numbers, clear those breakpoints. Without argument, clear all breaks (but first ask confirmation). With a filename:lineno argument, clear all breaks at that line in that file. Note that the argument is different from previous versions of the debugger (in python distributions 1.5.1 and before) where a linenumber was used instead of either filename:lineno or breakpoint numbers.((R((RR scCs dGHdS(NsJtbreak same arguments as break, but breakpoint is removed when first hit.((R((Rt help_tbreakscCs dGHdS(Nseenable bpnumber [bpnumber ...] Enables the breakpoints given as a space separated list of bp numbers.((R((Rt help_enablescCs dGHdS(Nsgdisable bpnumber [bpnumber ...] Disables the breakpoints given as a space separated list of bp numbers.((R((Rt help_disablescCs dGHdS(Ns(ignore bpnumber count Sets the ignore count for the given breakpoint number. A breakpoint becomes active when the ignore count is zero. When non-zero, the count is decremented each time the breakpoint is reached and the breakpoint is not disabled and any associated condition evaluates to true.((R((Rt help_ignore$scCs dGHdS(Nscondition bpnumber str_condition str_condition is a string specifying an expression which must evaluate to true before the breakpoint is honored. If str_condition is absent, any existing condition is removed; i.e., the breakpoint is made unconditional.((R((Rthelp_condition,scCs|idS(N(Rthelp_s(R((Rt help_step3scCs dGHdS(Nss(tep) Execute the current line, stop at the first possible occasion (either in a function that is called or in the current function).((R((RR 6scCs|idS(N(Rthelp_n(R((Rt help_next;scCs dGHdS(Ns_n(ext) Continue execution until the next line in the current function is reached or it returns.((R((RR >scCs|idS(N(Rthelp_r(R((Rt help_returnCscCs dGHdS(Ns?r(eturn) Continue execution until the current function returns.((R((RRFscCs|idS(N(Rthelp_c(R((Rt help_continueJscCs|idS(N(RR(R((Rt help_contMscCs dGHdS(NsLc(ont(inue)) Continue execution, only stop when a breakpoint is encountered.((R((RRPscCs|idS(N(Rthelp_j(R((Rt help_jumpTscCs dGHdS(Ns6j(ump) lineno Set the next line that will be executed.((R((RRWscCs dGHdS(Nsdebug code Enter a recursive debugger that steps through the code argument (which is an arbitrary expression or statement to be executed in the current environment).((R((Rt help_debug[scCs|idS(N(Rthelp_l(R((Rt help_listascCs dGHdS(Ns8l(ist) [first [,last]] List source code for the current file. Without arguments, list 11 lines around the current line or continue the previous listing. With one argument, list 11 lines starting at that line. With two arguments, list the given range; if the second argument is less than the first, it is a count.((R((RRdscCs|idS(N(Rthelp_a(R((Rt help_argsmscCs dGHdS(Ns3a(rgs) Print the arguments of the current function.((R((RRpscCs dGHdS(Ns/p expression Print the value of the expression.((R((Rthelp_ptscCs dGHdS(Ns7pp expression Pretty-print the value of the expression.((R((Rthelp_ppxscCs dGHdS(Ns[(!) statement Execute the (one-line) statement in the context of the current stack frame. The exclamation point can be omitted unless the first word of the statement resembles a debugger command. To assign to a global variable you must always prefix the command with a 'global' command, e.g.: (Pdb) global list_options; list_options = ['-l'] (Pdb)((R((Rt help_exec|scCs|idS(N(Rthelp_q(R((Rt help_quitscCs dGHdS(NsOq(uit) or exit - Quit from the debugger. The program being executed is aborted.((R((RRscCs dGHdS(Ns+whatis arg Prints the type of the argument.((R((Rt help_whatisscCs dGHdS(Ns,EOF Handles the receipt of EOF as a command.((R((Rthelp_EOFscCs dGHdS(Nsalias [name [command [parameter parameter ...] ]] Creates an alias called 'name' the executes 'command'. The command must *not* be enclosed in quotes. Replaceable parameters are indicated by %1, %2, and so on, while %* is replaced by all the parameters. If no command is given, the current alias for name is shown. If no name is given, all aliases are listed. Aliases may be nested and can contain anything that can be legally typed at the pdb prompt. Note! You *can* override internal pdb commands with aliases! Those internal commands are then hidden until the alias is removed. Aliasing is recursively applied to the first word of the command line; all other words in the line are left alone. Some useful aliases (especially when placed in the .pdbrc file) are: #Print instance variables (usage "pi classInst") alias pi for k in %1.__dict__.keys(): print "%1.",k,"=",%1.__dict__[k] #Print instance variables in self alias ps pi self ((R((Rt help_aliasscCs dGHdS(Ns)unalias name Deletes the specified alias.((R((Rt help_unaliasscCs tdS(N(R(R((Rthelp_pdbscCs>tii|otii|o|Sntiitid|}tii|o!|i ||i jo|Sntii |\}}|djo|d}ntii|o|SnxktiD]`}x'tii|oti|}qWtii||}tii|o|SqqWdS(sHelper function for break/clear parsing -- may be overridden. lookupmodule() translates (possibly incomplete) file or module name into an absolute file name. iR s.pyN(R(R+tisabsRtexistsR,R_R6RRBR$tsplitexttroottexttdirnametislinktreadlinktfullnameR(RRR6R(R,R)R'((RRs(&,   cCs`hdd<}|}d|_|i||_d|_d|}|i |d|d|dS(NRRt__main__iisexecfile( "%s")R]R[( tglobals_tlocals_RR%RBRR$Rt statementR(RRR/R.R0((Rt _runscripts   (sRRt __module__RR0R1R9R8RARFRJRUR?RbRsR R!tdo_helptdo_hRRtdo_bRRRRRRRRtdo_clRtdo_wtdo_btRtdo_uRtdo_dRtdo_sRtdo_nRtdo_rRtdo_ctdo_contRtdo_jRRtdo_qtdo_exitRRtdo_aRtdo_rvRRRRtdo_lRRRRt line_prefixRWRRRRthelp_btRRRRRRRRRRRRR R R R R RRRRRRRRRRRRRRRRRt help_exitRR R!R"R#RR1(((RR5s "         T   !      +                +                                           cCsti|||dS(N(RRR0R]R[(R0R]R[((RRscCsti|||S(N(RRt expressionR]R[(RIR]R[((RRscCst|||dS(N(RR0R]R[(R0R]R[((RRscOsti||S(N(RRRhtkwds(RhRJ((RRscCstitiidS(N(RRR_t _getframetf_back(((RRscCsKt}|ix|idj o |i}qW|i|i|dS(N(RRR0R7ttb_nextRR?ttb_frame(R7R((RRs   cCsttidS(N(RR_tlast_traceback(((RRssimport x; x.main()cCsttdS(N(RtTESTCMD(((RttestscCsuxntiD]Z}tii|d}tii|o,tid|}|o dG|GHnPq q WdGdGHdS(Nspdb.docs${PAGER-more} s*** Pager exit status:s)Sorry, can't find the help file "pdb.doc"salong the Python search path( R_R+R)R(R,R,R%tsystemtsts(R,R)RS((RRs   cCsStidpdGHtidntid}tii|pdG|GdGHtidntid=tii|tid