c++visual-studio-codelldb

"CString not terminated" when using LLDB-MI with Visual Studio Code on Windows ARM64


I recently switched to an ARM64 machine with the Snapdragon X Elite on Windows and I am trying to set up Visual Studio Code. Since MinGW-w64 with gcc and gdb isn’t available for ARM64, I’m using LLVM-Mingw (version 18.1.18).(I also tried MSVC but I just cannot get used to it).

The problem arises when I try to start lldb-mi from within VS Code. I encounter the following error (full output at the bottom of the question):

[Error] MI parsing error: CString not terminated: ""C:\\Users\\User_\\Documents\\Development\\TestProject"
[Error] MI parsing error: Result expected: "path="C:\\Users\\User_\\Documents\\Development\\TestProject"
[Error] MI parsing error: trailing chars: ""C:\\Users\\User_\\Documents\\Development\\TestProject"

The Launch Configuration (launch.json):

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(lldb) Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "${command:cmake.launchTargetPath}",
            "showDisplayString": true,
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "logging": {
                "engineLogging": true
            },
            "externalConsole": true,
            "MIMode": "lldb"
        }
    ]
}

Debugging using only lldb directly via CLI works fine. I also tried the vs code extension CodeLLDB but unfortunately that one is not available on ARM64 yet.

For anyone who would like to reproduce the problem. The code is a simple Hello World program in C++ and CMake used:

cmake_minimum_required(VERSION 3.27)
project(TestProject)
set(CMAKE_BUILD_TYPE Debug)

add_executable(testProject ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp)

target_link_libraries(  testProject)

Environment:

Any idea what I am missing?

Update based on Electro Organic's suggestion:

I updated the launch.json with absolute path. I also move it into a path without an underscore, same issue persist. I also tried forward and double backwards slash, no change. I checked with notepad++ for any hidden symbols but couldn't find one either.

New launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(lldb) Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "C:\\Users\\Public\\TestProject\\build\\testProject.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "C:\\Users\\Public\\TestProject",
            "logging": {
                "engineLogging": true
            },
            "externalConsole": false,
            "MIMode": "lldb",
            "miDebuggerPath": "C:\\BuildTools\\llvm-mingw-20240619-ucrt-aarch64\\bin\\lldb-mi.exe"
        }
    ]
}

Full Debug output:

1: (80) LaunchOptions{"name":"(lldb) Launch","type":"cppdbg","request":"launch","program":"C:\\Users\\User_\\Documents\\Development\\TestProject\\build\\testProject.exe","showDisplayString":true,"args":[],"stopAtEntry":false,"cwd":"C:\\Users\\User_\\Documents\\Development\\TestProject","logging":{"engineLogging":true},"externalConsole":true,"MIMode":"lldb","__configurationTarget":6,"__sessionId":"b05ff7d2-9d7c-4e88-96b2-79ee5c80f421","miDebuggerPath":null}
1: (131) Starting: "C:\BuildTools\llvm-mingw-20240619-ucrt-aarch64\bin\lldb-mi.exe" --interpreter=mi
1: (201) DebuggerPid=21952
1: (806) ->(gdb)
1: (816) <-1001-gdb-set auto-solib-add on
1: (816) ->1001^done
1: (817) ->(gdb)
1: (819) 1001: elapsed time 3
1: (820) <-1002-gdb-set solib-search-path "C:\\Users\\User_\\Documents\\Development\\TestProject\\build;"
1: (821) ->1002^done
1: (821) 1002: elapsed time 1
1: (821) <-1003-environment-cd C:\\Users\\User_\\Documents\\Development\\TestProject
1: (821) ->(gdb)
1: (821) ->1003^done,path="C:\\Users\\User_\\Documents\\Development\\TestProject
1: (821) ->"
1: (821) ->(gdb)
[Error] 1: (825) MI parsing error: CString not terminated: ""C:\\Users\\User_\\Documents\\Development\\TestProject"
[Error] 1: (825) MI parsing error: Result expected: "path="C:\\Users\\User_\\Documents\\Development\\TestProject"
[Error] 1: (825) MI parsing error: trailing chars: ""C:\\Users\\User_\\Documents\\Development\\TestProject"
[Error] 1: (894) EXCEPTION:
[Error] 1: (895) EXCEPTION:    at MICore.MIResults.ParseResultList(Span listStr, ResultClass resultClass)
[Error] 1: (895) EXCEPTION:    at MICore.MIResults.ParseCommandOutput(String output)
[Error] 1: (895) EXCEPTION:    at MICore.Debugger.ProcessStdOutLine(String line)
[Error] 1: (895) EXCEPTION:    at Microsoft.MIDebugEngine.DebuggedProcess.<>c__DisplayClass96_0.<ScheduleStdOutProcessing>b__0()
[Error] 1: (895) EXCEPTION:    at Microsoft.MIDebugEngine.WorkerThread.ThreadFunc()
1: (897) Send Event AD7MessageEvent
[Error] 1: (898) MI parsing error: CString not terminated: """

Solution

  • I kind of solved the problem, while I was unable to find a solution to the original problem, I found out about lldb-dap (previously lldb-vscode) while researching. lldb-dap also allows to debug using vs code but via a different interface. That does the trick for me to be able to debug using vs code.

    I needed to install the lldb-dap extension and the following is my launch.json:

        {
        "version": "0.2.0",
        "configurations": [
            {
                "name": "(lldb) Launch",
                "type": "lldb-dap",
                "request": "launch",
                "program": "${command:cmake.launchTargetPath}",
                "args": [],
                "cwd": "${workspaceFolder}",
    
            }
          ]
       }
    

    Thanks for everyone who tried to help.