emacs-lsp / lsp-mode

Emacs client/library for the Language Server Protocol
https://emacs-lsp.github.io/lsp-mode
GNU General Public License v3.0
4.79k stars 885 forks source link

lsp-rust-analyzer-debug doesn't work with lldb #2928

Open holyfight6 opened 3 years ago

holyfight6 commented 3 years ago

Thank you for the bug report

Bug description

I don't have gdb installed on my machine, when I try to use lsp-rust-analyzer-debug or the debug lens, the following error occurred: Warning (emacs): Initialize request failed: Unable to start debugging. Launch options string provided by the project system is invalid. Unable to determine path to debugger. Please specify the "MIDebuggerPath" option. After modified the source code to: (list :type "cppdbg" :request "launch" :name label :args executable-args :cwd workspace-root? :sourceLanguages ["rust"] :MIMode "lldb" :MIDebuggerPath "/usr/bin/lldb" :program), lldb will exit with error error: unknown option: --interpreter=mi error: unknown option: --tty=/dev/pts/0 Use 'lldb --help' for a complete list of options.. And after I installed gdb without setting MIMode or MIDebuggerPath, these error have gone.

Steps to reproduce

M-x lsp-rust-analyzer-debug or click the debug lens in any rust project without gdb installed.

Expected behavior

The lsp-rust-analyzer-debug should output some error when default debugger isn't installed, it should also support lldb, and there should be a way to set the MIMode and MIDebuggerPath options.

Which Language Server did you use?

rust-analyzer

OS

Linux

Error callstack

No response

Anything else?

In the rust-analyzer vscode extension, I found that it support both { "vadimcn.vscode-lldb": getLldbDebugConfig, "ms-vscode.cpptools": getCppvsDebugConfig }; as available debug engines, it will be great if we can choose from these engines too.

jming422 commented 2 years ago

Any updates on this issue? I just started experiencing the same bug.

I recently started using an M1 Mac, only to discover that gdb cannot yet be compiled on Apple Silicon, so I decided to give lldb a try. While I can use both regular lldb and rust-lldb to debug my Rust program from the terminal just fine, using M-x lsp-rust-analyzer-debug yields the exact same results described above.

I also tried to use a custom debug template setting :MIMode "lldb" and :miDebuggerPath appropriately, which got me the same results above with lldb exiting with error: unknown option: --interpreter=mi.

zeronone commented 1 year ago

I was able to make it work using the following (for doom emacs). I had run dap-cpptools-setup beforehand.

  (setq lsp-rust-analyzer-debug-lens-extra-dap-args
        `(:MIMode "lldb"
          :miDebuggerPath ,(f-join doom-local-dir "etc/dap-extension/vscode/cpptools/extension/debugAdapters/lldb-mi/bin/lldb-mi")
          :stopAtEntry t
          :externalConsole
          :json-false))
yyoncho commented 1 year ago

So it sounds more like something to document, what do you think @zeronone?

zeronone commented 1 year ago

@yyoncho Yep agree!

Ghasak commented 1 year ago

Although a bit old thread, but I have solved this issue finally on my M1 MacBook following the steps here

  1. Locate the lldb-mi in your system, I used the one already installed which comes with vscode in the following path.
~/.vscode/extensions/ms-vscode.cpptools-1.15.4-darwin-arm64/debugAdapters/lldb-mi/bin/lldb-mi
  1. Make it executable using chmod +x /bin/lldb-mi in the path above
  2. Source it in your zshrc using
export PATH="$PATH:$HOME/.vscode/extensions/ms-vscode.cpptools-1.15.4-darwin-arm64/debugAdapters/lldb-mi/bin"
  1. Now you can see in the terminal that you already have lldb-mi working.
╰─ lldb-mi --version
Version: GNU gdb (GDB) 7.4
(This is a MI stub on top of LLDB and not GDB)
All rights reserved.
  1. just ensure that you already have installed dap-mode and when you start debugging you can create a template file as
    (dap-register-debug-template
    "LLDB::Run"
    (list :type "lldb-mi"
        :request "launch"
        :name "LLDB::Run"
        :target nil
        :cwd nil
        ))