Debug Adapter Protocol

The Debug Adapter Protocol (DAP) defines a generic protocol for editors to talk to a debugger. Popular editors with DAP support include Visual Studio Code, Sublime Text, (Neo)vim and Emacs.

If you’re familiar with the Language Server Protocol (LSP) you can think of DAP like LSP, but for debugging.

Implementations of the debug adapter protocol generally come in two forms:

  • An extension tailored to a specific editor.
  • A standalone DAP server that can be used with any editor that supports the protocol.

LLDB supports both:

  • LLDB DAP is the Visual Studio Code extension available on the Marketplace.
  • lldb-dap (formerly lldb-vscode) is the DAP server.

The Visual Studio Code extension uses lldb-dap under the hood.

Configuration

Most editors will require two kinds of configuration:

  • Configuring the DAP server: For your editor to talk to the DAP server, it needs to know where to find it. This generally requires either specifying the path to lldb-dap or having it available in PATH. This is also true for the LLDB VS Code extension as the extension does not contain the actual lldb-dap server binary.

  • Configuring launch/attach: To debug an application you need to either launch it under the debugger or attach to existing project. This is generally tied to your project and editor. For example, VS Code uses a launch configuration file.

Installation

Like LLDB itself, lldb-dap is part of the LLVM project, and can be installed the same way you would install lldb:

  • macOS: brew install llvm
  • Ubuntu: apt install lldb
  • Arch Linux: pacman -S lldb

PS: Older versions of lldb-dap were called lldb-vscode. Besides the name and lldb-vscode being older, the two binaries are interchangeable.