Python bdb: the debugger framework behind breakpoints and pdb
Answer: The bdb module handles basic debugger functions, like setting breakpoints or managing execution.
Breakpoints
bdb handles basic debugger functions, including setting breakpoints and managing execution via the debugger.
BdbQuit is the exception the Bdb class raises when the debugger should quit.
Breakpoint implements temporary breakpoints, ignore counts, enabling and disabling, and conditions.
Breakpoints are indexed by number in bpbynumber and by (file, line) pairs in bplist. A single line may have more than one breakpoint.
The file name of a new breakpoint should already be in canonical form.
If funcname is set, a hit is counted on the function's first line. A conditional breakpoint always counts a hit.
Breakpoint methods include deleteMe, enable, disable, bpformat, and bpprint. bpformat was added in version 3.2.
Attributes include file, line, temporary, cond, funcname, enabled, ignore, and hits.
The Bdb class
Bdb is a generic Python debugger base class. It handles the trace facility, and a derived class should implement user interaction. pdb.Pdb is the standard example.
If given, skip must be an iterable of glob-style module name patterns. Frames from a module whose __name__ matches are not stepped into.
The backend argument is either settrace or monitoring. settrace uses sys.settrace and is the more compatible choice.
The monitoring backend uses sys.monitoring, added in 3.12, and can skip unused events.
The skip parameter arrived in 3.1, and backend arrived in 3.14.
canonic returns a case-normalized absolute path for real files. Names such as <stdin> are left unchanged.
start_trace and stop_trace were added in 3.14 and, with the settrace backend, map to sys.settrace.
See also
Claims
- id: C1 claim: bdb handles basic debugger functions such as breakpoints and execution control. source: S1 evidence: "The bdb module handles basic debugger functions, like setting"
- id: C2 claim: Breakpoint supports temporary breakpoints, ignore counts, and conditionals. source: S2 evidence: "This class implements temporary breakpoints, ignore counts, disabling"
- id: C3 claim: Bdb is a generic debugger base class; pdb.Pdb is one derived example. source: S1 evidence: "The Bdb class acts as a generic Python debugger base class"
Sources
- [S1] bdb — Debugger framework. Python Software Foundation. https://docs.python.org/3/library/bdb.html . License: PSF License Version 2. Accessed 2026-11-27.
- [S2] bdb documentation (source). CPython. https://raw.githubusercontent.com/python/cpython/main/Doc/library/bdb.rst . License: PSF License Version 2. Accessed 2026-11-27.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Python Software Foundation, bdb — Debugger framework; CPython, bdb documentation (source). PSF-2.0 (https://docs.python.org/3/license.html). Copyright Python Software Foundation. Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Python Software Foundation, bdb — Debugger framework; CPython, bdb documentation (source). PSF-2.0 (https://docs.python.org/3/license.html). Copyright Python Software Foundation.
Cite this
iinventedlight. 2026. "Python bdb: the debugger framework behind breakpoints and pdb." iinventedlight Library, iil:note:bx2cshpg, version of 2026-11-27. https://iinventedlight.com/library/notes/python-bdb/. License: CC-BY-4.0.
@misc{iil_note_bx2cshpg,
author = {{iinventedlight}},
title = {{Python bdb: the debugger framework behind breakpoints and pdb}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-27},
url = {https://iinventedlight.com/library/notes/python-bdb/},
note = {Permanent ID iil:note:bx2cshpg. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).
Extra files beside this note
These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.
- python-bdb.schema.json (schema; CC-BY-4.0)
- python-bdb.table.json (table; CC-BY-4.0)
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/python-bdb.md.