microsoft / microsoft/vscode-cpptools
Debugging doesn't work with Clang 11 on Windows
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 6.2k
- Forks
- 1.7k
- Avg merge
- 14h 46m
- Merged PRs (30d)
- 61
Description
Type: Debugger
Describe the bug
- OS and Version: Windows_NT x64 10.0.19042
- VS Code Version: 1.51.1 (also tried with Insiders, the issue still occurs)
- C/C++ Extension Version: 1.1.2
- Other extensions you installed (and if the issue persists after disabling them): When disabling all extensions except the C/C++ extension, the issue still occurs.
- A clear and concise description of what the bug is: Debugging doesn't work with Clang on Windows due to the file
lldb-mi.exebeing missing.
To Reproduce
Please include a code sample and launch.json configuration.
Steps to reproduce the behavior:
- Install LLVM 11.0.0
- Create a new workspace folder
- Create the following
test.cpp:
#include <iostream>
int main()
{
std::cout << "Hello, World!\n";
}
- Create the following
tasks.json:
{
"version": "2.0.0",
"tasks": [
{
"type": "cppbuild",
"label": "Build for debugging",
"command": "C:/Program Files/LLVM/bin/clang++.exe",
"args": [
"${workspaceFolder}/test.cpp",
"-o",
"${workspaceFolder}/test.exe",
"-g"
],
"options": {
"cwd": "C:/Program Files/LLVM/bin"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Build for debugging with Clang++"
}
]
}
- Press Ctrl+Shift+B to run the build task. The program compiles successfully. Typing
testin the terminal prints out "Hello, World!". - Press F5, choose "C++ (GDB/LLDB)", and then
clang. The message "Unable to start debugging. The value of miDebuggerPath is invalid" will be displayed.
The launch.json file that was created by default is:
{
"version": "0.2.0",
"configurations": [
{
"name": "clang++.exe - Build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "lldb",
"miDebuggerPath": "\\usr\\bin\\lldb-mi.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "Build for debugging"
}
]
}
First of all, the default miDebuggerPath isn't even a Windows path, since /usr/bin doesn't exist on Windows. More importantly, even in the correct folder, which is C:\Program Files\LLVM\bin, the file lldb-mi.exe itself doesn't exist.
I looked it up and apparently lldb-mi has been removed from recent versions of LLVM for some reason. Obviously, I don't want to downgrade to an older version of Clang just so I can use VS Code with it.
Curiously, in C:\Program Files\LLVM\bin, there is a file named lldb-vscode.exe. However, after changing miDebuggerPath to C:/Program Files/LLVM/bin/lldb-vscode.exe and pressing F5, the debugger starts but nothing happens in the terminal - the program just freezes. Typing lldb-vscode in the terminal doesn't do anything either - it just exits without printing any output to the terminal. So I don't know what that file is actually supposed to do, but it doesn't seem to solve the problem of debugging in VS Code.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the Windows LLVM 11 setup using the generated launch.json and tasks.json, then trace how the clang configuration resolves miDebuggerPath. Compare the missing lldb-mi.exe with the available lldb-vscode.exe and verify the result by launching the sample test.cpp under the debugger. Done means the extension can start a working debugging session with Clang 11 on Windows.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, vscode
- Domain
- developer-experience, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100