在Centos 7上使用VS Code来debug OpenGauss
openGauss debug
·
前置条件
- 已经安装gdb,可以运行命令
gdb -v来确认是否安装。在centos7下面,可以通过命令yum install gdb来安装gdb。 - openGauss能够成功编译并且运行。注意,在执行configure命令的时候必须包含–enable-debug选项。
- vscode 安装C/C++插件
debug配置文件
- 使用vscode打开项目文件后,点击在顶部菜单栏run中,找到add configuration选项,点击生成debug配置文件。
- 将下面的内容粘贴到配置文件中。“program”对应的值为gaussdb的安装路径,请按照实际情况进行修改。
{
// 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": "${workspaceFolder}/dest/bin/gaussdb",
"processId": "${command:pickProcess}",
"MIMode": "gdb",
"miDebuggerPath": "/usr/bin/gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "ignore SIGUSR2 signal",
"text": "handle SIGUSR2 nostop noprint pass"
},
{
"description": "Set Disassembly Flavor to Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
],
},
]
}
开始debug
- 启动openGauss
- 在顶部菜单栏
run中,找到start debugging选项,点击后,会弹出进程选择页面,找到名为gaussdb的进程选中即可开始debug。 - 在
src/gausskernel/process/tcop/postgres.cpp里面,存在一个exec_simple_query函数,该函数是查询的入口,可以在这个函数里面设置断点,然后执行查询,如果能够停住,说明debug配置成功。
鲲鹏昇腾开发者社区是面向全社会开放的“联接全球计算开发者,聚合华为+生态”的社区,内容涵盖鲲鹏、昇腾资源,帮助开发者快速获取所需的知识、经验、软件、工具、算力,支撑开发者易学、好用、成功,成为核心开发者。
更多推荐

所有评论(0)