grthtrhthjhtyjytjytkergtrhtrjytjerhrfh4:24 29/09/2026B ©Ö3Y Dã@s¶dZddlZddlZddlZddlmZmZmZdddgZeeBeBZ Gdd„de ƒZ Gdd„dƒZ d d „Z Gd d„dƒZd d „Zdd„ZGdd„de ƒZdd„Zdd„Zdd„ZdS)zDebugger basicséN)Ú CO_GENERATORÚ CO_COROUTINEÚCO_ASYNC_GENERATORÚBdbQuitÚBdbÚ Breakpointc@seZdZdZdS)rz Exception to give up completely.N)Ú__name__Ú __module__Ú __qualname__Ú__doc__©r r ú(/opt/alt/python37/lib64/python3.7/bdb.pyr sc@speZdZdZdZdd„Zdd„Zdd„Zd d „Zd d „Zd d„Z dd„Z dd„Z dd„Z dd„Z dd„Zdd„Zdd„Zdd„Zdd „Zd!d"„Zd#d$„Zd[d&d'„Zd\d(d)„Zd*d+„Zd,d-„Zd.d/„Zd]d0d1„Zd2d3„Zd4d5„Zd^d7d8„Zd9d:„Zd;d<„Zd=d>„Z d?d@„Z!dAdB„Z"dCdD„Z#dEdF„Z$dGdH„Z%dIdJ„Z&dKdL„Z'dMdN„Z(d_dPdQ„Z)d`dRdS„Z*dadTdU„Z+dVdW„Z,dXdY„Z-dS)braGeneric 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. The optional skip argument must be an iterable of glob-style module name patterns. The debugger will not step into frames that originate in a module that matches one of these patterns. Whether a frame is considered to originate in a certain module is determined by the __name__ in the frame globals. NcCs(|r t|ƒnd|_i|_i|_d|_dS)N)ÚsetÚskipÚbreaksÚfncacheÚframe_returning)Úselfrr r r Ú__init__sz Bdb.__init__cCsR|d|dd…dkr|S|j |¡}|sNtj |¡}tj |¡}||j|<|S)a$Return canonical form of filename. For real filenames, the canonical form is a case-normalized (on case insenstive filesystems) absolute path. 'Filenames' with angle brackets, such as "", generated in interactive mode, are returned unchanged. ú<ééÿÿÿÿú>)rÚgetÚosÚpathÚabspathÚnormcase)rÚfilenameÚcanonicr r r r%s    z Bdb.canoniccCs&ddl}| ¡d|_| dd¡dS)z5Set values of attributes as ready to start debugging.rN)Ú linecacheÚ checkcacheÚbotframeÚ _set_stopinfo)rr r r r Úreset6sz Bdb.resetcCs–|jr dS|dkr| |¡S|dkr0| ||¡S|dkrD| ||¡S|dkrX| ||¡S|dkrf|jS|dkrt|jS|dkr‚|jStd t|ƒƒ|jS) aODispatch a trace function for debugged frames based on the event. This function is installed as the trace function for debugged frames. Its return value is the new trace function, which is usually itself. The default implementation decides how to dispatch a frame, depending on the type of event (passed in as a string) that is about to be executed. The event can be one of the following: line: A new line of code is going to be executed. call: A function is about to be called or another code block is entered. return: A function or other code block is about to return. exception: An exception has occurred. c_call: A C function is about to be called. c_return: A C function has returned. c_exception: A C function has raised an exception. For the Python events, specialized functions (see the dispatch_*() methods) are called. For the C events, no action is taken. The arg parameter depends on the previous event. NÚlineZcallÚreturnZ exceptionZc_callZ c_exceptionZc_returnz*bdb.Bdb.dispatch: unknown debugging event:)ÚquittingÚ dispatch_lineÚ dispatch_callÚdispatch_returnÚdispatch_exceptionÚtrace_dispatchÚprintÚrepr)rÚframeZeventÚargr r r r,=s$    zBdb.trace_dispatchcCs.| |¡s| |¡r(| |¡|jr(t‚|jS)a Invoke user function and return trace function for line event. If the debugger stops on the current line, invoke self.user_line(). Raise BdbQuit if self.quitting is set. Return self.trace_dispatch to continue tracing in this scope. )Ú stop_hereÚ break_hereÚ user_liner'rr,)rr/r r r r(hs  zBdb.dispatch_linecCsd|jdkr|j|_|jS| |¡s0| |¡s0dS|jrH|jjt@rH|jS|  ||¡|j r^t ‚|jS)a Invoke user function and return trace function for call event. If the debugger stops on this function call, invoke self.user_call(). Raise BbdQuit if self.quitting is set. Return self.trace_dispatch to continue tracing in this scope. N) r"Úf_backr,r1Úbreak_anywhereÚ stopframeÚf_codeÚco_flagsÚGENERATOR_AND_COROUTINE_FLAGSÚ user_callr'r)rr/r0r r r r)ts  zBdb.dispatch_callcCs|| |¡s||jkrv|jr,|jjt@r,|jSz||_| ||¡Wdd|_X|j rVt ‚|j|krv|j dkrv|  dd¡|jS)aInvoke user function and return trace function for return event. If the debugger stops on this function return, invoke self.user_return(). Raise BdbQuit if self.quitting is set. Return self.trace_dispatch to continue tracing in this scope. Nr) r1Ú returnframer6r7r8r9r,rÚ user_returnr'rÚ stoplinenor#)rr/r0r r r r*Šs zBdb.dispatch_returncCs�| |¡rF|jjt@r.|dtkr.|ddksŠ| ||¡|jrŠt‚nD|jrŠ||jk rŠ|jjjt@rŠ|dtt fkrŠ| ||¡|jrŠt‚|j S)aInvoke user function and return trace function for exception event. If the debugger stops on this exception, invoke self.user_exception(). Raise BdbQuit if self.quitting is set. Return self.trace_dispatch to continue tracing in this scope. réN) r1r7r8r9Ú StopIterationÚuser_exceptionr'rr6Ú GeneratorExitr,)rr/r0r r r r+ s    zBdb.dispatch_exceptioncCs$x|jD]}t ||¡rdSqWdS)z4Return True if module_name matches any skip pattern.TF)rÚfnmatch)rZ module_nameÚpatternr r r Úis_skipped_module¿s  zBdb.is_skipped_modulecCsN|jr| |j d¡¡rdS||jkr@|jdkr4dS|j|jkS|jsJdSdS)z>Return True if frame is below the starting frame in the stack.rFrT)rrDÚ f_globalsrr6r=Úf_lineno)rr/r r r r1Æs   z Bdb.stop_herecCsŒ| |jj¡}||jkrdS|j}||j|krJ|jj}||j|krJdSt|||ƒ\}}|r„|j|_|r€|j r€|  t |jƒ¡dSdSdS)zÅReturn True if there is an effective breakpoint for this line. Check for line or function breakpoint and if in effect. Delete temporary breakpoints if effective() says to. FTN) rr7Ú co_filenamerrFÚco_firstlinenoÚ effectiveÚnumberZ currentbpÚ temporaryÚdo_clearÚstr)rr/rÚlinenoÚbpÚflagr r r r2Õs  zBdb.break_herecCs tdƒ‚dS)zlRemove temporary breakpoint. Must implement in derived classes or get NotImplementedError. z)subclass of bdb must implement do_clear()N)ÚNotImplementedError)rr0r r r rLðsz Bdb.do_clearcCs| |jj¡|jkS)zEReturn True if there is any breakpoint for frame's filename. )rr7rGr)rr/r r r r5÷szBdb.break_anywherecCsdS)z&Called if we might stop in a function.Nr )rr/Z argument_listr r r r:ÿsz Bdb.user_callcCsdS)z'Called when we stop or break at a line.Nr )rr/r r r r3sz Bdb.user_linecCsdS)z&Called when a return trap is set here.Nr )rr/Z return_valuer r r r<szBdb.user_returncCsdS)z$Called when we stop on an exception.Nr )rr/Úexc_infor r r r@ szBdb.user_exceptionrcCs||_||_d|_||_dS)zÖSet the attributes for stopping. If stoplineno is greater than or equal to 0, then stop at line greater than or equal to the stopline. If stoplineno is -1, then don't stop at all. FN)r6r;r'r=)rr6r;r=r r r r#szBdb._set_stopinfocCs$|dkr|jd}| |||¡dS)zxStop when the line with the lineno greater than the current one is reached or when returning from current frame.Nr)rFr#)rr/rNr r r Ú set_until s z Bdb.set_untilcCs0|jr |jj}|r |js |j|_| dd¡dS)zStop after one line of code.N)rr4Úf_tracer,r#)rZ caller_framer r r Úset_step(s  z Bdb.set_stepcCs| |d¡dS)z2Stop on the next line in or below the given frame.N)r#)rr/r r r Úset_next4sz Bdb.set_nextcCs.|jjt@r| |dd¡n| |j|¡dS)z)Stop when returning from the given frame.Nr)r7r8r9r#r4)rr/r r r Ú set_return8s zBdb.set_returncCsP|dkrt ¡j}| ¡x|r6|j|_||_|j}qW| ¡t |j¡dS)znStart debugging from frame. If frame is not specified, debugging starts from caller's frame. N) ÚsysÚ _getframer4r$r,rTr"rUÚsettrace)rr/r r r Ú set_trace?s  z Bdb.set_tracecCsL| |jdd¡|jsHt d¡t ¡j}x|rF||jk rF|`|j}q,WdS)z€Stop only at breakpoints or when finished. If there are no breakpoints, set the system trace function to None. Nr)r#r"rrXrZrYr4rT)rr/r r r Ú set_continueNs  zBdb.set_continuecCs"|j|_d|_d|_t d¡dS)zuSet quitting attribute to True. Raises BdbQuit exception in the next call to a dispatch_*() method. NT)r"r6r;r'rXrZ)rr r r Úset_quit]sz Bdb.set_quitFc Csb| |¡}ddl}| ||¡}|s.d||fS|j |g¡}||krN| |¡t|||||ƒ} dS)z°Set a new breakpoint for filename:lineno. If lineno doesn't exist for the filename, return an error message. The filename should be in canonical form. rNzLine %s:%d does not exist)rr ÚgetlinerÚ setdefaultÚappendr) rrrNrKÚcondÚfuncnamer r%ÚlistrOr r r Ú set_breakns    z Bdb.set_breakcCs4||ftjkr|j| |¡|j|s0|j|=dS)aPrune breakpoints for filname:lineno. A list of breakpoints is maintained in the Bdb instance and in the Breakpoint class. If a breakpoint in the Bdb instance no longer exists in the Breakpoint class, then it's removed from the Bdb instance. N)rÚbplistrÚremove)rrrNr r r Ú _prune_breaks€s zBdb._prune_breakscCsn| |¡}||jkrd|S||j|kr6d||fSx&tj||fdd…D] }| ¡qNW| ||¡dS)znDelete breakpoints for filename:lineno. If no breakpoints were set, return an error message. zThere are no breakpoints in %szThere is no breakpoint at %s:%dN)rrrreÚdeleteMerg)rrrNrOr r r Ú clear_break�s     zBdb.clear_breakc CsRy| |¡}Wn&tk r4}zt|ƒSd}~XYnX| ¡| |j|j¡dS)zxDelete a breakpoint by its index in Breakpoint.bpbynumber. If arg is invalid, return an error message. N)Úget_bpbynumberÚ ValueErrorrMrhrgÚfiler%)rr0rOÚerrr r r Úclear_bpbynumberžszBdb.clear_bpbynumbercCs`| |¡}||jkrd|Sx6|j|D](}tj||f}x|D] }| ¡q@Wq(W|j|=dS)z`Delete all breakpoints in filename. If none were set, return an error message. zThere are no breakpoints in %sN)rrrrerh)rrr%ZblistrOr r r Úclear_all_file_breaks«s   zBdb.clear_all_file_breakscCs0|js dSxtjD]}|r| ¡qWi|_dS)z]Delete all existing breakpoints. If none were set, return an error message. zThere are no breakpointsN)rrÚ bpbynumberrh)rrOr r r Úclear_all_breaksºs  zBdb.clear_all_breakscCs†|s tdƒ‚y t|ƒ}Wn"tk r:td|ƒd‚YnXytj|}Wn"tk rltd|ƒd‚YnX|dkr‚td|ƒ‚|S)z£Return a breakpoint by its index in Breakpoint.bybpnumber. For invalid arg values or if the breakpoint doesn't exist, raise a ValueError. zBreakpoint number expectedz Non-numeric breakpoint number %sNz!Breakpoint number %d out of rangezBreakpoint %d already deleted)rkÚintrrpÚ IndexError)rr0rJrOr r r rjÇs  zBdb.get_bpbynumbercCs"| |¡}||jko ||j|kS)z9Return True if there is a breakpoint for filename:lineno.)rr)rrrNr r r Ú get_breakÛs  z Bdb.get_breakcCs4| |¡}||jkr0||j|kr0tj||fp2gS)znReturn all breakpoints for filename:lineno. If no breakpoints are set, return an empty list. )rrrre)rrrNr r r Ú get_breaksás  zBdb.get_breakscCs&| |¡}||jkr|j|SgSdS)zrReturn all lines with breakpoints for filename. If no breakpoints are set, return an empty list. N)rr)rrr r r Úget_file_breaksës   zBdb.get_file_breakscCs|jS)z$Return all breakpoints that are set.)r)rr r r Úget_all_breaksöszBdb.get_all_breakscCsªg}|r|j|kr|j}x.|dk rF| ||jf¡||jkr>P|j}qW| ¡tdt|ƒdƒ}x$|dk r†| |j|j f¡|j}qdW|dkr¢tdt|ƒdƒ}||fS)zÀReturn a list of (frame, lineno) in a stack trace and a size. List starts with original calling frame, if there is one. Size may be number of frames above or below f. Nrr) Útb_frameÚtb_nextr`rFr"r4ÚreverseÚmaxÚlenÚ tb_lineno)rÚfÚtÚstackÚir r r Ú get_stackýs      z Bdb.get_stackú: c Csªddl}ddl}|\}}| |jj¡}d||f}|jjrH||jj7}n|d7}|d7}d|jkr‚|jd} |d7}|| | ¡7}| |||j ¡} | r¦|||   ¡7}|S)a:Return a string with information about a stack entry. The stack entry frame_lineno is a (frame, lineno) tuple. The return string contains the canonical filename, the function name or '', the input arguments, the return value, and the line of code (if it exists). rNz%s(%r)zz()Z __return__z->) r Úreprlibrr7rGÚco_nameÚf_localsr.r^rEÚstrip) rZ frame_linenoZlprefixr r„r/rNrÚsÚrvr%r r r Úformat_stack_entrys    zBdb.format_stack_entryc CsŽ|dkrddl}|j}|dkr"|}| ¡t|tƒr@t|ddƒ}t |j¡z*yt |||ƒWnt k rrYnXWdd|_ t d¡XdS)z„Debug a statement executed via the exec() function. globals defaults to __main__.dict; locals defaults to globals. NrzÚexecT) Ú__main__Ú__dict__r$Ú isinstancerMÚcompilerXrZr,r‹rr')rÚcmdÚglobalsÚlocalsrŒr r r Úrun3s    zBdb.runc Cst|dkrddl}|j}|dkr"|}| ¡t |j¡z&y t|||ƒStk rXYnXWdd|_t d¡XdS)z†Debug an expression executed via the eval() function. globals defaults to __main__.dict; locals defaults to globals. NrT) rŒr�r$rXrZr,Úevalrr')rÚexprr‘r’rŒr r r ÚrunevalIs   z Bdb.runevalcCs| |||¡dS)z.For backwards-compatibility. Defers to run().N)r“)rr�r‘r’r r r Úrunctx]sz Bdb.runctxc Os®t|ƒdkr|^}}}n>|s&tdƒ‚n0d|krB| d¡}|^}}ntdt|ƒdƒ‚| ¡t |j¡d}z(y|||Ž}Wntk r’YnXWdd|_t d¡X|S)zWDebug a single function call. Return the result of the function call. r>z6descriptor 'runcall' of 'Bdb' object needs an argumentÚfuncz7runcall expected at least 1 positional argument, got %drNT) r|Ú TypeErrorÚpopr$rXrZr,rr')ÚargsÚkwdsrr˜Zresr r r Úruncallds&        z Bdb.runcall)N)r)N)N)FNN)rƒ)NN)NN).rr r r rrr$r,r(r)r*r+rDr1r2rLr5r:r3r<r@r#rSrUrVrWr[r\r]rdrgrirnrorqrjrtrurvrwr‚rŠr“r–r—r�r r r r rsX  +              cCstƒ ¡dS)z|j|jf}d|j|j<|j| |¡|j|s:|j|=dS)z´Delete the breakpoint from the list associated to a file:line. If it is the last breakpoint in that position, it also deletes the entry for the file:line. N)rlr%rprJrerf)rÚindexr r r rh¶s    zBreakpoint.deleteMecCs d|_dS)zMark the breakpoint as enabled.TN)rŸ)rr r r ÚenableÄszBreakpoint.enablecCs d|_dS)z Mark the breakpoint as disabled.FN)rŸ)rr r r ÚdisableÈszBreakpoint.disablecCs"|dkrtj}t| ¡|d�dS)z•Print the output of bpformat(). The optional out argument directs where the output is sent and defaults to standard output. N)rl)rXÚstdoutr-Úbpformat)rÚoutr r r ÚbpprintÌszBreakpoint.bpprintcCsš|jr d}nd}|jr |d}n|d}d|j||j|jf}|jrT|d|jf7}|jrj|d|jf7}|jr–|jdkr€d }nd }|d |j|f7}|S) zôReturn a string with information about the breakpoint. The information includes the breakpoint number, temporary status, file:line position, break condition, number of times to ignore, and number of times hit. zdel zkeep zyes zno z%-4dbreakpoint %s at %s:%dz stop only if %sz ignore next %d hitsrrˆÚz" breakpoint already hit %d time%s)rKrŸrJrlr%rar r¡)rZdispZretZssr r r r§Ös$  zBreakpoint.bpformatcCsd|j|j|jfS)z1Return a condensed description of the breakpoint.zbreakpoint %s at %s:%s)rJrlr%)rr r r Ú__str__ôszBreakpoint.__str__)FNN)N)rr r r r¢rerprrhr¤r¥r©r§r«r r r r r‡s  cCsN|js|j|jkrdSdS|jj|jkr,dS|js:|j|_|j|jkrJdSdS)aVReturn True if break should happen here. Whether a break should happen depends on the way that b (the breakpoint) was set. If it was set via line number, check if b.line is the same as the one in the frame. If it was set via function name, check if this is the right function and if it is on the first executable line. FT)rbr%rFr7r…rž)Úbr/r r r Ú checkfuncnameûs  r­cCsºtj||f}x¦|D]ž}|js qt||ƒs,q|jd7_|jsf|jdkr\|jd8_qq²|dfSqy)r-)Úar r r rµds rµcCstƒ}| d¡dS)Nzimport bdb; bdb.foo(10))r¯r“)rr r r Útesthsrº)r rBrXrÚinspectrrrÚ__all__r9Ú Exceptionrrr[rr­rIr¯r¸rµrºr r r r Ús(  ut"0