2

I am using Vagrant to launch a VM of Ubuntu and compile my C++ code in Linux. The Linux version is 5.8.0-59-generic.

The makefile build command is exec: main.o other_lib.o ${CXX} ${CXX_FLAGS} -lc++abi bin/main.o bin/other_lib.o -o bin/exec -g -fstandalone-debug. After running make exec and ./bin/exec, the program can successfully run. However the debugging part is bugged. This is the launch.json config for LLDB:

{
    "name": "debug exec lldb",
    "type": "cppdbg",
    "request": "launch",
    "program": "/home/vagrant/bin/exec",
    "stopAtEntry": true,
    "cwd": "${workspaceFolder}",
    "environment": [],
    "externalConsole": false,
    "MIMode": "lldb",
    "miDebuggerPath": "/usr/bin/lldb-mi",
    "preLaunchTask": "debug exec",
    "setupCommands": [
        {
            "description": "Enable pretty-printing for gdb",
            "text": "-enable-pretty-printing",
            "ignoreFailures": true
        },
        {
            "text": "settings set target.run-args ${input:lldb-debugger-args}"
        }
    ]
}

The first time I ran this debugging config using F5, vscode prompted miDebuggerPath invalid. I found that there was no /usr/bin/lldb-mi executable file in the system, so I ran sudo apt-get install lldb. This is where things get weird:

  1. I tried to run the debugging process via VSCode, and there is no miDebuggerPath invalid error. However, after hitting F5, the terminal will output [1] + Done(127) "/usr/bin/lldb-mi" --interpreter=mi --tty=${DbgTerm} 0<"/tmp/Microsoft-MIEngine-In-ly4ql3cx.s1b" 1>"/tmp/Microsoft-MIEngine-Out-gfkz1mbe.fex" and print a new prompt that listens for the next command. The hovering debug toolbar of VSCode appeared, but there is a constantly running progress bar (see below). The whole debug process is stuck. enter image description here

  2. Using ls in /usr/bin/, the lldb-mi file appears red. Using ls -l /usr/bin/lldb-mi indicates that it is a broken link, pointing to another broken link lldb-mi-11: enter image description here

  3. /usr/bin/lldb is an existing executable. However lldb-mi seems to be a "machine interface" of lldb, and I'm not sure if using lldb as the miDebugger can work.

How can I fix this problem (finding a substitution of lldb-mi or somehow fixing the broken link problem of lldb-mi)?

Power_tile
  • 578
  • 1
  • 6
  • 18

1 Answers1

2

lldb-mi used to be a part of the lldb project, but it languished for quite a while without a maintainer, and eventually it was broken out into a separate package on GitHub in the hopes that as a stand-alone thing it would get more support from the people who used it. There might be an apt-get for it as a standalone package? Not sure about that. But it's still available on GitHub, so if all else fails you can get and build it yourself. The source code is here: https://github.com/lldb-tools/lldb-mi, which has a README on how to build it.

But if you are primarily interested in using VSCode, you might try lldb-vscode instead. Rather than using the MI interface (which is pretty long in the tooth at this point), it uses MicroSoft's own debugging protocol, and is currently in active development. The lldb-vscode binary does get built as part of the regular lldb build.

Jim Ingham
  • 25,260
  • 2
  • 55
  • 63
  • I transferred from using VirtualBox to using Docker as the host of Vagrant and it somehow worked Thanks though – Power_tile Sep 09 '21 at 04:08