安装推荐的插件,确保有CodeLLDB


打开文件后,终端->配置默认生成任务

选择合适的编译器人物模板

得到tasks.json文件,并编辑
将label的内容改为build,得到
```json
{
"version": "2.0.0",
"tasks": [
{
"type": "cppbuild",
"label": "build",
"command": "/usr/bin/clang++",
"args": [
"-std=c++20",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}.out"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "编译器: /usr/bin/clang++"
}
]
}
```
在运行调试中创建`launch.js`

点击创建`launch.json`文件
环境选择LLDB

得到`launch.json`文件
更改`program`的内容为
```json
"program": "${workspaceFolder}/${fileBasenameNoExtension}.out"
```
增加`preLaunchTask`
```json
"preLaunchTask": "build"
```
得到
```json
{
"version": "0.2.0",
"configurations": [
{
"type": "lldb",
"request": "launch",
"name": "Debug",
"program": "${fileDirname}/${fileBasenameNoExtension}.out",
"args": [],
"preLaunchTask": "build",
"cwd": "${workspaceFolder}"
}
]
}
```
调试运行即可
0 Comments latest
No comments.