VSCode调试PostgreSQL配置

1,039 阅读1分钟

本文已参与「新人创作礼」活动,一起开启掘金创作之路

昨天折腾了很久才配置好,这里简单记录下。

打开lauch.json
菜单 View -> Command Palette,输入launch,选择 Debug: Open launch.json
在这里插入图片描述

选择 C++ (GDB/LLDB)
在这里插入图片描述
编辑 launch.json 文件
注意:根据你的PG环境,修改相关的路径(建议写成绝对路径)

GDB配置:

{
    "version": "0.2.0",
    "configurations": [
    {
        "name": "(gdb) 附加",
        "type": "cppdbg",
        "request": "attach",
        "program": "/home/postgres/test/bin/postgres",
        "processId": "${command:pickProcess}",
        "MIMode": "gdb",
        "setupCommands": [
            {
                "description": "为 gdb 启用整齐打印",
                "text": "-enable-pretty-printing",
                "ignoreFailures": true
            }
        ]
    }
    ]
}

LLDB配置:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(lldb) attach",
            "type": "cppdbg",
            "request": "attach",
            "program": "${workspaceFolder}/backend/postgres",
            "processId": "${command:pickProcess}",
            "MIMode": "lldb",
            "setupCommands": [
                {
                    "description": "为 gdb 启用整齐打印",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ]
        }
    ]
}

然后就可以开始调试了:
在这里插入图片描述

参考链接:
www.postgres.cn/v2/news/vie…