Additional to a configuration where netcoredbg
is started I want to have a configuration where I attached dap
to the running debug server. For that I added a coreclrattach
adapter and a corresponding attach
configuration:
local dap, dapui = require("dap"), require("dapui")
dap.adapters.coreclr = {
type = 'executable',
command = '/usr/local/netcoredbg',
args = { '--interpreter=vscode' },
}
dap.adapters.coreclrattach = {
type = 'server',
port = 4711,
}
dap.configurations.cs = {
{
type = "coreclr",
name = "launch - netcoredbg",
request = "launch",
program = function()
return vim.fn.input('Path to dll', vim.fn.getcwd() .. '/bin/Debug/', 'file')
end,
},
{
type = "coreclrattach",
name = "attach - netcoredbg",
request = "attach",
pid = require('dap.utils').pick_process,
args = {},
},
}
In one shell session I start debugging with
/usr/local/netcoredbg --interpreter=vscode --server -- dotnet run -c Debug
and in the other session I start debugging with the attach
configuration
Configuration:
1: launch - netcoredbg
2: attach - netcoredbg
Type number and <Enter> or click with the mouse (q or empty cancels): 2
with selecting the process to be debugged.
However attaching seems not to work and this error is raised:
Error on attach: can't parse: [json.exception.out_of_range.403] key 'processId' not found
log file log.txt
imho bears no additional information:
9827.176 I/NETCOREDBG(P60708, T60708): main.cpp: main(431) > Netcoredbg started
9853.273 I/NETCOREDBG(P60708, T60708): main.cpp: instantiate_protocol(113) > Creating protocol VSCodeProtocol
9853.274 I/NETCOREDBG(P60708, T60708): main.cpp: main(475) > pidDebugee 0
9853.274 I/NETCOREDBG(P60708, T60832): ioredirect.cpp: worker(164) > worker started
9853.275 E/NETCOREDBG(P60708, T60836): vscodeprotocol.cpp: HandleCommandJSON(855) > JSON error: [json.exception.out_of_range.403] key 'processId' not found
9853.280 I/NETCOREDBG(P60708, T60708): vscodeprotocol.cpp: ReadData(872) > EOF
What I also tried
In another post I found, that processId
is used instead of pid
- which I took from this cookbook.
Hence I adapted my configuration to
{
type = "coreclrattach",
name = "attach - netcoredbg",
request = "attach",
processId = require('dap.utils').pick_process,
args = {},
},
repeated to start the debugging session, but got
Failed command 'configurationDone' : 0x80070057
Is there a way to achieve this?
raised also an issue with
netcoredbg
: https://github.com/Samsung/netcoredbg/issues/139