In this blog we will have a debugging session using vscode it looks similar to the previous blog using GDB but here we will add some configurations for vscode.
After opening vscode on the age project directory, you will see .vscode
directory. Make sure that to put all the following configurations
Note: replace 'yourUserName' in the following files with your current system username
launch.json
{
// 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/yourUserName/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
}
]
}
]
}
settings.json
{
"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"
}
}
c_cpp_properties.json
{
"configurations": [
{
"name": "Linux",
"includePath": [
"/usr/include/**/**",
"${workspaceFolder}/**",
"/usr/include/**",
"/usr/local/pgsql/include/**",
"/usr/local/pgsql/include/server/**",
"/home/yourUserName/postgresql-14.7/src/**",
"/home/yourUserName/postgresql-14.7/**",
"/home/yourUserName/postgresql-14.7/src/backend/**",
"/usr/local/pgsql/lib/**",
"${workspaceFolder}/src/include/**"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "c11",
"cppStandard": "gnu++17",
"intelliSenseMode": "linux-gcc-x64",
"configurationProvider": "ms-vscode.makefile-tools"
}
],
"version": 4
}
Now we can start debugging
- START postgres server and CONNECT through psql session
- In the psql terminal get the session pid using command
SELECT pg_backend_pid();
- Set your breakpoints
- press F5 then type PID that you got in a previous step
run a query on the psql
terminal and the debugging will begin.
Ref:
apache age repo
Top comments (0)