Debugging programs with LLDB under Visual Studio

This tutorial shows how to configure VisualGDB to use the LLDB debugger instead of gdb to debug your programs.
Before you begin, install VisualGDB 5.1 or later.

  1. Start Visual Studio and open the VisualGDB MinGW/Cygwin Project Wizard:01-prjname
  2. Proceed with the default settings on the first page (Create new project -> Application):02-app
  3. On the next page select the toolchain you want to use. VisualGDB comes with a pre-built lldb debugger, so the steps described here will work on any local toolchain, as long as lldb can debug the program it produces:03-mingw
  4. Press “Finish” to generate your project. Build it with Ctrl-Shift-B:04-build
  5. If you start debugging by pressing F5 now, VisualGDB will launch the default GDB binary that comes with the toolchain. To use lldb instead, open VisualGDB Project Properties, go to the Debug Settings page and select “Use LLDB shipped with VisualGDB”:05-uselldb
  6. Then set a breakpoint in the main source file and press F5 to start debugging. VisualGDB will launch the debugging session:06-debugNote that LLDB won’t accept many of the gdb-specific commands and VisualGDB will automatically try known workarounds. The error messages in the LLDB Session window will indicate commands, but it should not interfere with most of the debugging functions.
  7. You can run LLDB-specific commands in the LLDB Session window directly. E.g. you can run “thread backtrace all” to view the backtrace of all the threads: 07-lldbout

Note that if you are using a cross-toolchain to deploy your program to a remote machine and debug it with gdbserver, LLDB may have compatibility issues with it. In that case we recommend installing lldb on that Linux machine directly and configuring VisualGDB to debug with it. As long as the binary name is called lldb-mi, VisualGDB will automatically adjust the command-line arguments so that LLDB can start correctly.