bdb — Debugger framework¶
Source code: Lib/bdb.py
The bdb module handles basic debugger functions, like setting breakpoints
or managing execution via the debugger.
The following exception is defined:
The bdb module also defines two classes:
-
class
bdb.Breakpoint(self, file, line, temporary=0, cond=None, funcname=None)¶ This class implements temporary breakpoints, ignore counts, disabling and (re-)enabling, and conditionals.
Breakpoints are indexed by number through a list called
bpbynumberand by(file, line)pairs throughbplist. The former points to a single instance of classBreakpoint. The latter points to a list of such instances since there may be more than one breakpoint per line.When creating a breakpoint, its associated filename should be in canonical form. If a funcname is defined, a breakpoint hit will be counted when the first line of that function is executed. A conditional breakpoint always counts a hit.
Breakpointinstances have the following methods:-
deleteMe()¶ 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.
-
enable()¶ Mark the breakpoint as enabled.
-
disable()¶ Mark the breakpoint as disabled.
-
bpformat()¶ Return a string with all the information about the breakpoint, nicely formatted:
The breakpoint number.
If it is temporary or not.
Its file,line position.
The condition that causes a break.
If it must be ignored the next N times.
The breakpoint hit count.
New in version 3.2.
-
bpprint(out=None)¶ Print the output of
bpformat()to the file out, or if it isNone, to standard output.
-
-
class
bdb.Bdb(skip=None)¶ The
Bdbclass acts as a generic Python debugger base class.This class takes care of the details of the trace facility; a derived class should implement user interaction. The standard debugger class (
pdb.Pdb) is an example.The skip argument, if given, 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.New in version 3.1: The skip argument.
The following methods of
Bdbnormally don’t need to be overridden.-
canonic(filename)¶ Auxiliary method for getting a filename in a canonical form, that is, as a case-normalized (on case-insensitive filesystems) absolute path, stripped of surrounding angle brackets.
-
reset()¶ Set the
botframe,stopframe,returnframeandquittingattributes with values ready to start debugging.
-
trace_dispatch(frame, event, arg)
-