如何调试C++;Mac上的代码与Mac上的代码? 我试图在MAC上的VS代码中调试我的C++代码。我可以编译它并运行可执行文件,但当我使用launch.json启动调试器时,它不会在断点处停止。断点变灰,当我把光标放在上面时,它会显示未验证的断点。调用堆栈显示未知源。我错过什么了吗

如何调试C++;Mac上的代码与Mac上的代码? 我试图在MAC上的VS代码中调试我的C++代码。我可以编译它并运行可执行文件,但当我使用launch.json启动调试器时,它不会在断点处停止。断点变灰,当我把光标放在上面时,它会显示未验证的断点。调用堆栈显示未知源。我错过什么了吗,c++,macos,debugging,visual-studio-code,vscode-debugger,C++,Macos,Debugging,Visual Studio Code,Vscode Debugger,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", "confi

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
}

为此,请遵循以下步骤

  • opne工作目录

  • 安装扩展插件
    姓名:C/C++ 链接:

  • 打开调试选项并单击打开launch.json文件的设置按钮
  • 您需要使用完整路径的执行文件更改程序feild