mfussenegger / nvim-dap

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

lldb content length is not a valid argument #1357

Closed reiend closed 2 weeks ago

reiend commented 2 weeks ago

Debug adapter definition and debug configuration

dap.adapters.lldb = {
  type = 'executable',
  command = 'lldb',
  name = 'lldb',
}

Debug adapter version

No response

Steps to Reproduce

Run continue()

Expected Result

lldb will run

Actual Result

[ ERROR ] 2024-11-05T15:22:06Z+0800 ] ...ppData/Local/nvim-data/lazy/nvim-dap/lua/dap/session.lua:1513 ] "stderr" { command = "lldb", name = "lldb", type = "executable" } "error: 'Content-Length' is not a valid command.\r\n"

mfussenegger commented 2 weeks ago

If you want to use lldb you either have to use it via codelldb or lldb-dap See https://github.com/mfussenegger/nvim-dap/wiki/Debug-Adapter-installation

reiend commented 2 weeks ago

If you want to use lldb you either have to use it via codelldb or lldb-dap See https://github.com/mfussenegger/nvim-dap/wiki/Debug-Adapter-installation

Thanks. appreciate the help.

updated config

    dap.adapters["lldb-dap"] = {
      type = 'executable',
      command = 'lldb-dap', -- adjust as needed, must be absolute path
      name = 'lldb',
    }

    dap.configurations.cpp = {
      {
        name = 'lldb',
        type = 'lldb-dap',
        request = 'launch',
        program = function()
          return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
        end,
        cwd = '${workspaceFolder}',
        stopOnEntry = false,
        args = {},
      },
    }

Note:

if you are in windows and using llvm's lldb-dap make sure it is base in mingw for more info

if not (in my case msvc) most likely you will encounter "Debug adapter didn't respond" similar to this issue

i tried solutions like

   local myadapter = {
    type = 'executable',
    command = '...',
    options = {
      initialize_timeout_sec = 10,
    }

didn't work.

I tried the same thing with vscode with lldb-dap base in msvc it didn't work too. it only loads eternally.

but if you still insist on msvc route better change to codelldb it works like magic both nvim and vscode

config

   dap.adapters["codelldb"] = {
      type = "server",
      port = "${port}",
      executable = {
          command = "codelldb.cmd", -- adjust as needed, must be absolute path
          args = {"--port", "${port}"},
      },
    }

    dap.configurations.cpp = {
      {
        name = 'codelldb',
        type = 'codelldb',
        request = 'launch',
        program = function()
          return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
        end,
        cwd = '${workspaceFolder}',
        stopOnEntry = false,
        args = {},
      }
   }

lastly don't forget to build you project in debug in cmake or by adding flags -g -O0, more more info