我正在尝试在Mac上的VS Code中调试C ++代码。我可以编译它并运行可执行文件,但是当我使用launch.json启动调试器时,它不会在断点处停止。断点变灰,当我将光标放在其上时,它显示未验证的断点。并且调用堆栈显示“未知来源”。我想念什么吗?
Launch.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": "(lldb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/xyz",
"preLaunchTask": "Makefile",
"logging": {
"moduleLoad": false,
"programOutput": true,
"trace": true
},
"args": ["--file", "file", "> abc.json"],
"stopAtEntry": true,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "lldb"
}
]
}
tasks.json:
"version": "0.1.0",
"command": "make",
"isShellCommand": true,
"tasks": [
{
"taskName": "Makefile",
// Make this the default build command.
"isBuildCommand": true,
// Show the output window only if unrecognized errors occur.
"showOutput": "always",
// Pass 'all' as the build target
"args": ["all"],
// Use the standard less compilation problem matcher.
"problemMatcher": {
"owner": "cpp",
"fileLocation": ["relative", "${workspaceRoot}"],
"pattern": {
"regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
}
}
]
}
c_cpp_properties.json:
"configurations": [
{
"name": "Mac",
"includePath": [
"${workspaceFolder}/**",
"${workspaceRoot}/deps"
],
"defines": [],
"macFrameworkPath": [
"/System/Library/Frameworks",
"/Library/Frameworks"
],
"compilerPath": "/usr/bin/clang",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "clang-x64"
}
],
"version": 4
}
答案 0 :(得分:0)
为此,请执行以下步骤
opne工作目录
安装扩展
名称:C / C ++ 链接:https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools- 打开调试选项,然后单击设置按钮以打开launch.json文件。
- 您需要使用完整路径更改已执行文件的程序范围。