mfussenegger / nvim-dap

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

need help: GDB on Windows (`\r\n` problem) #1227

Closed KevinNitroG closed 1 month ago

KevinNitroG commented 1 month ago

Debug adapter definition and debug configuration

local dap = require "dap"
dap.adapters.gdb = {
  type = "executable",
  command = "gdb",
  args = { "-i", "dap" },
}

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

Debug adapter version

sorry idk but my GDB version is 14.1 (installed with scoop)

Steps to Reproduce

  1. Open cpp file
  2. Start the dap

Expected Result

Run normally, like, debugging my beautiful cpp code

Actual Result

image

Log via :DapShowLog

[ ERROR ] 2024-05-27T18:46:20Z+0700 ] .../nvim-alexis12119-data/lazy/nvim-dap/lua/dap/session.lua:1455 ]    "stderr"    {
  args = { "-i", "dap" },
  command = "gdb",
  type = "executable"
}   "Interpreter `dap' unrecognized\r\n"
[ INFO ] 2024-05-27T18:46:20Z+0700 ] .../nvim-alexis12119-data/lazy/nvim-dap/lua/dap/session.lua:1428 ] "Process closed"    23472

[!NOTE]

My NVIM_APPNAME = nvim-alexis2119

Btw I run with the .cpp file. IDK if I need to run the compiled file (.exe) or not.

mfussenegger commented 1 month ago

Interpreter `dap' unrecognized

This means gdb is either outdated or packaged without dap support.

You can also see that by running gdb -i dap in a shell

Btw I run with the .cpp file. IDK if I need to run the compiled file (.exe) or not.

program needs to point to the executable, including debug symbols but you're not even getting that far.

luftaquila commented 5 days ago

Rebuild gdb with --with-python=/path/to/python fixed the issue. Thank you for the hint.