Mac OS VScode C/C++ debug breakpoint is invalid

Original source: https://blog.csdn.net/fonnn/article/details/104065273

The new mac system Calalina was updated. On the first day, I found that I needed to update a certain Xcode command line environment package (with a confused face) so that the include would not report an error.

The next day after the update, it was found that the breakpoint was invalid, and debugging was like running directly.

The text is as follows

  • 1) Download the CodeLLDB extension in VSCode

  • 2) Replace the contents of the two configuration files launch.json and tasks.json with

  • lauch.json:

{
    
    
    "version": "0.2.0",
    "configurations": [
        {
    
    
            "name": "clang++ build and debug active file",
            "type": "lldb",
            "request": "launch",
            "program": "${fileDirname}/${fileBasenameNoExtension}.out",
            "args": [],
            "cwd": "${workspaceFolder}",
            "preLaunchTask": "clang++ build active file"
        }
    ]
}
  • tasks.json
{
    
    
    "version": "2.0.0",
    "tasks": [
        {
    
    
            "label": "clang++ build active file",
            "type": "shell",
            "command": "clang++",
            "args": [
                "${fileBasename}",
                "-o",
                "${fileBasenameNoExtension}.out",
                "-g"
            ],
            "group": {
    
    
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}

Remember to install the CodeLLDB plug-in when you are done

Insert picture description here

Attachment: original configuration file

launch.json

{
    
    
    // 使用 IntelliSense 了解相关属性。 
    // 悬停以查看现有属性的描述。
    // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
    
        {
    
    
            "name": "clang++ - 生成和调试活动文件",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}/${fileBasenameNoExtension}",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": true,
            "MIMode": "lldb",
            "preLaunchTask": "C/C++: clang++ build active file"
        }
    ]
}

tasks.json

{
    
    
    "tasks": [
        {
    
    
            "type": "cppbuild",
            "label": "C/C++: clang++ build active file",
            "command": "/usr/bin/clang++",
            "args": [
                "-g",
                "${file}",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}"
            ],
            "options": {
    
    
                "cwd": "${workspaceFolder}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
    
    
                "kind": "build",
                "isDefault": true
            },
            "detail": "Task generated by Debugger."
        }
    ],
    "version": "2.0.0"
}

Guess you like

Origin blog.csdn.net/SL_World/article/details/112974539
Recommended