DEV Community

Mohamed Mokhtar
Mohamed Mokhtar

Posted on • Updated on

How to debug AGE source code on VSCode

Welcome everyone
Today we will set up our environment to debug and work with AGE source code on VSCode Editor.


  • Postgresql source code installed
  • AGE source code & installed
  • VSCode for sure
  • GDB

Our case here we will debug a function that we have added to the source code if you have missed adding some functions to AGE source code you can find that out on my blog, here is the link of it:

Lets set up our AGE git repository to exclude some of our new created directory which is .vscode

echo '/.vscode/*' >> .git/info/exclude
Enter fullscreen mode Exit fullscreen mode

We will need to modify out local git repo to exclude that directory we are going to work with to setup the linkage of our source-codes and header files so that whenever we click on smth it gets navigation to that function/file

cd .git/info
sudo nano exclude
Enter fullscreen mode Exit fullscreen mode

Add whatever you want to exclude just like .gitignore but it works on you local machine only.
REPLACE all /home/rrr/postgresql-14.7/ with corresponding postgresql directory on your machine
AND /usr/local/pgsql/ with your installed postgresl directory

  • incase of you are having the source code and installation on same directory, they will be the same.


    "configurations": [
            "name": "Linux",
            "includePath": [
            "defines": [],
            "compilerPath": "/usr/bin/gcc",
            "cStandard": "c11",
            "cppStandard": "gnu++17",
            "intelliSenseMode": "linux-gcc-x64",
            "configurationProvider": "ms-vscode.makefile-tools"
    "version": 4
Enter fullscreen mode Exit fullscreen mode


    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit:
    "version": "0.2.0",
    "configurations": [
            "name": "(gdb) Attach",
            "type": "cppdbg",
            "request": "attach",
            "program": "/home/rrr/postgresql-14.7/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

Enter fullscreen mode Exit fullscreen mode


    "files.associations": {
        "postgres.h": "c",
        "genam.h": "c",
        "heapam.h": "c",
        "tableam.h": "c",
        "table.h": "c",
        "htup_details.h": "c",
        "skey.h": "c",
        "pg_operator.h": "c",
        "namespace.h": "c"
Enter fullscreen mode Exit fullscreen mode

Now you are supposed to have all of your headers and linkage works properly

LETS dive into the debugging

  1. START postgres server
  2. CONNECT through psql session
  3. GET THE pid of that backend process through

    SELECT pg_backend_pid();
  4. SET your breakpoints on your function or anywhere you want

  5. Get start with the debugging on VS code through click on F5 and write the process id you got from the psql session

  6. Write commands to the psql session (call your function to get into that and reach the break points you have set

  7. Have a good debugging day <3

Another debugging blog:


References & Resources

Top comments (0)