Daniil Andreev
Daniil Andreev

Reputation: 247

How to debug in VS Code using lldb?

I'm trying to debug a simple C++ program, but nothing happens, and breakpoints are also not working. Build task runs fine, and I can run the application.

tasks.json

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

launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "clang++.exe - Build and debug active file",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
            "args": [],
            "stopAtEntry": true,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "lldb",
            "miDebuggerPath": "F:\\Programs\\LLVM\\bin\\lldb-vscode.exe",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "C/C++: clang++.exe build active file"
        }
    ]
}

When I press F5, I have this in terminal:

PS F:\Projects\Console Apps\testbuild>  & 'c:\Users\daniil\.vscode\extensions\ms-vscode.cpptools-1.7.1\debugAdapters\bin\WindowsDebugLauncher.exe' '--stdin=Microsoft-MIEngine-In-4pf1un21.l04' '--stdout=Microsoft-MIEngine-Out-tpjfi4ip.jse' '--stderr=Microsoft-MIEngine-Error-2nkku53m.1iw' '--pid=Microsoft-MIEngine-Pid-xscepzdp.k00' '--dbgExe=F:\Programs\LLVM\bin\lldb-vscode.exe' '--interpreter=mi'

But I don't have any output of my program, step over/into/out buttons is greyed out and breakpoints are not working.

Upvotes: 7

Views: 30689

Answers (1)

Daniil Andreev
Daniil Andreev

Reputation: 247

In launch.json I had to write "lldb", not "cppdbg". Now it works.

Upvotes: 15

Related Questions