Mac下C/C++调试插件CodeLLDB配置
vscode配置文件在项目列表的.vscode文件下,每新建一个工程都需要自己创建配置文件
设定好 launch.json 和 task.json 来进行构建和debug启动。
//vscode预设变量
${workspaceFolder} :表示当前workspace文件夹路径,也即/home/Coding/Test
${workspaceRootFolderName}:表示workspace的文件夹名,也即Test
${file}:文件自身的绝对路径,也即/home/Coding/Test/.vscode/tasks.json
${relativeFile}:文件在workspace中的路径,也即.vscode/tasks.json
${fileBasenameNoExtension}:当前文件的文件名,不带后缀,也即tasks
${fileBasename}:当前文件的文件名,tasks.json
${fileDirname}:文件所在的文件夹路径,也即/home/Coding/Test/.vscode
${fileExtname}:当前文件的后缀,也即.json
${lineNumber}:当前文件光标所在的行号
${env:PATH}:系统中的环境变量
//tasks.json
{
"version": "2.0.0",
"tasks": [
{
"label": "Build with Clang",//这个任务的名字在launch.json最后一项配置
"type": "shell",
"command": "clang++",//根据实际使用语言选择clang/clang++
"args": [
"-std=c++17",
"-stdlib=libc++",
"*.cpp",
"-o",
"a.out",
"--debug"
],
/*"command": "clang",
"args": [
"*.c",
"-o",
"a.out",
"--debug"
],*/
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
//launch.json
{
"version": "0.2.0",
"configurations": [
{
"type": "lldb",
"request": "launch",
"name": "Debug",
"program": "${workspaceFolder}/a.out",//根据实际情况修改文件名称
"args": [],
"cwd": "${workspaceFolder}",
"preLaunchTask": "Build with Clang"
}
]
}