mfussenegger / nvim-dap

Debug Adapter Protocol client implementation for Neovim
GNU General Public License v3.0
5.17k stars 180 forks source link

nvim-dap does not work with apple silicon and lldb #1046

Closed JayaAnim closed 9 months ago

JayaAnim commented 9 months ago

Debug adapter definition and debug configuration

local dap = require('dap')
dap.adapters.lldb = {
  type = 'executable',
  command = '/usr/bin/lldb', -- adjust as needed, must be absolute path
  name = 'lldb'
}

dap.configurations.c = {
  {
    name = 'Launch',
    type = 'lldb',
    request = 'launch',
    program = vim.fn.getcwd() .. '/bin/exec',
    cwd = '${workspaceFolder}',
    stopOnEntry = false,
    args = {},
  },
}

vim.keymap.set('n', '<Leader>dbg', function() require('dap').continue() end)
vim.keymap.set('n', '<F10>', function() require('dap').step_over() end)
vim.keymap.set('n', '<F11>', function() require('dap').step_into() end)
vim.keymap.set('n', '<F12>', function() require('dap').step_out() end)
vim.keymap.set('n', '<Leader>b', function() require('dap').toggle_breakpoint() end)
vim.keymap.set('n', '<Leader>B', function() require('dap').set_breakpoint() end)
vim.keymap.set('n', '<Leader>lp', function() require('dap').set_breakpoint(nil, nil, vim.fn.input('Log point message: ')) end)
vim.keymap.set('n', '<Leader>dr', function() require('dap').repl.open() end)
vim.keymap.set('n', '<Leader>dl', function() require('dap').run_last() end)
vim.keymap.set({'n', 'v'}, '<Leader>dh', function()
  require('dap.ui.widgets').hover()
end)
vim.keymap.set({'n', 'v'}, '<Leader>dp', function()
  require('dap.ui.widgets').preview()
end)
vim.keymap.set('n', '<Leader>df', function()
  local widgets = require('dap.ui.widgets')
  widgets.centered_float(widgets.frames)
end)
vim.keymap.set('n', '<Leader>ds', function()
  local widgets = require('dap.ui.widgets')
  widgets.centered_float(widgets.scopes)
end)

Debug adapter version

3.4.5

Steps to Reproduce

  1. Install nvim-dap with packer
  2. Utilize this configuration
  3. Compile a C project
  4. Attempt to run continue() function

Expected Result

Nvim dap should properly configure and run

Actual Result

Nvim dap says there is either the server is slow or there is a configuration error with lldb. I have tried every, single, adapater. None work.

JayaAnim commented 9 months ago

Here is the dap.log file:

[ INFO ] 2023-09-30T22:08:28Z-0500 ] ...nvim/site/pack/packer/start/nvim-dap/lua/dap/session.lua:744 ] "Telemetry" "VS/Diagnostics/Debugger/Launch" [ ERROR ] 2023-09-30T22:24:01Z-0500 ] ...nvim/site/pack/packer/start/nvim-dap/lua/dap/session.lua:1431 ] "stderr" { command = "/usr/bin/lldb", name = "lldb", type = "executable" } "error: 'Content-Length' is not a valid command.\n" [ ERROR ] 2023-09-30T22:24:02Z-0500 ] ...nvim/site/pack/packer/start/nvim-dap/lua/dap/session.lua:1431 ] "stderr" { command = "/usr/bin/lldb", name = "lldb", type = "executable" } "error: '{\"arguments\":{\"supportsRunInTerminalRequest\":true,\"supportsVariableType\":true,\"supportsProgressReporting\":true,\"supportsStartDebuggingRequest\":true,\"locale\":\"en_US.UTF-8\",\"clientId\":\"neo vim\",\"clientname\":\"neovim\",\"adapterID\":\"nvim-dap\",\"pathFormat\":\"path\",\"columnsStartAt1\":true,\"linesStartAt1\":true},\"command\":\"initialize\",\"seq\":0,\"type\":\"request\"}Content-Length:' is not a vali d command.\n"

[ ERROR ] 2023-09-30T22:24:32Z-0500 ] ...nvim/site/pack/packer/start/nvim-dap/lua/dap/session.lua:1431 ] "stderr" { command = "/usr/bin/lldb", name = "lldb", type = "executable" } "error: 'Content-Length' is not a valid command.\n"

mfussenegger commented 9 months ago

The lldb executable doesn't speak the debug adapter protocol directly, you need to use an adapter like lldb-vscode. Please check the wiki: https://github.com/mfussenegger/nvim-dap/wiki/Debug-Adapter-installation