Debugging 如何在调试C++;macOS上的vscode
在VScode上调试时如何添加用户输入 我试过以下方法Debugging 如何在调试C++;macOS上的vscode,debugging,visual-studio-code,Debugging,Visual Studio Code,在VScode上调试时如何添加用户输入 我试过以下方法 编辑my launch.json以设置externalConsole:true 如前所述,尝试将输入作为命令行参数 不管采用上述方法一步一步地进行操作,都会出现问题 我总是得到一扇我无能为力的窗户。升/降/进按钮处于非活动状态 在我的launch.json文件中 { // Use IntelliSense to learn about possible attributes. // Hover to view descr
- 编辑my launch.json以设置
externalConsole:true
- 如前所述,尝试将输入作为命令行参数
{
// 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": "g++-10 - Build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "lldb",
"preLaunchTask": "C/C++: g++-10 build active file"
}
]
}
{
"tasks": [
{
"type": "shell",
"label": "C/C++: g++-10 build active file",
"command": "g++",
"args": [
"-g",
"${file}",
"-std=c++17",
],
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
}
}
],
"version": "2.0.0"
}
这是我的tasks.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": "g++-10 - Build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "lldb",
"preLaunchTask": "C/C++: g++-10 build active file"
}
]
}
{
"tasks": [
{
"type": "shell",
"label": "C/C++: g++-10 build active file",
"command": "g++",
"args": [
"-g",
"${file}",
"-std=c++17",
],
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
}
}
],
"version": "2.0.0"
}
系统详细信息
Version: 1.48.1
Commit: 3dd905126b34dcd4de81fa624eb3a8cbe7485f13
Date: 2020-08-19T17:09:41.484Z
Electron: 7.3.2
Chrome: 78.0.3904.130
Node.js: 12.8.1
V8: 7.8.279.23-electron.0
OS: Darwin x64 20.0.0
在要点中给出了解决方案 问题是当VSCode启动调试适配器时,调试适配器启动lldb mi,然后lldb mi启动终端。应该出现一个提示,但DebugAdapter没有转发此权限请求 解决方法是让VS代码启动终端一次。您可以通过在
tasks.json中添加并运行此任务来完成此操作:
您可以使用Command+Shift+p运行此特定任务。键入任务并查找任务:运行任务,然后选择打开终端
我写了一篇关于这一点的小博文,用可以找到的图片详细描述了每一步