B °-_Nôã"@sädZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z Gdd„deƒZddddd d d d d g Zdd„Zdd„Zdd„ZGdd„deƒZdZGdd„dejejƒZedk rbd ddddddddd d!d"d#d$d%d&d'd(dd)d*d+d,d-d.d/d0d1d2d3d4d5d6d7g"Zx*eD]"Zeeed8eƒj ¡d97Zq,Weejj7Z[[dJd:d„ZdKd;d„Z dœd?d „Z#dLd@d „Z$dAd„Z%dBZ&dCdD„Z'dEd „Z(dFZ)dGdH„Z*e+dIkràddl,Z,e, *¡dS)Ma½ The Python Debugger Pdb ======================= To use the debugger in its simplest form: >>> import pdb >>> pdb.run('') The debugger's prompt is '(Pdb) '. This will stop in the first function call in . Alternatively, if a statement terminated with an unhandled exception, you can use pdb's post-mortem facility to inspect the contents of the traceback: >>> >>> import pdb >>> pdb.pm() The commands recognized by the debugger are listed in the next section. Most can be abbreviated as indicated; e.g., h(elp) means that 'help' can be typed as 'h' or 'help' (but not as 'he' or 'hel', nor as 'H' or 'Help' or 'HELP'). Optional arguments are enclosed in square brackets. Alternatives in the command syntax are separated by a vertical bar (|). A blank line repeats the previous command literally, except for 'list', where it lists the next 11 lines. Commands that the debugger doesn't recognize are assumed to be Python statements and are executed in the context of the program being debugged. Python statements can also be prefixed with an exclamation point ('!'). This is a powerful way to inspect the program being debugged; it is even possible to change variables or call functions. When an exception occurs in such a statement, the exception name is printed but the debugger's state is not changed. The debugger supports aliases, which can save typing. And aliases can have parameters (see the alias help entry) which allows one a certain level of adaptability to the context under examination. Multiple commands may be entered on a single line, separated by the pair ';;'. No intelligence is applied to separating the commands; the input is split at the first ';;', even if it is in the middle of a quoted string. If a file ".pdbrc" exists in your home directory or in the current directory, it is read in and executed as if it had been typed at the debugger prompt. This is particularly useful for aliases. If both files exist, the one in the home directory is read first and aliases defined there can be overridden by the local file. This behavior can be disabled by passing the "readrc=False" argument to the Pdb constructor. Aside from aliases, the debugger is not directly programmable; but it is implemented as a class from which you can derive your own debugger class, which you can make as fancy as you like. Debugger commands ================= éNc@seZdZdZdS)ÚRestartzBCauses a debugger to be restarted for the debugged python program.N)Ú__name__Ú __module__Ú __qualname__Ú__doc__©rrú/usr/lib/python3.7/pdb.pyrUsrÚrunÚpmÚPdbÚrunevalÚrunctxÚruncallÚ set_traceÚ post_mortemÚhelpc Csxt dt |¡¡}y t|ƒ}Wntk r4dSX|4x,t|ddD]\}}| |¡rJ|||fSqJWWdQRXdS)Nzdef\s+%s\s*[(]é)Ústart)ÚreÚcompileÚescapeÚopenÚOSErrorÚ enumerateÚmatch)ÚfuncnameÚfilenameZcreÚfpÚlinenoÚlinerrrÚ find_function\s  r cCsXt |¡\}}t |¡r,|j|jkr,|dfSt |¡r>|dfSt ||d…¡|dfS)Nr)ÚinspectZ findsourceZisframeÚ f_globalsÚf_localsZismoduleZgetblock)ÚobjÚlinesrrrrÚgetsourcelinesis  r&cCs8tt |¡ƒ}| ¡x|D]\}}||kr|SqWdS)Nr)ÚlistÚdisZfindlinestartsÚreverse)ÚcodeZlastiZ linestartsÚirrrrÚ lasti2linenors r,c@seZdZdZdd„ZdS)Ú_rstrz#String that doesn't quote its repr.cCs|S)Nr)ÚselfrrrÚ__repr__}sz_rstr.__repr__N)rrrrr/rrrrr-{sr-z -> c@seZdZdZd£dd„Zdd„Zd d „Zd d „Zd d„Zdd„Z dd„Z dd„Z dd„Z dd„Z dd„Zdd„Zdd„Zdd „Zd!d"„Zd#d$„Zd%d&„Zd'd(„Zd)d*„Zd+d,„Zd-d.„Zd/d0„Zd1d2„Zd3d4„Zd5d6„ZeZd¤d8d9„Zd:d;„ZeZ eZ!eZ"dd?„Z%d@dA„Z&dBdC„Z'eZ(dDdE„Z)eZ*dFdG„Z+eZ,dHdI„Z-eZ.dJdK„Z/e/Z0eZ1eZ2dLdM„Z3e3Z4e3Z5dNdO„Z6dPdQ„Z7e7Z8dRdS„Z9e9Z:dTdU„Z;e;ZdXdY„Z?e?Z@dZd[„ZAeAZBd\d]„ZCeCZDd^d_„ZEeEZFZGd`da„ZHeHZIdbdc„ZJeZKddde„ZLeLZMeLZNdfdg„ZOdhdi„ZPePZQdjdk„ZReRZSdldm„ZTd¥dndo„ZUdpdq„ZVdrds„ZWeZXeZYeZZdtdu„Z[e[Z\dvdw„Z]e]Z^dxdy„Z_eZ`d¦d{d|„Zad}d~„ZbeZcdd€„ZdeZedd‚„Zfdƒd„„Zgd…d†„Zhd‡dˆ„Zid‰dŠ„Zjd‹dŒ„ZkddŽddd‘d’gZld“d”„Zmenfd•d–„Zod—d˜„ZpepZqd™dš„Zrd›dœ„Zsddž„ZtdŸd „Zud¡d¢„ZvdS)§r NÚtabFTc CsJtjj||dtj ||||¡|r,d|_d|_i|_i|_d|_ d|_ i|_ yddl }|  d¡Wntk rzYnXd|_||_g|_|r(dtjkrìtjd}y.ttj |d¡ƒ} |j | ¡WdQRXWntk rêYnXy$tdƒ} |j | ¡WdQRXWntk r&YnXi|_i|_i|_d|_d|_dS) N)Úskiprz(Pdb) ÚFz `@#$%^&*()=+[{]}\|;:'",<>?ÚHOMEz.pdbrc)ÚbdbÚBdbÚ__init__ÚcmdÚCmdZ use_rawinputÚpromptÚaliasesÚ displayingÚ mainpyfileÚ_wait_for_mainpyfileÚ tb_linenoÚreadlineZset_completer_delimsÚ ImportErrorÚ allow_kbdintÚnosigintÚrcLinesÚosÚenvironrÚpathÚjoinÚextendrÚcommandsÚcommands_dopromptÚcommands_silentÚcommands_definingÚ commands_bnum) r.Ú completekeyÚstdinÚstdoutr1rBZreadrcr?ZenvHomeZrcFilerrrr6ŒsH   z Pdb.__init__cCs*|jr t‚| d¡| ¡| |¡dS)Nz- Program interrupted. (Use 'cont' to resume).)rAÚKeyboardInterruptÚmessageÚset_stepr)r.ZsignumÚframerrrÚsigint_handler¼s  zPdb.sigint_handlercCstj |¡| ¡dS)N)r4r5ÚresetÚforget)r.rrrrVÃs z Pdb.resetcCs&d|_g|_d|_d|_|j ¡dS)Nr)rÚstackÚcurindexÚcurframer>Úclear)r.rrrrWÇs z Pdb.forgetcCsl| ¡| ||¡\|_|_x*|rFt|jj|jƒ}||j|j<|j }qW|j|jd|_ |j j |_ |  ¡S)Nr)rWZ get_stackrXrYr,Útb_frameÚf_codeÚtb_lastir>Útb_nextrZr#Úcurframe_localsÚ execRcLines)r.ÚfÚtbrrrrÚsetupÎs   z Pdb.setupcCsh|js dS|j}| ¡g|_xD|rb| ¡ ¡}|r |ddkr | |¡r |jt|ƒ7_dSq WdS)Nrú#T)rCr)ÚpopÚstripÚonecmdÚreversed)r.rCrrrrraàs  zPdb.execRcLinescCs.|jr dS| |¡r*| d¡| |d¡dS)znThis method is called when there is the remote possibility that we ever need to stop in this function.Nz--Call--)r=Z stop_hererRÚ interaction)r.rTZ argument_listrrrÚ user_callôs   z Pdb.user_callcCsH|jr.|j| |jj¡ks$|jdkr(dSd|_| |¡rD| |d¡dS)z;This function is called when we stop or break at this line.rNF)r=r<Úcanonicr]Ú co_filenameÚf_linenoÚ bp_commandsrj)r.rTrrrÚ user_lineýs  z Pdb.user_linecCs˜t|ddƒr”|j|jkr”|j}d|_|j}| |d¡x|j|D]}| |¡qBW||_|j|sv| |j|j ¡|j |rˆ|  ¡|  ¡dSdS)z¾Call every command that was set for the current active breakpoint (if there is one). Returns True if the normal interaction function must be called, False otherwise.Ú currentbpFrNr) ÚgetattrrqrIÚlastcmdrdrhrKÚprint_stack_entryrXrYrJÚ_cmdlooprW)r.rTrqZ lastcmd_backrrrrros      zPdb.bp_commandscCs.|jr dS||jd<| d¡| |d¡dS)z7This function is called when a return trap is set here.NÚ __return__z --Return--)r=r#rRrj)r.rTZ return_valuerrrÚ user_returns   zPdb.user_returncCsh|jr dS|\}}}||f|jd<|s2|tkr2dnd}| d|t ||¡d ¡f¡| ||¡dS)zoThis function is called if an exception occurs, but only if we are to stop at or just below this level.NZ __exception__z Internal r2z%s%séÿÿÿÿ)r=r#Ú StopIterationrRÚ tracebackÚformat_exception_onlyrgrj)r.rTÚexc_infoÚexc_typeÚ exc_valueÚ exc_tracebackÚprefixrrrÚuser_exception's zPdb.user_exceptioncCsDx>yd|_| ¡d|_PWqtk r:| d¡YqXqWdS)NTFz--KeyboardInterrupt--)rAÚcmdlooprQrR)r.rrrru;sz Pdb._cmdloopcCsb|j |j¡}|r^xJ| ¡D]>\}}| |¡}||k r||kr|||<| d|||f¡qWdS)Nzdisplay %s: %r [old: %r])r;ÚgetrZÚitemsÚ_getval_exceptrR)r.r;ÚexprZoldvalueZnewvaluerrrÚpreloopHs z Pdb.preloopcCsZtjrt tjtj¡dt_| ||¡r4| ¡dS| |j|j¡|  ¡| ¡dS)N) r Ú_previous_sigint_handlerÚsignalÚSIGINTrdrWrtrXrYru)r.rTrzrrrrjUs zPdb.interactioncCs|dk r| t|ƒ¡dS)z{Custom displayhook for the exec in default(), which prevents assignment of the _ variable in the builtins. N)rRÚrepr)r.r$rrrÚ displayhookcszPdb.displayhookc CsÈ|dd…dkr|dd…}|j}|jj}ydt|dddƒ}tj}tj}tj}z(|jt_|jt_|jt_t|||ƒWd|t_|t_|t_XWn4t  ¡dd…}|  t j |Žd  ¡¡YnXdS)Nrú!Ú zZsingleérx)r`rZr"rÚsysrPrOrŒÚexecr|Úerrorrzr{rg) r.rÚlocalsÚglobalsr*Z save_stdoutZ save_stdinZsave_displayhookr|rrrÚdefaultks(  z Pdb.defaultcCsà| ¡s |S| ¡}xx|d|jkrŒ|j|d}d}x0|dd…D] }| dt|ƒ|¡}|d7}qDW| dd |dd…¡¡}| ¡}qW|ddkrÜ| d¡}|dkrÜ||d d… ¡}|j  |¡|d|…  ¡}|S) z*Handle alias expansion and ';;' separator.rrNú%z%*ú Úaliasz;;r) rgÚsplitr:ÚreplaceÚstrrGÚfindÚlstripÚcmdqueueÚappendÚrstrip)r.rÚargsZiiZtmpArgZmarkerÚnextrrrÚprecmds&     z Pdb.precmdcCs"|jstj ||¡S| |¡SdS)zÒInterpret the argument as though it had been typed in response to the prompt. Checks whether this line is typed at the normal prompt or in a breakpoint command list definition. N)rLr7r8rhÚhandle_command_def)r.rrrrrhšsz Pdb.onecmdcCsÄ| |¡\}}}|sdS|dkr0d|j|j<dS|dkrBg|_dS|j|j}|rf| |d|¡n | |¡yt|d|ƒ}Wntk rœ|j}YnX|j |j krÀd|j |j<g|_dSdS) z8Handles one command line during command list definition.NZsilentTÚendrr—Údo_F) Z parselinerKrMržrIrŸrrÚAttributeErrorr•rÚcommands_resumingrJ)r.rr7ÚargZcmdlistÚfuncrrrr¤¦s,      zPdb.handle_command_defcCst||jddS)N)Úfile)ÚprintrP)r.ÚmsgrrrrRÄsz Pdb.messagecCstd||jddS)Nz***)r«)r¬rP)r.r­rrrr’Çsz Pdb.errorcCs¤| ¡ d¡rgSy| ||||¡}Wntk r>g}YnXt |d¡}xP|D]H}tj |¡rt| |d¡qTtj  |¡rT|  ¡ d¡rT| |d¡qTW|S)N)ú:ú,Ú*ú/)z.pyz.pywr®) rgÚendswithÚ_complete_expressionÚ ExceptionÚglobrDrFÚisdirrŸÚisfileÚlower)r.ÚtextrÚbegidxÚendidxZretÚglobsÚfnrrrÚ_complete_locationÍs   zPdb._complete_locationcs‡fdd„ttjjƒDƒS)Ncs.g|]&\}}|dk rt|ƒ ˆ¡rt|ƒ‘qS)N)r›Ú startswith)Ú.0r+Úbp)r¹rrú äsz*Pdb._complete_bpnumber..)rr4Ú BreakpointÚ bpbynumber)r.r¹rrºr»r)r¹rÚ_complete_bpnumberàszPdb._complete_bpnumberc sÆ|js gS|jj ¡}| |j¡dˆkr¬ˆ d¡‰y0|ˆd}xˆdd…D]}t||ƒ}qPWWnttfk r|gSXd  ˆdd…¡d‰‡‡fdd„t |ƒDƒS‡fdd„|  ¡DƒSdS)NÚ.rrrxcs"g|]}| ˆd¡rˆ|‘qS)rx)r¿)rÀÚn)Údottedr€rrrÂüsz,Pdb._complete_expression..csg|]}| ˆ¡r|‘qSr)r¿)rÀrÇ)r¹rrrÂÿs) rZr"ÚcopyÚupdater`r™rrÚKeyErrorr§rGÚdirÚkeys)r.r¹rrºr»Únsr$Úpartr)rÈr€r¹rr³çs    zPdb._complete_expressioncCs(|sttjjƒd}n"y t|ƒ}Wn| d¡dS||_||jkrf|j||j||j |f}nd}g|j|<d|j|<d|j |<|j }d|_ d|_ zzy |  ¡Wnht k r|rê|d|j|<|d|j|<|d|j |<n|j|=|j|=|j |=| d ¡YnXWdd|_ ||_ XdS) a4commands [bpnumber] (com) ... (com) end (Pdb) Specify a list of commands for breakpoint number bpnumber. The commands themselves are entered on the following lines. Type a line containing just 'end' to terminate the commands. The commands are executed when the breakpoint is hit. To remove all commands from a breakpoint, type commands and follow it immediately with end; that is, give no commands. With no bpnumber argument, commands refers to the last breakpoint set. You can use breakpoint commands to start your program up again. Simply use the continue command, or step, or any other command that resumes execution. Specifying any command resuming execution (currently continue, step, next, return, jump, quit and their abbreviations) terminates the command list (as if that command was immediately followed by end). This is because any time you resume execution (even with a simple next or step), you may encounter another breakpoint -- which could have its own command list, leading to ambiguities about which list to execute. If you use the 'silent' command in the command list, the usual message about stopping at a breakpoint is not printed. This may be desirable for breakpoints that are to print a specific message and then continue. If none of the other commands print anything, you will see no sign that the breakpoint was reached. rz.Usage: commands [bnum] ... endNTFz(com) rrz1command definition aborted, old commands restored)Úlenr4rÃrÄÚintr’rMrIrJrKr9rLr‚rQ)r.r©ZbnumZold_command_defsZ prompt_backrrrÚ do_commandss@%       zPdb.do_commandsrc Cs@|s<|jr8| d¡x"tjjD]}|r| | ¡¡qWdSd}d}d}| d¡}|dkr~||dd… ¡}|d|… ¡}|  d¡}d} |dkr|d|… ¡}|  |¡} | sÆ|  d|¡dS| }||dd… ¡}y t |ƒ}Wn$t k r|  d|¡dSXn¼y t |ƒ}Wn®t k rÌyt||jj|jƒ} Wn|} YnXy.t| d ƒrl| j} | j} | j} | j}| j}Wn@| |¡\} }}| s¶|  d |¡dS| } t |ƒ}YnXYnX|sÜ| ¡}| ||¡}|r<| ||||| ¡}|r|  |¡n*| ||¡d }| d |j|j|jf¡dS) a²b(reak) [ ([filename:]lineno | function) [, condition] ] Without argument, list all breaks. With a line number argument, set a break at this line in the current file. With a function name, set a break at the first executable line of that function. 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. z!Num Type Disp Enb WhereNr¯rrr®z%r not found from sys.pathzBad lineno: %sÚ__func__zJThe specified object %r is not a function or was not found along sys.path.rxzBreakpoint %d at %s:%d) ÚbreaksrRr4rÃrÄZbpformatrœrr ÚrfindÚ lookupmoduler’rÑÚ ValueErrorÚevalrZr"r`ÚhasattrrÓÚ__code__Úco_nameÚco_firstlinenormÚlineinfoÚ defaultFileÚ checklineZ set_breakÚ get_breaksÚnumberr«r)r.r©Z temporaryrÁrrÚcondZcommaZcolonrrbrªr*ÚokZlnrÚerrrrrÚdo_breakTs~             z Pdb.do_breakcCs"|jjj}|dkr|jr|j}|S)zProduce a reasonable default.z)rZr]rmr<)r.rrrrrÞ±s zPdb.defaultFilecCs| |d¡dS)z¶tbreak [ ([filename:]lineno | function) [, condition] ] Same arguments as break, but sets a temporary breakpoint: it is automatically deleted when first hit. rN)rå)r.r©rrrÚ do_tbreak½sz Pdb.do_tbreakc CsÌd}| d¡}t|ƒdkr(|d ¡}nt|ƒdkrB|d ¡}n|S|dkrR|S| d¡}|ddkr~|d=t|ƒdkr~|S| ¡}t|ƒdkrœ|d}n| |d¡}|r²|}|d}t||ƒ} | pÊ|S) N)NNNú'rrér2rÆr.)r™rÐrgrÞrÖr ) r.Z identifierZfailedZidstringÚidÚpartsZfnameÚitemrbZanswerrrrrÝÆs.         z Pdb.lineinfocCs€t|dƒr|jjnd}t |||¡}|s6| d¡dS| ¡}|rn|ddksn|dd…dksn|dd…dkr|| d ¡dS|S) zÈCheck 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. rZNz End of filerrerèz"""z'''zBlank or comment)rÙrZr"Ú linecacheÚgetlinerRrgr’)r.rrr¼rrrrrßçs   z Pdb.checklinec Csl| ¡}x^|D]V}y| |¡}Wn,tk rL}z| |¡Wdd}~XYqX| ¡| d|¡qWdS)z†enable bpnumber [bpnumber ...] Enables the breakpoints given as a space separated list of breakpoint numbers. Nz Enabled %s)r™Úget_bpbynumberr×r’ÚenablerR)r.r©r¡r+rÁrärrrÚ do_enableüs z Pdb.do_enablec Csl| ¡}x^|D]V}y| |¡}Wn,tk rL}z| |¡Wdd}~XYqX| ¡| d|¡qWdS)aNdisable bpnumber [bpnumber ...] Disables the breakpoints given as a space separated list of breakpoint numbers. Disabling a breakpoint means it cannot cause the program to stop execution, but unlike clearing a breakpoint, it remains in the list of breakpoints and can be (re-)enabled. Nz Disabled %s)r™rîr×r’ÚdisablerR)r.r©r¡r+rÁrärrrÚ do_disable s zPdb.do_disablec CsÂ| dd¡}y |d}Wntk r0d}YnXy| |d ¡¡}WnHtk rf| d¡YnXtk r}z| |¡Wdd}~XYn.X||_|s®| d|j¡n| d|j¡dS)a#condition bpnumber [condition] Set a new condition for the breakpoint, an expression which must evaluate to true before the breakpoint is honored. If condition is absent, any existing condition is removed; i.e., the breakpoint is made unconditional. r—rNrzBreakpoint number expectedz#Breakpoint %d is now unconditional.z$New condition set for breakpoint %d.) r™Ú IndexErrorrîrgr’r×rârRrá)r.r©r¡rârÁrärrrÚ do_condition!s   zPdb.do_conditionc CsÜ| ¡}yt|d ¡ƒ}Wnd}YnXy| |d ¡¡}WnHtk rb| d¡Ynvtk rŒ}z| |¡Wdd}~XYnLX||_|dkrÈ|dkr®d|}nd}| d||j f¡n| d|j ¡dS) a–ignore bpnumber [count] Set the ignore count for the given breakpoint number. If count is omitted, the ignore count is set to 0. 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. rrzBreakpoint number expectedNz %d crossingsz 1 crossingz%Will ignore next %s of breakpoint %d.z-Will stop next time breakpoint %d is reached.) r™rÑrgrîrór’r×ÚignorerRrá)r.r©r¡ÚcountrÁräZcountstrrrrÚ do_ignore<s(   z Pdb.do_ignorec CsŽ|sxy tdƒ}Wntk r(d}YnX| ¡ ¡}|dkrtdd„tjjDƒ}| ¡x|D]}| d|¡q^WdSd|kr|  d¡}|d|…}||d d…}y t |ƒ}Wnt k rÐd |}YnX|  ||¡}|  ||¡}|rú| |¡nx|D]}| d|¡qWdS| ¡} xd| D]\}y| |¡}Wn.t k rj}z| |¡Wdd}~XYnX| |¡| d|¡q*WdS) a=cl(ear) filename:lineno cl(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. zClear all breaks? Zno)ÚyZyescSsg|] }|r|‘qSrr)rÀrÁrrrrÂmsz Pdb.do_clear..z Deleted %sNr®rzInvalid line number (%s))ÚinputÚEOFErrorrgr¸r4rÃrÄZclear_all_breaksrRrÕrÑr×ràZ clear_breakr’r™rîZclear_bpbynumber) r.r©ZreplyZbplistrÁr+rrräZ numberlistrrrÚdo_clear_sF              z Pdb.do_clearcCs | ¡dS)zâw(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. N)Úprint_stack_trace)r.r©rrrÚdo_where’sz Pdb.do_wherecCs^d|krt|jƒks nt‚||_|j|jd|_|jj|_| |j|j¡d|_dS)Nr) rÐrXÚAssertionErrorrYrZr#r`rtr)r.rárrrÚ _select_frameœs   zPdb._select_framecCsx|jdkr| d¡dSyt|p"dƒ}Wn"tk rJ| d|¡dSX|dkrZd}ntd|j|ƒ}| |¡dS)z‚u(p) [count] Move the current frame count (default one) levels up in the stack trace (to an older frame). rz Oldest frameNrzInvalid frame count (%s))rYr’rÑr×Úmaxrÿ)r.r©röÚnewframerrrÚdo_up¤s  z Pdb.do_upcCs–|jdt|jƒkr"| d¡dSyt|p,dƒ}Wn"tk rT| d|¡dSX|dkrnt|jƒd}ntt|jƒd|j|ƒ}| |¡dS)z…d(own) [count] Move the current frame count (default one) levels down in the stack trace (to a newer frame). rz Newest frameNzInvalid frame count (%s)r)rYrÐrXr’rÑr×Úminrÿ)r.r©rörrrrÚdo_down¸s z Pdb.do_downcCsf|rPy t|ƒ}Wn"tk r2| d|¡dSX||jjkrT| d¡dSnd}| |j|¡dS)aNunt(il) [lineno] Without argument, continue execution until the line with a number greater than the current one is reached. With a line number, continue execution until a line with a number greater or equal to that is reached. In both cases, also stop when the current frame returns. zError in argument: %rNz7"until" line number is smaller than current line numberr)rÑr×r’rZrnZ set_until)r.r©rrrrÚdo_untilÌs   z Pdb.do_untilcCs | ¡dS)z§s(tep) Execute the current line, stop at the first possible occasion (either in a function that is called or in the current function). r)rS)r.r©rrrÚdo_stepäsz Pdb.do_stepcCs| |j¡dS)zxn(ext) Continue execution until the next line in the current function is reached or it returns. r)Zset_nextrZ)r.r©rrrÚdo_nextîs z Pdb.do_nextcCs<|r4ddl}tjdd…}| |¡t_|tjdd…<t‚dS)arun [args...] Restart the debugged python program. If a string is supplied it is split with "shlex", and the result is used as the new sys.argv. History, breakpoints, actions and debugger options are preserved. "restart" is an alias for "run". rNr)ÚshlexrÚargvr™r)r.r©rZargv0rrrÚdo_run÷s  z Pdb.do_runcCs| |j¡dS)zPr(eturn) Continue execution until the current function returns. r)Z set_returnrZ)r.r©rrrÚ do_returns z Pdb.do_returncCs>|js2yt tj|j¡t_Wntk r0YnX| ¡dS)z]c(ont(inue)) Continue execution, only stop when a breakpoint is encountered. r)rBr‰rŠrUr rˆr×Z set_continue)r.r©rrrÚ do_continueszPdb.do_continuec Cs¾|jdt|jƒkr"| d¡dSy t|ƒ}Wntk rL| d¡YnnXy:||j_|j|jd|f|j|j<| |j|j¡Wn0tk r¸}z| d|¡Wdd}~XYnXdS)a£j(ump) lineno Set the next line that will be executed. Only available in the bottom-most frame. This lets you jump back and execute code again, or jump forward to skip code that you don't want to run. It should be noted that not all jumps are allowed -- for instance it is not possible to jump into the middle of a for loop or out of a finally clause. rz)You can only jump within the bottom frameNz)The 'jump' command requires a line numberrzJump failed: %s) rYrÐrXr’rÑr×rZrnrt)r.r©ÚerrrÚdo_jump"s   z Pdb.do_jumpcCs¼t d¡|jj}|j}t|j|j|jƒ}d|j   ¡|_ |  d¡yt  |j |||f¡Wn<tk r˜t ¡dd…}| tj|Žd  ¡¡YnX|  d¡t |j¡|j|_dS)zÆdebug 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). Nz(%s) zENTERING RECURSIVE DEBUGGERrrxzLEAVING RECURSIVE DEBUGGER)rÚsettracerZr"r`r rNrOrPr9rgrRÚ call_tracingr r´r|r’rzr{Ztrace_dispatchrs)r.r©r”r“Úpr|rrrÚdo_debug?s    z Pdb.do_debugcCsd|_| ¡dS)z[q(uit) exit Quit from the debugger. The program being executed is aborted. Tr)Ú_user_requested_quitÚset_quit)r.r©rrrÚdo_quitVsz Pdb.do_quitcCs| d¡d|_| ¡dS)z=EOF Handles the receipt of EOF as a command. r2Tr)rRrr)r.r©rrrÚdo_EOFas z Pdb.do_EOFcCsˆ|jj}|j}|j}|jd@r&|d}|jd@r8|d}xJt|ƒD]>}|j|}||krp| d|||f¡qB| d|f¡qBWdS)zHa(rgs) Print the argument list of the current function. éréz%s = %rz%s = *** undefined ***N)rZr]r`Ú co_argcountÚco_flagsÚrangeÚ co_varnamesrR)r.r©ÚcoÚdictrÇr+ÚnamerrrÚdo_argsjs   z Pdb.do_argscCs.d|jkr | t|jdƒ¡n | d¡dS)zQretval Print the return value for the last return of a function. rvzNot yet returned!N)r`rRr‹r’)r.r©rrrÚ do_retval{s z Pdb.do_retvalcCsNyt||jj|jƒSt ¡dd…}| tj|Žd  ¡¡‚YnXdS)Nrrx) rØrZr"r`rr|r’rzr{rg)r.r©r|rrrÚ_getval…s z Pdb._getvalcCshy.|dkrt||jj|jƒSt||j|jƒSWn4t ¡dd…}tj|Žd  ¡}t d|ƒSdS)Nrrxz** raised %s **) rØrZr"r`r#rr|rzr{rgr-)r.r©rTr|rärrrr…szPdb._getval_exceptcCs*y| t| |¡ƒ¡Wn YnXdS)z@p expression Print the value of the expression. N)rRr‹r")r.r©rrrÚdo_p˜szPdb.do_pcCs,y| t | |¡¡¡Wn YnXdS)zHpp expression Pretty-print the value of the expression. N)rRÚpprintZpformatr")r.r©rrrÚdo_pp¡sz Pdb.do_ppcCsdd|_d}|rš|dkršy^d|krX| d¡\}}t| ¡ƒ}t| ¡ƒ}||krr||}nt| ¡ƒ}td|dƒ}WqÊtk r–| d|¡dSXn0|jdks¬|dkrÀtd|jj dƒ}n |jd}|dkrÚ|d}|jj j }|  |¡}yZt  ||jj¡}| ||d|…|||j¡t|t|ƒƒ|_t|ƒ|krF| d ¡Wntk r^YnXdS) a°l(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 . as argument, list 11 lines around the current line. 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. The current line in the current frame is indicated by "->". If an exception is being debugged, the line where the exception was originally raised or propagated is indicated by ">>", if it differs from the current line. r'NrÆr¯rézError in argument: %ré z[EOF])rsr™rÑrgrr×r’rrZrnr]rmÚget_file_breaksrìÚgetlinesr"Ú _print_linesrrÐrRrQ)r.r©ZlastÚfirstrÚ breaklistr%rrrÚdo_list®s>        z Pdb.do_listc Csj|jjj}| |¡}yt|jƒ\}}Wn,tk rR}z| |¡dSd}~XYnX| ||||j¡dS)z\longlist | ll List the whole source code for the current function or frame. N)rZr]rmr(r&rr’r*)r.r©rr,r%rrärrrÚ do_longlistás   zPdb.do_longlistc Csly| |¡}Wn dSyt|ƒ\}}Wn0ttfk rZ}z| |¡dSd}~XYnX| ||¡dS)z^source expression Try to get source code for the given object and display it. N)r"r&rÚ TypeErrorr’r*)r.r©r$r%rrärrrÚ do_sourceïs z Pdb.do_sourcerc Cs²|r|j}|j |d¡}nd}}xŠt||ƒD]|\}}t|ƒ d¡} t| ƒdkrX| d7} ||krj| d7} n| d7} ||kr„| d7} n||kr”| d7} | | d| ¡¡q.Wd S) zPrint a range of lines.rxrèrr—ÚBz->z>>ú N) rnr>rƒrr›ÚrjustrÐrRr ) r.r%rrÔrTZcurrent_linenoZ exc_linenorrÚsrrrr*s    zPdb._print_linescCsÆy| |¡}Wn dSd}y |j}Wntk r<YnX|rV| d|j¡dSy |jj}Wntk rvYnX|r| d|j¡dS|jtkr´| d|j|j f¡dS| t|ƒ¡dS)z;whatis arg Print the type of the argument. Nz Function %sz Method %sz Class %s.%s) r"rÚr´rRrÛrÓÚ __class__Útyperr)r.r©Úvaluer*rrrÚ do_whatiss.   z Pdb.do_whatiscCsp|s<| d¡x\|j |ji¡ ¡D]}| d|¡q$Wn0| |¡}||j |ji¡|<| d||f¡dS)zâdisplay [expression] Display the value of the expression if it changed, each time execution stops in the current frame. Without expression, list all display expressions for the current frame. zCurrently displaying:z%s: %rzdisplay %s: %rN)rRr;rƒrZr„r…Ú setdefault)r.r©rëÚvalrrrÚ do_display8s  zPdb.do_displaycCsT|r@y|j |ji¡|=WqPtk r<| d|¡YqPXn|j |jd¡dS)z·undisplay [expression] Do not display the expression any more in the current frame. Without expression, clear all display expressions for the current frame. znot displaying %sN)r;rƒrZrËr’rf)r.r©rrrÚ do_undisplayKs zPdb.do_undisplaycs‡fdd„|j |ji¡DƒS)Ncsg|]}| ˆ¡r|‘qSr)r¿)rÀr )r¹rrrÂ[sz*Pdb.complete_undisplay..)r;rƒrZ)r.r¹rrºr»r)r¹rÚcomplete_undisplayZszPdb.complete_undisplaycCs*|jj ¡}| |j¡tjd|ddS)z interact Start an interactive interpreter whose global namespace contains all the (global and local) names found in the current scope. z *interactive*)ZlocalN)rZr"rÉrÊr`r*Úinteract)r.r©rÎrrrÚ do_interact^s  zPdb.do_interactcCs¨| ¡}t|ƒdkrLt|j ¡ƒ}x$|D]}| d||j|f¡q(WdS|d|jkrˆt|ƒdkrˆ| d|d|j|df¡nd |dd…¡|j|d<dS)acalias [name [command [parameter parameter ...] ]] Create an alias called 'name' that executes 'command'. The command must *not* be enclosed in quotes. Replaceable parameters can be 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. As an example, here are two useful aliases (especially when placed in the .pdbrc file): # 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 rz%s = %sNrr—)r™rÐÚsortedr:rÍrRrG)r.r©r¡rÍr˜rrrÚdo_aliashs  "z Pdb.do_aliascCs6| ¡}t|ƒdkrdS|d|jkr2|j|d=dS)z9unalias name Delete the specified alias. rN)r™rÐr:)r.r©r¡rrrÚ do_unalias‹s  zPdb.do_unaliascs‡fdd„|jDƒS)Ncsg|]}| ˆ¡r|‘qSr)r¿)rÀÚa)r¹rrr•sz(Pdb.complete_unalias..)r:)r.r¹rrºr»r)r¹rÚcomplete_unalias”szPdb.complete_unaliasr rrr rrcCs8yx|jD]}| |¡q WWntk r2YnXdS)N)rXrtrQ)r.Ú frame_linenorrrrü£s  zPdb.print_stack_tracecCs6|\}}||jkrd}nd}| || ||¡¡dS)Nz> z )rZrRZformat_stack_entry)r.rEZ prompt_prefixrTrr€rrrrtªs  zPdb.print_stack_entrycCs¤|stj ||¡Sy}xtj  |¡r¦t  |¡}qŽWtj ||¡}tj |¡rˆ|SqˆWdS)z·Helper function for break/clear parsing -- may be overridden. lookupmodule() translates (possibly incomplete) file or module name into an absolute file name. rr2z.pyN) rDrFÚisabsÚexistsrGrrlr<ÚsplitextÚislinkÚreadlink)r.rrbÚrootZextÚdirnameÚfullnamerrrrÖàs"   zPdb.lookupmodulec Csrd|_d|_ddl}| |¡\}}}| |j¡|_ddl}|j  ¡|j  d|j|j |j |t dœ¡| |¡dS)NTFrÚ__main__)rÚ__file__Ú __package__Ú __loader__Ú__spec__Ú __builtins__)r=rÚrunpyZ_get_module_detailsrlrmr<rSÚ__dict__r[rÊÚparentÚloaderrXr )r.Z module_namerYZmod_nameZmod_specr*rSrrrÚ _runmoduleøs  zPdb._runmodulec Cstddl}|j ¡|j d|tdœ¡d|_| |¡|_d|_t |dƒ}d|  ¡|jf}WdQRX|  |¡dS)NrrS)rrTrXTFÚrbzexec(compile(%r, %r, 'exec'))) rSrZr[rÊrXr=rlr<rrÚreadr )r.rrSrÚ statementrrrÚ _runscript s    zPdb._runscript)r0NNNFT)r)N)rN)wrrrrˆr6rUrVrWrdrarkrprorwrrur‡rjrŒr•r£rhr¤rRr’r¾rÅr³rÒZcomplete_commandsrårÞZdo_bZcomplete_breakZ complete_bræZcomplete_tbreakrÝrßrðZcomplete_enableròZcomplete_disablerôZcomplete_conditionr÷Zcomplete_ignorerûZdo_clZcomplete_clearZ complete_clrýZdo_wZdo_btrÿrZdo_urZdo_drZdo_untrZdo_srZdo_nr Z do_restartr Zdo_rr Zdo_cZdo_contrZdo_jrZcomplete_debugrZdo_qZdo_exitrr Zdo_ar!Zdo_rvr"r…r#r%Zcomplete_printZ complete_pZ complete_ppr-Zdo_lr.Zdo_llr0Zcomplete_sourcer*r8Zcomplete_whatisr;Zcomplete_displayr<r=r?rArBrDr¨rüÚ line_prefixrtrFZdo_hrIrJrÖr]rarrrrr ˆsè /     M ]!!.    1  ! #    ÚwhereZdownZupÚbreakZtbreakr[rñrïrõZ conditionrIÚstepr¢ZuntilZjumpÚreturnZretvalÚcontinuer'Zlonglistr¡rZppZwhatisÚsourceZdisplayZ undisplayr>r˜ZunaliasÚdebugZquitr¦z cCstƒ |||¡dS)N)r r )r`r”r“rrrr 9scCstƒ |||¡S)N)r r )Z expressionr”r“rrrr <scCst|||ƒdS)N)r )r`r”r“rrrr ?scOstƒj||ŽS)N)r r)r¡ÚkwdsrrrrCs)ÚheadercCs,tƒ}|dk r| |¡| t ¡j¡dS)N)r rRrrÚ _getframeÚf_back)rkÚpdbrrrrFs cCsB|dkrt ¡d}|dkr$tdƒ‚tƒ}| ¡| d|¡dS)NrzAA valid traceback must be passed if no exception is being handled)rr|r×r rVrj)ÚtrrrrrNs cCsttjƒdS)N)rrÚlast_tracebackrrrrr \szimport x; x.main()cCs ttƒdS)N)r ÚTESTCMDrrrrÚtestdsrrcCsddl}| t¡dS)Nr)ÚpydocZpagerr)rsrrrrhsausage: pdb.py [-c command] ... [-m module | pyfile] [arg] ... Debug the Python program given by pyfile. Alternatively, an executable module or package to debug can be specified using the -m switch. Initial commands are read from .pdbrc files in your home directory and in the current directory, if they exist. Commands supplied with -c are executed after commands from .pdbrc files. To let the script run until an exception occurs, use "-c continue". To let the script run up to a given line X in the debugged file, use "-c 'until X'".c Cs ddl}| tjdd…dddg¡\}}|s>ttƒt d¡g}d}xJ|D]B\}}|dkrnttƒt ¡qL|d kr‚| |¡qL|d krLd }qLW|d}|sÀtj  |¡sÀtd |d ƒt d¡|tjdd…<|sätj  |¡tjd<t ƒ}|j   |¡x y2|r| |¡n | |¡|jr"PtdƒWqútk r`td|dƒtdd |¡ƒYqútk rtdddtt ¡dƒYqútk r¶t ¡t d¡Yqút ¡tdƒtdƒt ¡d} | d| ¡td|dƒYqúXqúWdS)Nrrzmhc:z--helpz --command=rF)z-hz--help)z-cz --command)z-mTzError:zdoes not existz*The program finished and will be restartedZ Restartingzwith arguments:r2r—z/The program exited via sys.exit(). Exit status:)r¥z2Uncaught exception. Entering post mortem debuggingz1Running 'cont' or 'step' will restart the programz#Post mortem debugger finished. The z will be restarted)Úgetoptrr r¬Ú_usageÚexitrŸrDrFrLrQr rCrHr]rarrrGÚ SystemExitr|Ú SyntaxErrorrzÚ print_excrj) rtZoptsr¡rIZ run_as_moduleZoptZoptargr<rnrorrrÚmain{sb              rzrS)NN)NN)N)-rrDrrr7r4r(r*rµr$r‰r!rzrìr´rÚ__all__r r&r,r›r-rbr5r8r Z _help_orderZ_commandrrrgrIr r r rrrr rqrrrrurzrrnrrrrÚBst    )  "    C