I want to launch my debug adapters from an external terminal because I'm sick and tired of always adapting the launch.json or dap-configurations when I could just alter the command directly from the terminal. Right now I only care about rust, cpp and python, so I tried to fiddle around with the attach option and server-type adapters.
For python this seems to work quite well, I can just call debugpy with a port to listen on
python -m debugpy --listen 127.0.0.1:5678 --wait-for-client myapp.py
And then connect to debugpy using my adapter configuration
dap.adapters.python = {
type = 'server',
port = 5678,
host = 127.0.0.1,
options = {
source_filetype = 'python',
},
}
dap.configurations.python = {
{
type = 'python', -- the type here established the link to the adapter definition: `dap.adapters.python`
request = 'attach',
name = "Attach to debugpy (already running)",
justMyCode = false,
}
}
I tried the same for rust/cpp with lldb-server.
Start the app using
lldb-server g :1234 ./build/Debug/myapp.exe ../sbeer_meteocache_config.ini
Then I tried to attach to it and while I see lldb-server reporting Connection established it doesn't stop on my breakpoint! I tried to check dap.log in ~/.cache/nvim but it didn't seem to emit anything particularly useful. From nvim I get this notif:
Debug adapter didn't respond. Either the adapter is slow (then wait and ignore this) or there is a problem with y our adapter or lldb_server configuration. Check the logs for errors (:help dap.set_log_level)
Here's my nvim-dap config for lldb-server:
-- Rust & C++
dap.adapters.lldb_server = {
type = 'server',
host = '127.0.0.1',
port = 1234,
}
local lldb_server_config = {
{
name = "Attach to lldb_server (already running)",
type = "lldb_server",
request = "attach",
stopOnEntry = true,
},
}
dap.configurations.c = lldb_server_config
dap.configurations.cpp = lldb_server_config
dap.configurations.rust = lldb_server_config
ChatGPT mentions that the source mapping is not clear to lldb_server like this and wants me to also specify a program field for the configuration, but my exact point of managing the configurations this way is that I don't want to do that. Also this makes no sense to me since the source mapping should be rather clear as I provide the program to start to lldb_server directly?
What am I missing?