]"@sddlZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z Gddde Zdddddd d d d g Zd dZddZddZGdddeZdZGdddejejZedk rd dddddddddd d!d"d#d$d%d&d'dd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6g"Zx2eD]*Zeeed7ejjd87ZqWeejj7Z[[ddd9dZddd:dZ d;dZ!d<d Z"d=d Z#dd>d Z$d?dZ%d@Z&dAdBZ'dCd Z(dDZ)dEdFZ*e+dGkrddl,Z,e,j*dS)HNc@seZdZdS)RestartN)__name__ __module__ __qualname__rr(/opt/alt/python35/lib64/python3.5/pdb.pyrTs rrunpmPdbrunevalrunctxruncall set_trace post_mortemhelpcCstjdtj|}yt|}Wntk rDdSYnX|Dx<t|ddD](\}}|j|r_|||fSq_WWdQRXdS)Nzdef\s+%s\s*[(]start)recompileescapeopenOSError enumeratematch)funcnamefilenameZcrefplinenolinerrr find_function[s  rcCsztj|\}}tj|r@|j|jkr@|dfStj|rY|dfStj||d|dfS)Nr)inspectZ findsourceZisframe f_globalsf_localsZismoduleZgetblock)objlinesrrrrgetsourcelineshs !  r%cCsJttj|}|jx$|D]\}}||kr&|Sq&WdS)Nr)listdisZfindlinestartsreverse)codeZlastiZ linestartsirrrr lasti2linenoqs   r+c@seZdZddZdS)_rstrcCs|S)Nr)selfrrr__repr__|sz_rstr.__repr__N)rrrr.rrrrr,zs r,z -> c@seZdZdZdddddddZddZdd Zd d Zd d ZddZ ddZ ddZ ddZ ddZ ddZddZddZddZd d!Zd"d#Zd$d%Zd&d'Zd(d)Zd*d+Zd,d-Zd.d/Zd0d1Zd2d3Zd4d5ZeZd6d7d8Zd9d:ZeZ eZ!eZ"d;d<Z#eZ$d=d>Z%d?d@Z&dAdBZ'eZ(dCdDZ)eZ*dEdFZ+eZ,dGdHZ-eZ.dIdJZ/e/Z0eZ1eZ2dKdLZ3e3Z4e3Z5dMdNZ6dOdPZ7e7Z8dQdRZ9e9Z:dSdTZ;e;Z<dUdVZ=e=Z>dWdXZ?e?Z@dYdZZAeAZBd[d\ZCeCZDd]d^ZEeEZFZGd_d`ZHeHZIdadbZJeZKdcddZLeLZMeLZNdedfZOdgdhZPePZQdidjZReRZSdkdlZTddmdnZUdodpZVdqdrZWeZXeZYeZZdsdtZ[e[Z\dudvZ]e]Z^dwdxZ_eZ`fddydzZad{d|ZbeZcd}d~ZdeZeddZfddZgddZhddZiddZjddZkddddddgZlddZmenddZoddZpepZqddZrddZsddZtddZudS)r NZtabFc $Cstjj|d|tjj|||||r>d|_d|_i|_i|_d|_ d|_ i|_ yddl }|j dWntk rYnXd|_||_g|_dtjkr+tjd}y9ttjj|d}|jj|WdQRXWntk r*YnXy*td}|jj|WdQRXWntk riYnXi|_i|_i|_d|_d|_dS) Nskiprz(Pdb) Fz `@#$%^&*()=+[{]}\|;:'",<>?HOMEz.pdbrc)bdbBdb__init__cmdCmdZ use_rawinputpromptaliases displaying mainpyfile_wait_for_mainpyfile tb_linenoreadlineZset_completer_delims ImportError allow_kbdintnosigintrcLinesosenvironrpathjoinextendrcommandscommands_dopromptcommands_silentcommands_defining commands_bnum) r- completekeystdinstdoutr/r@r=ZenvHomeZrcFilerrrr4sF                   z Pdb.__init__cCs7|jrt|jd|j|j|dS)Nz- Program interrupted. (Use 'cont' to resume).)r?KeyboardInterruptmessageset_stepr)r-signumframerrrsigint_handlers    zPdb.sigint_handlercCstjj||jdS)N)r2r3resetforget)r-rrrrUsz Pdb.resetcCs5d|_g|_d|_d|_|jjdS)Nr)rstackcurindexcurframer<clear)r-rrrrVs     z Pdb.forgetcCs|j|j||\|_|_x;|ret|jj|j}||j|j<|j }q+W|j|jd|_ |j j |_ |j S)Nr)rVZ get_stackrWrXr+tb_framef_codetb_lastir<tb_nextrYr"curframe_locals execRcLines)r-ftbrrrrsetups   z Pdb.setupcCs|js dS|j}|jg|_xZ|r|jj}|r,|ddkr,|j|r,|jt|7_dSq,WdS)Nr#T)rAr(popstriponecmdreversed)r-rArrrrr`s     zPdb.execRcLinescCs=|jr dS|j|r9|jd|j|ddS)Nz--Call--)r;Z stop_hererP interaction)r-rSZ argument_listrrr user_calls   z Pdb.user_callcCsf|jrC|j|j|jjks6|jdkr:dSd|_|j|rb|j|ddS)NrF)r;r:canonicr\ co_filenamef_lineno bp_commandsri)r-rSrrr user_lines  z Pdb.user_linecCst|ddr|j|jkr|j}d|_|j}|j|dx"|j|D]}|j|q]W||_|j|s|j|j|j |j |r|j |j dSdS)N currentbpFrr) getattrrprGlastcmdrcrgrIprint_stack_entryrWrXrH_cmdlooprV)r-rSrpZ lastcmd_backrrrrrns         zPdb.bp_commandscCs;|jr dS||jd<|jd|j|ddS)N __return__z --Return--)r;r"rPri)r-rSZ return_valuerrr user_returns    zPdb.user_returncCs|jr dS|\}}}||f|jd<| rH|tkrHdnd}|jd|tj||djf|j||dS)NZ __exception__z Internal r0z%s%sr)r;r" StopIterationrP tracebackformat_exception_onlyrfri)r-rSexc_infoexc_type exc_value exc_tracebackprefixrrruser_exception%s  !zPdb.user_exceptionc CsNxGy!d|_|jd|_PWqtk rE|jdYqXqWdS)NTFz--KeyboardInterrupt--)r?cmdlooprOrP)r-rrrrt9s    z Pdb._cmdloopcCs|jj|j}|rxe|jD]W\}}|j|}||k r(||kr(|||<|jd|||fq(WdS)Nzdisplay %s: %r [old: %r])r9getrYitems_getval_exceptrP)r-r9exprZoldvalueZnewvaluerrrpreloopFs  z Pdb.preloopcCswtjr(tjtjtjdt_|j||rH|jdS|j|j|j|j |jdS)N) r _previous_sigint_handlersignalSIGINTrcrVrsrWrXrt)r-rSryrrrriSs    zPdb.interactioncCs#|dk r|jt|dS)N)rPrepr)r-r#rrr displayhookas zPdb.displayhookc Cs |dddkr&|dd}|j}|jj}yt|ddd}tj}tj}tj}z8|jt_|jt_|jt_t|||Wd|t_|t_|t_XWn>tj dd}|j t j |dj YnXdS)Nr! zZsinglerw)r_rYr!rsysrNrMrexecr{errorryrzrf) r-rlocalsglobalsr)Z save_stdoutZ save_stdinZsave_displayhookr{rrrdefaultis(          z Pdb.defaultcCs.|js|S|j}x|d|jkr|j|d}d}x>|ddD],}|jdt||}|d7}qZW|jddj|dd}|j}qW|ddkr*|jd}|dkr*||ddj}|jj ||d|j }|S) Nrr%z%* aliasz;;r) rfsplitr8replacestrrEfindlstripcmdqueueappendrstrip)r-rargsiiZtmpArgmarkernextrrrprecmds&   % z Pdb.precmdcCs-|jstjj||S|j|SdS)N)rJr5r6rghandle_command_def)r-rrrrrgs z Pdb.onecmdc Cs|j|\}}}|s"dS|dkrBd|j|js z*Pdb._complete_bpnumber..)rr2 Breakpoint bpbynumber)r-rrrrr)rr_complete_bpnumberszPdb._complete_bpnumberc s|js gS|jjj}|j|jdkrjdy<|d}x'ddD]}t||}qlWWnttfk rgSYnXdj dddfddt |DSfdd|j DSdS) N.rrcs-g|]#}|jdr|qS)rrw)r)rn)dottedrrrrs z,Pdb._complete_expression..cs%g|]}|jr|qSr)r)rr)rrrrs rwrw) rYr!copyupdater_rrqKeyErrorrrEdirkeys)r-rrrrnsr#partr)rrrrrs    zPdb._complete_expressioncCsz|sttjjd}n,yt|}Wn|jddSYnX||_||jkr|j||j||j |f}nd}g|j|)rYr\rlr:)r-rrrrrs zPdb.defaultFilecCs|j|ddS)Nr)r)r-rrrr do_tbreaksz Pdb.do_tbreakc Csd}|jd}t|dkr:|dj}n)t|dkr_|dj}n|S|dkrs|S|jd}|ddkr|d=t|dkr|S|j}t|dkr|d}n)|j|d}|r|}|d}t||} | p|S) N'rrr0rr-)NNN)rrrfrrr) r-Z identifierZfailedZidstringidpartsZfnameitemraZanswerrrrrs.    z Pdb.lineinfocCst|dr|jjnd}tj|||}|sM|jddS|j}| s|ddks|dddks|dddkr|jddS|S) NrYz End of filerrdrz"""z'''zBlank or comment)rrYr! linecachegetlinerPrfr)r-rrrrrrrrs!  , z Pdb.checklinecCs|j}xq|D]i}y|j|}Wn2tk r`}z|j|WYdd}~XqX|j|jd|qWdS)Nz Enabled %s)rget_bpbynumberrrenablerP)r-rrr*rrrrr do_enables    z Pdb.do_enablecCs|j}xq|D]i}y|j|}Wn2tk r`}z|j|WYdd}~XqX|j|jd|qWdS)Nz Disabled %s)rrrrdisablerP)r-rrr*rrrrr do_disable s    zPdb.do_disablecCs|jdd}y|d}Wntk r:d}YnXy|j|dj}WnPtk ry|jdYnltk r}z|j|WYdd}~Xn;X||_|s|jd|jn|jd|jdS)NrrrzBreakpoint number expectedz#Breakpoint %d is now unconditional.z$New condition set for breakpoint %d.) r IndexErrorrrfrrrrPr)r-rrrrrrrr do_conditions     zPdb.do_conditioncCs|j}yt|dj}Wnd}YnXy|j|dj}WnPtk ru|jdYntk r}z|j|WYdd}~XnfX||_|dkr|dkrd|}nd}|jd||j fn|jd|j dS)NrrzBreakpoint number expectedz %d crossingsz 1 crossingz%Will ignore next %s of breakpoint %d.z-Will stop next time breakpoint %d is reached.) rrrfrrrrignorerPr)r-rrcountrrZcountstrrrr do_ignore:s(          z Pdb.do_ignorec !Cs|sytd}Wntk r0d}YnX|jj}|d krddtjjD}|jx|D]}|jd|qyWdSd|krf|j d}|d|}||d d}yt |}Wnt k rd |}Yn%X|j ||}|j ||}|r@|j|n"x|D]}|jd|qGWdS|j} xt| D]l}y|j|}Wn2t k r}z|j|WYdd}~XqyX|j||jd|qyWdS) NzClear all breaks? noyyescSsg|]}|r|qSrr)rrrrrrks z Pdb.do_clear..z Deleted %srrzInvalid line number (%s))rr)inputEOFErrorrfrr2rrZclear_all_breaksrPrrrrZ clear_breakrrrZclear_bpbynumber) r-rZreplyZbplistrr*rrrZ numberlistrrrdo_clear]sF            z Pdb.do_clearcCs|jdS)N)print_stack_trace)r-rrrrdo_wheresz Pdb.do_wherecCsS||_|j|jd|_|jj|_|j|j|jd|_dS)Nr)rXrWrYr"r_rsr)r-rrrr _select_frames  zPdb._select_framec Cs|jdkr |jddSyt|p/d}Wn'tk r_|jd|dSYnX|dkrud}ntd|j|}|j|dS)Nrz Oldest framerzInvalid frame count (%s))rXrrrmaxr)r-rrnewframerrrdo_ups     z Pdb.do_upc Cs|jdt|jkr-|jddSyt|p<d}Wn'tk rl|jd|dSYnX|dkrt|jd}n#tt|jd|j|}|j|dS)Nrz Newest framezInvalid frame count (%s)r)rXrrWrrrminr)r-rrrrrrdo_downs    #z Pdb.do_downc Cs|rfyt|}Wn'tk r?|jd|dSYnX||jjkrl|jddSnd}|j|j|dS)NzError in argument: %rz7"until" line number is smaller than current line numberr)rrrrYrmZ set_until)r-rrrrrdo_untils   z Pdb.do_untilcCs|jdS)Nr)rQ)r-rrrrdo_steps z Pdb.do_stepcCs|j|jdS)Nr)Zset_nextrY)r-rrrrdo_nextsz Pdb.do_nextcCsT|rJddl}tjdd}|j|t_|tjdd           z Pdb.do_listcCs|jjj}|j|}yt|j\}}Wn6tk ro}z|j|dSWYdd}~XnX|j||||jdS)N)rYr\rlr.r%rrr0)r-rrr2r$rrrrr do_longlists zPdb.do_longlistcCsy|j|}Wn dSYnXyt|\}}Wn<ttfk rv}z|j|dSWYdd}~XnX|j||dS)N)r(r%r TypeErrorrr0)r-rr#r$rrrrr do_sources  z Pdb.do_sourcec Cs|r'|j}|jj|d }n d }}xt||D]\}}t|jd} t| dkr~| d7} ||kr| d7} n | d7} ||kr| d7} n||kr| d7} |j| d|jqAWdS) NrrrrBz->z>> rwrw) rmr<rrrrjustrrPr) r-r$rrrSZcurrent_linenoZ exc_linenorrsrrrr0s           zPdb._print_linescCsy|j|}Wn dSYnXd}y |j}Wntk rIYnX|rh|jd|jdSy|jj}Wntk rYnX|r|jd|jdS|jtkr|jd|j|j fdS|jt|dS)Nz Function %sz Method %sz Class %s.%s) r(rrrPrr __class__typerr)r-rvaluer)rrr do_whatiss.    z Pdb.do_whatiscCs|sP|jdx||jj|jijD]}|jd|q2WnB|j|}||jj|ji|<|jd||fdS)NzCurrently displaying:z%s: %rzdisplay %s: %r)rPr9rrYrr setdefault)r-rrvalrrr do_display2s %zPdb.do_displayc Csf|rLy|jj|ji|=Wqbtk rH|jd|YqbXn|jj|jddS)Nznot displaying %s)r9rrYrrre)r-rrrr do_undisplayEs  zPdb.do_undisplaycs)fdd|jj|jiDS)Ncs%g|]}|jr|qSr)r)rr)rrrrUs z*Pdb.complete_undisplay..)r9rrY)r-rrrrr)rrcomplete_undisplayTszPdb.complete_undisplaycCs9|jjj}|j|jtjdd|dS)Nz *interactive*local)rYr!rrr_r)interact)r-rrrrr do_interactXszPdb.do_interactcCs|j}t|dkrft|jj}x,|D]$}|jd||j|fq:WdS|d|jkrt|dkr|jd|d|j|dfn$dj|dd|j|d.)r8)r-rrrrr)rrcomplete_unaliasszPdb.complete_unaliasrr r rrrc Cs>y%x|jD]}|j|q WWntk r9YnXdS)N)rWrsrO)r- frame_linenorrrrs  zPdb.print_stack_tracecCsK|\}}||jkr$d}nd}|j||j||dS)Nz> z )rYrPZformat_stack_entry)r-rLZ prompt_prefixrSrrrrrrss    zPdb.print_stack_entrycCs|stjj||SyJyt|d|}|SWn%tk rat|d|}YnXWn#tk r|jd|Yn>Xtjjdkr|jd|dS|j |j j dS)NZhelp_rzNo help for %rrzJNo help for %r; please do not run Python with -OO if you need command help) r5r6do_helprqrrrflagsoptimizerP__doc__r)r-rZtopicZcommandrrrrMs    z Pdb.do_helpcCs#|j|jjpdjdS)Nr0)rP help_execrPrf)r-rrrrQs z Pdb.help_execcCs tdS)N)r)r-rrrhelp_pdbsz Pdb.help_pdbcCs!tjj|r(tjj|r(|Stjjtjd|}tjj|rr|j||jkrr|Stjj|\}}|dkr|d}tjj|r|SxdtjD]Y}x%tjj |rtj |}qWtjj||}tjj|r|SqWdS)Nrr0z.py) rBrDisabsexistsrErrkr:splitextislinkreadlink)r-rrarootextdirnamefullnamerrrrs"$*  zPdb.lookupmodulec Csddl}|jj|jjddd|dtid|_|j||_d|_t |d }d |j |jf}WdQRX|j |dS) Nrr__main____file__ __builtins__TFrbzexec(compile(%r, %r, 'exec'))) r\__dict__rZrr^r;rkr:rrreadr)r-rr\r statementrrr _runscripts     zPdb._runscript)vrrrrr4rTrUrVrcr`rjrornrvrrtrrirrrrgrrPrrrrrZcomplete_commandsrrZdo_bZcomplete_breakZ complete_brZcomplete_tbreakrrrZcomplete_enablerZcomplete_disablerZcomplete_conditionrZcomplete_ignorerZdo_clZcomplete_clearZ complete_clrZdo_wZdo_btrrZdo_ur Zdo_dr Zdo_untr Zdo_sr Zdo_nrZ do_restartrZdo_rrZdo_cZdo_contrZdo_jrZcomplete_debugrZdo_qZdo_exitrr&Zdo_ar'Zdo_rvr(rr)r+Zcomplete_printZ complete_pZ complete_ppr3Zdo_lr4Zdo_llr6Zcomplete_sourcer0r>Zcomplete_whatisrAZcomplete_displayrBrCrFrHrIrKrr line_prefixrsrMZdo_hrQrRrrcrrrrr s  .                   M]   !     ! .                   1   !    #      ZwhereZdownZupbreakZtbreakrZrrrZ conditionrGsteprZuntilZjumpreturnZretvalcontinuer&ZlonglistrrppZwhatissourceZdisplayZ undisplayrErZunaliasdebugquitrz cCstj|||dS)N)r r)rbrrrrrr!scCstj|||S)N)r r )Z expressionrrrrrr $scCst|||dS)N)r)rbrrrrrr 'scOstj||S)N)r r )rkwdsrrrr +scCstjtjjdS)N)r rr _getframef_backrrrrr.scCs[|dkrtjd}|dkr4tdt}|j|jd|dS)NrzAA valid traceback must be passed if no exception is being handled)rr{rr rUri)trrrrr3s     cCsttjdS)N)rrlast_tracebackrrrrr Aszimport x; x.main()cCsttdS)N)rTESTCMDrrrrtestIsrscCsddl}|jtdS)Nr)pydocZpagerrP)rtrrrrMs ausage: pdb.py [-c command] ... pyfile [arg] ... Debug the Python program given by pyfile. 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 CsNddl}|jtjdddddg\}}|sWtttjdg}xP|D]H\}}|dkrtttjqd|dkrd|j|qdW|d}tjj |std |d tjd|tjddEsf                  (       <