1、设置CMakeLists.txt,保证CMake是在debug模式下:
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")
2、设置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) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/dds_test/Fast_DDS_lidar/build/DataTranSeqExampleTCP",//设置为编译完的可执行文件
// "program": "${fileDirname}/${fileBasenameNoExtension}",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath":"/usr/bin/gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
3、打上断点就可以进行断点调试了
|