Closed PrettRett closed 4 months ago
The server
type is for debug adapters that communicate via TCP with the client(=nvim-dap) . That's not the case with gdb -i dap
, which uses stdio.
You need to use the executable
type for gdb itself:
dap.adapters.gdb = {
type = "executable",
command = "gdb",
args = { "-i", "dap" }
}
And then an attach configuration, to tell that gdb should connect to the gdbserver:
dap.configurations.c = {
{
name = "gdbserver: attach",
type = "gdb",
request = "attach",
target = "localhost:1234",
cwd = '${workspaceFolder}',
},
}
So the communication is:
┌──────────┐ DAP ┌─────┐ ┌──────────┐ ┌───────────────┐
│ nvim-dap │────►│ gdb │───────►│ gdbserver│──────►│your-executable│
└──────────┘ └─────┘ └──────────┘ └───────────────┘
Thank you!!
Debug adapter definition and debug configuration
Installed the plugin using lazyvim, from what I've seen It should be the latest release.
The configuration is: `dap.adapters.gdb = { type="server", port="1234", -- type="executable", command = "gdb", args = {"-i", "dap"}, initialize_timeout_sec=30, }
dap.configurations.c = { { name = "Attacher", type = "gdb", request = "launch", cwd = "${workspaceFolder}", program = function () return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') end, }, }`
I've tested commenting type="server" and port="1234" and uncommenting the line type="executable", and I can successfully run the debug session, so at least I know the general configuration and version of GDB is working.
I've tested connecting to the gdbserver through the terminal and debugging using the gdb command "gdb --eval-command='target remote localhost:1234'" and it successfully connect to the gdbserver and I can debug, so I know that the server is running properly. The server is executed with the command: "gdbserver localhost:1234 /path/to/executable"
When I try to start the debug session, the meesage it appears is:![image](https://github.com/mfussenegger/nvim-dap/assets/27734127/e5daf167-1a30-4c51-984a-1c4568b0c827)
And the debug information for the request call is:![image](https://github.com/mfussenegger/nvim-dap/assets/27734127/d8de3e92-a688-4e94-a20d-3407c0269e72)
Debug adapter version
No response
Steps to Reproduce
Expected Result
Starts the debug session, or it responds with an error message
Actual Result
The Debug adapter didn't respond message appears and every command we attempt to the dap this message appears:![image](https://github.com/mfussenegger/nvim-dap/assets/27734127/d0b9c68f-a8e4-4655-a037-54868840d299)
The message seen from the gdbserver are:![image](https://github.com/mfussenegger/nvim-dap/assets/27734127/9cb14eb5-6326-429b-85fc-ad93da70817a)