Foreword
Using gdb for command-line debugging still feels inconvenient. I initially wanted to find a simpler way to directly debug the PostgreSQL source code under Windows. After searching for a while, I found that Visual Studio (VS) was the only option available, but it is heavy and the steps are quite complex. Since most real environments run on Linux, it is better to debug the PostgreSQL source code under Linux.
How to build & install PostgreSQL from source code.
I used Ubuntu Linux environment, the first step we might need to install pre-requirement tool for PostgreSQL build.
1 | sudo apt-get update |
download PostgreSQL source code.
1 | wget https://ftp.postgresql.org/pub/source/v14.8/postgresql-14.8.tar.gz |
we would need to make sure the path (--prefix
) exist in your system.
1 | ./configure --prefix=/home/daniel/postgresql-14.8/pgsql --with-icu --with-openssl --with-systemd --with-libxml --enable-debug |
we must build with
--enable-debug
parameter, otherwise we can’t debug with our source code.