Hello, in this bog we will be learning how to add a debugger sowe can debug our apache AGE source code.
Today we will simply install the debugger and learn how to use it.
Prerequisites
- AGE PostgreSQL Source code installed
- PostgreSQL Source code installed (with debg enabled)
- VSCode
- GDB
Step 1: Starting your PostgreSQL server
First go to the directory where you postgreSQL is installed
cd posgresql-16beta1
Then initialize your DB cluster
bin/initdb demo
Start your server
bin/pg_ctl -D demo -l logfile start
Then create your database
bin/createdb demodb
Then to access the database run
bin/psql demodb
Step 2: Getting backend pid
Using this command to check the backend process ID where postgresql server is running.
SELECT pg_backend_pid();
Step 3: Setting up AGE in VS Code
Open The AGE source code you have installed and then mainly install the
- C/C++ Plugin
- C/C++ Extension Pack Plugin
Both are from microsoft
After this press F5 and you can edit the launch.json file.
Add the path to your postgres like this in the file and save it
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Attach",
"type": "cppdbg",
"request": "attach",
"program": "/home/hannanaamir/age16/postgresql-16beta1/bin/postgres",
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "Set Disassembly Flavor to Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
]
}
]
}
Step4: Start Debugging
Now again press F5 and now paste the pid of your server
You have now successfully enabled the debugger
Now in your code you can setup breakpoints and then load AGE in the sever
CREATE EXTENSION age;
LOAD 'age';
SET search_path = ag_catalog, "$user", public;
Now you can see how the code runs and behave you can also run further querries and see how it behaves with them. I hope this helps.
Extra
To help with postgreSQL and AGE installation you can follow this blog https://imranzaheer.hashnode.dev/install-age-psql-from-source
Top comments (0)