pgdbg is a small GDB helper for pretty-printing PostgreSQL Node trees, including indexed PostgreSQL List elements, from a live debugging session.
- loads a custom
pgprintcommand into GDB - detects PostgreSQL node pointers and formats them recursively
gdbwith Python support- a debug session where PostgreSQL types are available
This repository includes a Nix dev shell with gdb and python3:
nix developDo not run the Python files directly. Load them from inside GDB:
source /path/to/pgdbg/pgdbg.pyThat registers the pgprint command.
pgprint [--depth MAX_DEPTH] [--position POSITION] <expression>...
pgprint [--depth MAX_DEPTH] [--position POSITION] -- <expression>...Examples:
pgprint query
pgprint --depth 3 query
pgprint --position 0 query->targetList
pgprint --depth 2 --position 1 query->rtable
pgprint ((Node*)query)depth must be an integer greater than or equal to 1.
position must be an integer greater than or equal to 0.
Current specialized formatters live under nodes/:
T_QueryT_ListT_IntListT_OidListT_XidList
Other structs that look like PostgreSQL nodes still print through the generic base formatter.