debugging with lldb clang does not work on WSL with VSCode

Viewed 380

I am using clang 13 for compiling and lldb 13 for debugging on WSL (kali linux) using Visual Studio Code.

I found that the mi debugger - lldb-mi - isn't available on apt-get, so I had to compile it from source. I looked into issue #5415 on VS Code cpptools and the answer suggested there to download the latest clang, lldb versions and compile lldb-mi from source.

After following all the steps, lldb-mi still does not work in VSCode. As a result I have gone back to using gdb as the debugger with clang still for building.

However, I don't understand the problem here. I compiled and linked everything without errors but when run, the debugger simply outputs nothing, even with simplest hello world example. Why is this happening?

Details:

Here is the script I used to compile lldb-mi with its dependencies:

sudo apt install clang-13 llvm-13-dev liblldb-13-dev
sudo ln -f -s /usr/bin/clang-13 /usr/bin/clang
sudo ln -f -s /usr/bin/clang++-13 /usr/bin/clang++
sudo ln -f -s /usr/bin/lldb-13 /usr/bin/lldb
sudo ln -f -s /usr/bin/lldb-server-13 /usr/bin/lldb-server-13.0.0
sudo ln -f -s /usr/bin/lldb-server-13 /usr/bin/lldb-server-13.0.1
git clone https://github.com/lldb-tools/lldb-mi.git
cd lldb-mi
rm ./src/lldb-mi
cmake .
cmake --build .
sudo cp src/lldb-mi /usr/bin/

Here is my launch.json:

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