bdb.Bdb
Up: bdb | Next: bdb.BdbQuit
Rel: bdb.BdbQuit, bdb.Breakpoint
Ref: docs.python.org — bdb.Bdb
Tags: #public #python3 #stdlib #bdb
Import
import bdb
from bdb import Bdb
Signature & Overview
bdb.Bdb(skip=None, backend='settrace')
Generic Python debugger base class.
Methods & Attributes
Bdb.break_anywhere(self, frame)— Return True if there is any breakpoint in that frameBdb.break_here(self, frame)— Return True if there is an effective breakpoint for this line.Bdb.canonic(self, filename)— Return canonical form of filename.Bdb.clear_all_breaks(self)— Delete all existing breakpoints.Bdb.clear_all_file_breaks(self, filename)— Delete all breakpoints in filename.Bdb.clear_bpbynumber(self, arg)— Delete a breakpoint by its index in Breakpoint.bpbynumber.Bdb.clear_break(self, filename, lineno)— Delete breakpoints for filename:lineno.Bdb.disable_current_event(self)— Disable the current event.Bdb.dispatch_call(self, frame, arg)— Invoke user function and return trace function for call event.Bdb.dispatch_exception(self, frame, arg)— Invoke user function and return trace function for exception event.Bdb.dispatch_line(self, frame)— Invoke user function and return trace function for line event.Bdb.dispatch_opcode(self, frame, arg)— Invoke user function and return trace function for opcode event.Bdb.dispatch_return(self, frame, arg)— Invoke user function and return trace function for return event.Bdb.do_clear(self, arg)— Remove temporary breakpoint.Bdb.format_stack_entry(self, frame_lineno, lprefix=': ')— Return a string with information about a stack entry.Bdb.get_all_breaks(self)— Return all breakpoints that are set.Bdb.get_bpbynumber(self, arg)— Return a breakpoint by its index in Breakpoint.bybpnumber.Bdb.get_break(self, filename, lineno)— Return True if there is a breakpoint for filename:lineno.Bdb.get_breaks(self, filename, lineno)— Return all breakpoints for filename:lineno.Bdb.get_file_breaks(self, filename)— Return all lines with breakpoints for filename.Bdb.get_stack(self, f, t)— Return a list of (frame, lineno) in a stack trace and a size.Bdb.is_skipped_module(self, module_name)— Return True if module_name matches any skip pattern.Bdb.reset(self)— Set values of attributes as ready to start debugging.Bdb.restart_events(self)— Restart all events.Bdb.run(self, cmd, globals=None, locals=None)— Debug a statement executed via the exec() function.Bdb.runcall(self, func, /, *args, **kwds)— Debug a single function call.Bdb.runctx(self, cmd, globals, locals)— For backwards-compatibility. Defers to run().Bdb.runeval(self, expr, globals=None, locals=None)— Debug an expression executed via the eval() function.Bdb.set_break(self, filename, lineno, temporary=False, cond=None, funcname=None)— Set a new breakpoint for filename:lineno.Bdb.set_continue(self)— Stop only at breakpoints or when finished.Bdb.set_enterframe(self, frame)—Bdb.set_enterframemethod/property.Bdb.set_next(self, frame)— Stop on the next line in or below the given frame.Bdb.set_quit(self)— Set quitting attribute to True.Bdb.set_return(self, frame)— Stop when returning from the given frame.Bdb.set_step(self)— Stop after one line of code.Bdb.set_stepinstr(self)— Stop before the next instruction.Bdb.set_trace(self, frame=None)— Start debugging from frame.Bdb.set_until(self, frame, lineno=None)— Stop when the line with the lineno greater than the current one is reached or when returning from current frame.Bdb.start_trace(self)—Bdb.start_tracemethod/property.Bdb.stop_here(self, frame)— Return True if frame is below the starting frame in the stack.
Usage
import bdb
class Tracer(bdb.Bdb):
def __init__(self):
super().__init__()
self.seen = []
def user_call(self, frame, args):
self.seen.append(frame.f_code.co_name)
tr = Tracer()
assert tr.runcall(lambda: 42) == 42 and "<lambda>" in tr.seen
Gotchas
- Base class behind
pdb.Pdb: High runtime overhead—use for debugging tools, not production hot paths.
REPL Inspect
from bdb import Bdb
help(Bdb)
Linked from
Related notes
- tuts/python3/stdlib_module/bdb/BdbQuit Linked here; links to this page; shared tags: #bdb, #stdlib
- tuts/python3/stdlib_module/bdb/Breakpoint Linked here; links to this page; shared tags: #bdb, #stdlib
- tuts/python3/stdlib_module/bdb links to this page; shared tags: #stdlib
- tuts/c/stdlib shared tags: #stdlib
- tuts/c/stdlib/assert shared tags: #stdlib
- tuts/c/stdlib/assert/assert shared tags: #stdlib
- tuts/c/stdlib/assert/static_assert shared tags: #stdlib
- tuts/c/stdlib/ctype shared tags: #stdlib
- tuts/c/stdlib/ctype/isalpha shared tags: #stdlib
- tuts/c/stdlib/ctype/isdigit shared tags: #stdlib