Vscode docker c++debug launch.json
时间: 2023-12-12 17:24:10 浏览: 201
以下是一个使用VS Code和Docker进行C++调试的示例launch.json文件:
```json
{
"version": "0.2.0",
"configurations": [
{
"name": "Docker C++ Debug",
"type": "cppdbg",
"request": "launch",
"program": "/path/to/your/executable",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"miDebuggerPath": "/usr/bin/gdb",
"miDebuggerArgs": "-q",
"setupCommands": [
{
"description": "Enable gdb pretty-printing for gdb 7.5 and later",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"dockerLaunch": {
"image": "your-docker-image-name",
"dockerBuild": "always",
"network": "host",
"mounts": [
{
"source": "${workspaceFolder}",
"target": "/mnt",
"type": "bind",
"consistency": "cached"
}
],
"ports": [
{
"containerPort": 8080,
"hostPort": 8080
}
],
"command": "bash"
},
"sourceFileMap": {
"/mnt": "${workspaceFolder}"
}
}
]
}
```
你需要将其中的`/path/to/your/executable`替换为你的可执行文件所在的路径,将`your-docker-image-name`替换为你的Docker镜像名称。如果你的可执行文件与源代码在同一目录下,可以将`/path/to/your/executable`替换为`./your-executable`。
此外,这个配置文件还使用`dockerLaunch`选项指定了一些Docker容器的配置,包括镜像名称、网络设置、挂载卷、端口映射等等。你需要根据你的实际情况进行修改。
最后,你需要在VS Code中打开你的工作区,并在调试面板中选择`Docker C++ Debug`配置,然后按下F5键启动调试器。
阅读全文
相关推荐
















