GDB Typing Stubs

raw JSON →
16.3.0.20260408 verified Fri May 01 auth: no python

Typing stubs for GDB (GNU Debugger) provided by typeshed. Version 16.3.0.20260408 provides type annotations for the gdb Python module, enabling static type checking with mypy or pyright. Stubs are updated weekly to match the latest GDB release.

pip install types-gdb
error ModuleNotFoundError: No module named 'gdb'
cause GDB Python module is not installed; it is part of GDB itself.
fix
Install GDB (e.g., 'apt install gdb' or 'brew install gdb'). The stubs are only for type-checking.
error Cannot find reference 'Frame' in 'gdb.py'
cause Outdated stub version or incorrect import path.
fix
Upgrade types-gdb: 'pip install --upgrade types-gdb'. Use 'import gdb' then reference gdb.Frame.
deprecated Importing from 'gdb.types' is deprecated; use 'gdb' directly for type hints.
fix Replace 'from gdb.types import ...' with 'import gdb' and use gdb.Type directly.
breaking Earlier versions may have incorrect signatures for gdb.execute. If using type: ignore or casting, update stubs.
fix Upgrade to 16.x and ensure your type hints match the new stub signatures.
gotcha These stubs assume the gdb module is available. They only provide type hints and do not install the debugger.
fix Ensure GDB is installed (e.g., 'apt install gdb') separately from the stubs.

Register a breakpoint event handler using typed stubs.

import gdb

def break_handler(event: gdb.BreakpointEvent) -> None:
    print(f"Hit breakpoint {event.breakpoint.number}")

gdb.events.stop.connect(break_handler)
# Run with: gdb -batch -ex run -ex bt ./some_binary