Using LLDB on Emacs (dap-mode & dap-lldb & lldb-vscode) for macOS


In previous post, I wrote about how to debug C/Objective-C with LLDB CLI.
This time I will try the operation from Emacs with dap-mode and dap-lldb.




The dap-lldb require lldb-vscodethat is developed by the LLVM project.

  1. Install lldb-vscode. Select plan the belows:
    • Plan A: Install LLDB VSCode extension that includelldb-vscode of the binary file in VSCode.
      • LLDB VSCode’s lldb is v9.0.0. Therefore lldb-vscode is old.
      • By the way, CodeLLDB that is similar VSCode extension. It doesn’t include lldb-vscode.
  2. Install dap-mode package that contain dap-lldb on Emacs.
  3. Add configuration for dap-mode in init.el.
  4. Add dap-register-debug-template.


(leaf dap-mode
  :ensure t
  (dap-mode 1)
  (dap-tooltip-mode 1)
  (dap-auto-configure-mode 1)
  (dap-ui-controls-mode 1)
  :require t dap-lldb
   ([f5] . dap-debug)
   ("M-d i" . dap-step-in)
   ("M-d o" . dap-step-out)
   ("M-d n" . dap-next)
   ("M-d g" . dap-continue)
   ("M-d t" . dap-breakpoint-toggle))
  (leaf dap-ui
    :ensure nil
    :require t
    (dap-ui-mode 1))
  (dap-auto-configure-features . '(sessions locals breakpoints expressions repl controls tooltip))
  (dap-lldb-debug-program . `(,(expand-file-name "~/.vscode/extensions/lanza.lldb-vscode-0.2.3/bin/darwin/bin/lldb-vscode"))))

dap debug template:

;; Eval Buffer with `M-x eval-buffer' to register the newly created template.

  (list :type "lldb-vscode"
        :cwd "/path/to/your/code/emacs"
        :request "launch"
        :args (list "-Q")
        :program "nextstep/"
        :name "LLDB::Run"))


$ ~/.vscode/extensions/lanza.lldb-vscode-0.2.3/bin/darwin/bin/lldb --version
lldb version 9.0.0 ( revision 364465)
  clang revision 364468
  llvm revision 364469

$ codesign -vv ~/.vscode/extensions/lanza.lldb-vscode-0.2.3/bin/darwin/bin/lldb 
/Users/hiroakit/.vscode/extensions/lanza.lldb-vscode-0.2.3/bin/darwin/bin/lldb: code object is not signed at all
In architecture: x86_64

$ codesign -vv ~/.vscode/extensions/lanza.lldb-vscode-0.2.3/bin/darwin/bin/lldb-vscode 
/Users/hiroakit/.vscode/extensions/lanza.lldb-vscode-0.2.3/bin/darwin/bin/lldb-vscode: code object is not signed at all
In architecture: x86_64

$ otool -L ~/.vscode/extensions/lanza.lldb-vscode-0.2.3/bin/darwin/bin/lldb-vscode 
	@rpath/liblldb.9.0.0svn.dylib (compatibility version 0.0.0, current version 9.0.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.250.1)
	/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.11)
	/usr/lib/libncurses.5.4.dylib (compatibility version 5.4.0, current version 5.4.0)
	/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 400.9.4)