{
//${workspaceRoot} the path of the folder opened in VS Code(VSCode中打开文件夹的路径)
//${workspaceRootFolderName} (VSCode中打开文件夹的路径, 但不包含"/")
//${file} the current opened file(当前打开的文件)
//${relativeFile} (当前打开的文件,相对于workspaceRoot)
//${fileBasename} (当前打开文件的文件名, 不含扩展名)
//${fileDirname} (当前打开文件的目录名)
//${fileExtname} (当前打开文件的扩展名)
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",// 配置名称,将会在启动配置的下拉菜单中显示
"type": "cppdbg",// 配置类型,这里只能为cppdbg
"request": "launch",// 请求配置类型,可以为launch(启动)或attach(附加)
"program": "${workspaceFolder}/detect/test/detect_demo",// 将要进行调试的程序的路径
"args": ["--rgb_video","/data/data/videos/car1_20170525.mp4"],// 程序调试时传递给程序的命令行参数
"stopAtEntry": false,// 设为true时程序将暂停在程序入口处,一般设置为false
"cwd": "${workspaceRoot}/detect/test",// 可执行程序的启动路径
"environment": [],
"externalConsole": true,// 调试时是否显示控制台窗口,一般设置为true显示控制台
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
3.若出现问题:Unable to start debugging. Failed to initialize debugger terminal.
在launch.json中添加如下配置
"pipeTransport": {
"pipeCwd": "/usr/bin",
"pipeProgram": "/bin/sh",
"debuggerPath": "/usr/bin/gdb",
"pipeArgs": [
"-c"
]
},
{
"version": "2.0.0",
"tasks": [
{
"label": "echo",
"type": "shell",
"command": "echo Hello"
}
]
}
2.在launch.json的“cwd”后添加"preLaunchTask": "Make detect demo",
其中Make detect demo需要与tasks.json中的label一致。
"stopAtEntry": false,// 设为true时程序将暂停在程序入口处,一般设置为false
"cwd": "${workspaceRoot}/detect/test",// 可执行程序的启动路径
"preLaunchTask": "Make detect demo"
"environment": [],
"externalConsole": true,// 调试时是否显示控制台窗口,一般设置为true显示控制台
"MIMode": "gdb",
3.tasks.json配置如下
{
"version": "2.0.0",
"tasks": [
{
"label": "Make detect demo",//与launch.json的文件中的preLaunchTask保持一致
"type": "shell",
"command": "make -j8",
//"command": "./build.sh",//此处也可将所要执行的命令写在shell脚本里支执行
"options": {
"cwd": "build"//进入到build文件夹
},
"args": [
], // 程序调试时传递给程序的命令行参数
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
3.按F5键开始调试,会自动编译最新的文件