ros工程vscode下配置gdb的调试环境需要添加几个配置文件,下面贴一下用得到的几个配置文件。
- c_cpp_properties.json,这个配置作用是方便代码跳转。
{
"configurations": [
{
"browse": {
"databaseFilename": "${default}",
"limitSymbolsToIncludedHeaders": false
},
"includePath": [
"/opt/ros/noetic/include/**",
"/usr/include/**"
],
"name": "ROS",
"intelliSenseMode": "gcc-x64",
"compilerPath": "/usr/bin/gcc",
"cStandard": "gnu11",
"cppStandard": "c++14"
}
],
"version": 4
}
备注:需要在vscode中安装ROS插件。
- 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": "Ros Debug",
"request": "launch",
"preLaunchTask": "catkin_make: Debug",
"target": "${workspaceFolder}/xx.launch",
"launch": [
"rviz",
"gz",
"gzclient",
"gzserver"
],
"type": "ros"
},
{
"name": "Ros RelWithDebInfo",
"request": "launch",
"preLaunchTask": "catkin_make: RelWithDebInfo",
"target": "${workspaceFolder}/xx.launch",
"launch": [
"rviz",
"gz",
"gzclient",
"gzserver"
],
"type": "ros"
},
{
"name": "Ros Release",
"request": "launch",
"preLaunchTask": "catkin_make: Release",
"target": "${workspaceFolder}/xx.launch",
"launch": [
"rviz",
"gz",
"gzclient",
"gzserver"
],
"type": "ros"
}
]
}
- tasks.json
{
"version": "2.0.0",
"tasks": [
{
"type": "catkin_make_isolated",
"args": [
"-DCMAKE_EXPORT_COMPILE_COMMANDS=1",
"--install",
"--use-ninja",
"--ignore-pkg",
"ms_lams",
"-DCMAKE_BUILD_TYPE=Debug"
],
"problemMatcher": [
"$catkin-gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"label": "catkin_make: Debug"
},
{
"type": "catkin_make_isolated",
"args": [
"--install",
"--use-ninja",
"--ignore-pkg",
"ms_lams",
"-DCMAKE_BUILD_TYPE=RelWithDebInfo",
"-DCMAKE_EXPORT_COMPILE_COMMANDS=1"
],
"problemMatcher": [
"$catkin-gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"label": "catkin_make: RelWithDebInfo"
},
{
"type": "catkin_make_isolated",
"args": [
"--install",
"--use-ninja",
"--ignore-pkg",
"ms_lams",
"-DCMAKE_BUILD_TYPE=Release",
"-DCMAKE_EXPORT_COMPILE_COMMANDS=1"
],
"problemMatcher": [
"$catkin-gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"label": "catkin_make: Release"
}
]
}