GDBmongo

0.16.0 · active · verified Sun Apr 12

GDBmongo provides GDB pretty printers and commands specifically designed for debugging the MongoDB Server. It enhances GDB's capabilities to better inspect complex MongoDB data structures. The library is actively maintained, with version 0.16.0 being the latest as of the last verification, and typically follows a periodic release cadence to keep up with MongoDB Server developments.

Warnings

Install

Imports

Quickstart

To quickly integrate `gdbmongo` with GDB, add the provided Python snippet to your `~/.gdbinit` file. This script attempts to import `gdbmongo` and, if it fails, can optionally try to install it using `pip` within the GDB's Python environment (especially useful for specific toolchains). After import, it registers the essential pretty printers. You can then launch GDB and use commands like `(gdb) enable pretty-printer global gdbmongo-mongo-extras` to activate other collections.

# In your ~/.gdbinit file:
python
try:
    import gdbmongo
except ImportError:
    import sys
    # Example: Attempt to install gdbmongo if not found (e.g., in a specific toolchain Python)
    if sys.prefix.startswith('/opt/mongodbtoolchain/'): # Adjust path as needed for your environment
        import subprocess
        subprocess.run([sys.prefix + '/bin/python3', '-m', 'pip', 'install', 'gdbmongo'], check=True)
        import gdbmongo
    else:
        import warnings
        warnings.warn("Not attempting to install gdbmongo into non-MongoDB toolchain Python")

# Register printers if gdbmongo was successfully imported
if 'gdbmongo' in dir():
    gdbmongo.register_printers(essentials=True, stdlib=False, abseil=False, boost=False, mongo_extras=False)
end

view raw JSON →