B ŒÑ>3nØdã"@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ú(/opt/alt/python37/lib64/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 Cs4tjj||dtj ||||¡|r,d|_d|_i|_i|_d|_ d|_ i|_ yddl }|  d¡Wntk rzYnXd|_||_g|_|ry,ttj d¡ƒ}|j |¡WdQRXWntk rÔYnXy$tdƒ}|j |¡WdQRXWntk rYnXi|_i|_i|_d|_d|_dS) N)Úskiprz(Pdb) ÚFz `@#$%^&*()=+[{]}\|;:'",<>?z~/.pdbrcz.pdbrc)ÚbdbÚBdbÚ__init__ÚcmdÚCmdZ use_rawinputÚpromptÚaliasesÚ displayingÚ mainpyfileÚ_wait_for_mainpyfileÚ tb_linenoÚreadlineZset_completer_delimsÚ ImportErrorÚ allow_kbdintÚnosigintÚrcLinesrÚosÚpathÚ expanduserÚextendrÚcommandsÚcommands_dopromptÚcommands_silentÚcommands_definingÚ commands_bnum) r.Ú completekeyÚstdinÚstdoutr1rAZreadrcr>ZrcFilerrrr5ŒsD z Pdb.__init__cCs*|jr t‚| d¡| ¡| |¡dS)Nz- Program interrupted. (Use 'cont' to resume).)r@ÚKeyboardInterruptÚmessageÚset_stepr)r.ZsignumÚframerrrÚsigint_handlerºs  zPdb.sigint_handlercCstj |¡| ¡dS)N)r3r4ÚresetÚforget)r.rrrrTÁs z Pdb.resetcCs&d|_g|_d|_d|_|j ¡dS)Nr)rÚstackÚcurindexÚcurframer=Úclear)r.rrrrUÅs z Pdb.forgetcCsl| ¡| ||¡\|_|_x*|rFt|jj|jƒ}||j|j<|j }qW|j|jd|_ |j j |_ |  ¡S)Nr)rUZ get_stackrVrWr,Útb_frameÚf_codeÚtb_lastir=Útb_nextrXr#Ú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)rBr)ÚpopÚstripÚonecmdÚreversed)r.rBrrrrr_Þ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_hererPÚ interaction)r.rRZ 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_commandsrh)r.rRrrrÚ 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) ÚgetattrrorGÚlastcmdrbrfrIÚprint_stack_entryrVrWrHÚ_cmdlooprU)r.rRroZ lastcmd_backrrrrrms      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#rPrh)r.rRZ 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#Ú StopIterationrPÚ tracebackÚformat_exception_onlyrerh)r.rRÚexc_infoÚexc_typeÚ exc_valueÚ exc_tracebackÚprefixrrrÚuser_exception%s zPdb.user_exceptioncCsDx>yd|_| ¡d|_PWqtk r:| d¡YqXqWdS)NTFz--KeyboardInterrupt--)r@ÚcmdlooprOrP)r.rrrrs9sz Pdb._cmdloopcCsb|j |j¡}|r^xJ| ¡D]>\}}| |¡}||k r||kr|||<| d|||f¡qWdS)Nzdisplay %s: %r [old: %r])r:ÚgetrXÚitemsÚ_getval_exceptrP)r.r:ÚexprZoldvalueZnewvaluerrrÚpreloopFs z Pdb.preloopcCsZtjrt tjtj¡dt_| ||¡r4| ¡dS| |j|j¡|  ¡| ¡dS)N) r Ú_previous_sigint_handlerÚsignalÚSIGINTrbrUrrrVrWrs)r.rRrxrrrrhSs zPdb.interactioncCs|dk r| t|ƒ¡dS)z{Custom displayhook for the exec in default(), which prevents assignment of the _ variable in the builtins. N)rPÚrepr)r.r$rrrÚ displayhookaszPdb.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érv)r^rXr"rÚsysrNrMrŠÚexecrzÚerrorrxryre) r.rÚlocalsÚglobalsr*Z save_stdoutZ save_stdinZsave_displayhookrzrrrÚdefaultis(  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) reÚsplitr9ÚreplaceÚstrÚjoinÚ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)rJr6r7rfÚhandle_command_def)r.rrrrrf˜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 parselinerIrKrrGržrpÚAttributeErrorr“rÚcommands_resumingrH)r.rr6ÚargZcmdlistÚfuncrrrr£¤s,      zPdb.handle_command_defcCst||jddS)N)Úfile)ÚprintrN)r.ÚmsgrrrrPÂsz Pdb.messagecCstd||jddS)Nz***)rª)r«rN)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­) reÚendswithÚ_complete_expressionÚ ExceptionÚglobrCrDÚ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..)rr3Ú 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Ú.rrrvcs"g|]}| ˆd¡rˆ|‘qS)rv)r¾)r¿Ún)Údottedr~rrrÁúsz,Pdb._complete_expression..csg|]}| ˆ¡r|‘qSr)r¾)r¿rÆ)r¸rrrÁýs) rXr"ÚcopyÚupdater^r—rpÚKeyErrorr¦ršÚ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)Úlenr3rÂrÃÚintrrKrGrHrIr8rJr€rO)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.rvzBreakpoint %d at %s:%d) ÚbreaksrPr3rÂrÃZbpformatr›rœrŸÚrfindÚ lookupmodulerrÐÚ ValueErrorÚevalrXr"r^ÚhasattrrÒÚ__code__Úco_nameÚco_firstlinenorkÚlineinfoÚ defaultFileÚ checklineZ set_breakÚ get_breaksÚnumberrªr)r.r¨Z temporaryrÀrrÚcondZcommaZcolonrr`r©r*ÚokZlnrÚerrrrrÚdo_breakRs~             z Pdb.do_breakcCs"|jjj}|dkr|jr|j}|S)zProduce a reasonable default.z)rXr[rkr;)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ÏrerÝrÕr ) r.Z identifierZfailedZidstringÚidÚpartsZfnameÚitemr`ZanswerrrrrÜÄ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. rXNz End of filerrcrçz"""z'''zBlank or comment)rØrXr"Ú linecacheÚgetlinerPrer)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ÚenablerP)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ÚdisablerP)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írerrÖrárPrà)r.r¨r rárÀrãrrrÚ do_conditions   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ÐreríròrrÖÚignorerPrà)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Áksz Pdb.do_clear..z Deleted %sNr­rzInvalid line number (%s))ÚinputÚEOFErrorrer·r3rÂrÃZclear_all_breaksrPrÔrÐrÖrßZ clear_breakrr—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_wheresz Pdb.do_wherecCs^d|krt|jƒks nt‚||_|j|jd|_|jj|_| |j|j¡d|_dS)Nr) rÏrVÚAssertionErrorrWrXr#r^rrr)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))rWrrÐ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)rWrÏrVrrÐ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ÖrrXrlZ 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)rQ)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_nextrX)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_returnrX)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)rAr‡rˆrSr 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) rWrÏrVrrÐrÖrXrlrr)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 DEBUGGERrrvzLEAVING RECURSIVE DEBUGGER)rŽÚsettracerXr"r^r rLrMrNr8rerPÚ call_tracingr r³rzrrxryZtrace_dispatchrq)r.r¨r’r‘ÚprzrrrÚ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_quitTsz Pdb.do_quitcCs| d¡d|_| ¡dS)z=EOF Handles the receipt of EOF as a command. r2Tr)rPrr)r.r¨rrrÚdo_EOF_s z Pdb.do_EOFcCs’|jj}|j}|j|j}|jtj@r.|d}|jtj@rB|d}xJt |ƒD]>}|j |}||krz|  d|||f¡qL|  d|f¡qLWdS)zHa(rgs) Print the argument list of the current function. rz%s = %rz%s = *** undefined ***N) rXr[r^Ú co_argcountÚco_kwonlyargcountÚco_flagsr!Z CO_VARARGSZCO_VARKEYWORDSÚrangeÚ co_varnamesrP)r.r¨ÚcoÚdictrÆr+ÚnamerrrÚdo_argshs    z Pdb.do_argscCs.d|jkr | t|jdƒ¡n | d¡dS)zQretval Print the return value for the last return of a function. rtzNot yet returned!N)r^rPr‰r)r.r¨rrrÚ do_retvalys z Pdb.do_retvalcCsNyt||jj|jƒSt ¡dd…}| tj|Žd  ¡¡‚YnXdS)Nrrv) r×rXr"r^rŽrzrrxryre)r.r¨rzrrrÚ_getvalƒs z Pdb._getvalcCshy.|dkrt||jj|jƒSt||j|jƒSWn4t ¡dd…}tj|Žd  ¡}t d|ƒSdS)Nrrvz** raised %s **) r×rXr"r^r#rŽrzrxryrer-)r.r¨rRrzrãrrrrƒ‹szPdb._getval_exceptcCs*y| t| |¡ƒ¡Wn YnXdS)z@p expression Print the value of the expression. N)rPr‰r )r.r¨rrrÚdo_p–szPdb.do_pcCs,y| t | |¡¡¡Wn YnXdS)zHpp expression Pretty-print the value of the expression. N)rPÚ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])rqr—rÐrerÿrÖrrrXrlr[rkÚget_file_breaksrëÚgetlinesr"Ú _print_linesrrÏrPrO)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)rXr[rkr&r&rrr()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Ú TypeErrorrr()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.rvrçér•ÚBz->z>>ú N) rlr=rrr™ÚrjustrÏrPrŸ) r.r%rrÓrRZcurrent_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³rPrÚ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)rPr:rrXr‚rƒÚ setdefault)r.r¨rêÚvalrrrÚ do_display6s  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:rrXrÊrrd)r.r¨rrrÚ do_undisplayIs zPdb.do_undisplaycs‡fdd„|j |ji¡DƒS)Ncsg|]}| ˆ¡r|‘qSr)r¾)r¿r )r¸rrrÁYsz*Pdb.complete_undisplay..)r:rrX)r.r¸rr¹rºr)r¸rÚcomplete_undisplayXszPdb.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)rXr"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ÏÚsortedr9rÌrPrš)r.r¨r rÌr–rrrÚdo_aliasfs  "z Pdb.do_aliascCs6| ¡}t|ƒdkrdS|d|jkr2|j|d=dS)z9unalias name Delete the specified alias. rN)r—rÏr9)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..)r9)r.r¸rr¹rºr)r¸rÚcomplete_unalias’szPdb.complete_unaliasr rrr rr cCs8yx|jD]}| |¡q WWntk r2YnXdS)N)rVrrrO)r.Ú frame_linenorrrrû¡s  zPdb.print_stack_tracecCs6|\}}||jkrd}nd}| || ||¡¡dS)Nz> z )rXrPZformat_stack_entry)r.rDZ prompt_prefixrRrr~rrrrr¨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) rCrDÚisabsÚexistsršrŽrjr;ÚsplitextÚislinkÚreadlink)r.rr`Ú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_detailsrjrkr;rRÚ__dict__rYrÉÚparentÚloaderrWr )r.Z module_namerXZmod_nameZmod_specr*rRrrrÚ _runmoduleös  zPdb._runmodulec Cstddl}|j ¡|j d|tdœ¡d|_| |¡|_d|_t |dƒ}d|  ¡|jf}WdQRX|  |¡dS)NrrR)rrSrWTFÚrbzexec(compile(%r, %r, 'exec'))) rRrYrYrÉrWr<rjr;rrÚreadr )r.rrRrÚ statementrrrÚ _runscripts    zPdb._runscript)r0NNNFT)r)N)rN)wrrrr†r5rSrTrUrbr_rirnrmrurrsr…rhrŠr“r¢rfr£rPrr½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_contr Zdo_jrZcomplete_debugrZdo_qZdo_exitrrZdo_arZdo_rvr rƒr!r#Zcomplete_printZ complete_pZ complete_ppr+Zdo_lr,Zdo_llr.Zcomplete_sourcer(r7Zcomplete_whatisr:Zcomplete_displayr;r<r>r@rArCr§rûÚ line_prefixrrrEZdo_hrHrIrÕr\r`rrrrr ˆsè -     M ]!!.    1  ! #    ÚwhereZdownZupÚbreakZtbreakrYrðrîrôZ conditionrGÚstepr¡ZuntilZjumpÚreturnZretvalÚcontinuer'Zlonglistr rZppZwhatisÚsourceZdisplayZ undisplayr=r–ZunaliasÚdebugÚquitr¥z cCstƒ |||¡dS)N)r r )r_r’r‘rrrr 7scCstƒ |||¡S)N)r r )Z expressionr’r‘rrrr :scCst|||ƒdS)N)r )r_r’r‘rrrr =scOstƒj||ŽS)N)r r)r ÚkwdsrrrrAs)ÚheadercCs,tƒ}|dk r| |¡| t ¡j¡dS)N)r rPrrŽÚ _getframeÚf_back)rkÚpdbrrrrDs cCsB|dkrt ¡d}|dkr$tdƒ‚tƒ}| ¡| d|¡dS)NrzAA valid traceback must be passed if no exception is being handled)rŽrzrÖr rTrh)ÚtrrrrrLs cCsttjƒdS)N)rrŽÚlast_tracebackrrrrr Zszimport x; x.main()cCs ttƒdS)N)r ÚTESTCMDrrrrÚtestbsrrcCsddl}| t¡dS)Nr)ÚpydocZpagerr)rsrrrrfsausage: 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:rzcommand=rF)z-hz--help)z-cz --command)z-mTzError:zdoes not existz*The program finished and will be restartedZ Restartingzwith arguments:r1r•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)ÚgetoptrŽrr«Ú_usageÚexitržrCrDrKrPr rBrFr\r`rrršÚ SystemExitrzÚ SyntaxErrorrxÚ print_excrh) rtZoptsr rGZ run_as_moduleZoptZoptargr;rnrorrrÚmainysb              rzrR)NN)NN)N)-rrCrrŽr6r3r(r*r´r"r‡r!rxrër³rÚ__all__r r&r,r™r-rar4r7r Z _help_orderZ_commandrprerHr r r rrrr rqrrrrurzrrnrrrrÚBst    '  "    C