Closed MikaelElkiaer closed 2 years ago
Based on the error message I'd guess that netcoredbg requires a property named processId
, not pid
.
So maybe this works?
dap.configurations.cs = {
{
type = "netcoredbg",
name = "launch - netcoredbg",
request = "attach",
processId = function()
local pgrep = vim.fn.system("pgrep -f 'dotnet run --project Beehive'")
return tonumber(pgrep)
end,
preLaunchTask = function()
Term = vim.fn.termopen("dotnet run --project Beehive")
end
},
}
That changed nothing.
I actually though it might have something to do with one of these: https://github.com/mfussenegger/nvim-dap/blob/4e8bb7ca12dc8ca6f7a500cbb4ecea185665c7f1/lua/dap/session.lua#L96 https://github.com/mfussenegger/nvim-dap/blob/4e8bb7ca12dc8ca6f7a500cbb4ecea185665c7f1/lua/dap/session.lua#L142
It seems like there is some dynamic link between the dap configuration and the adapter that I don't understand. netcoredbg
has a paramater --attach
where I can supply the process ID. How does this map to the config?
Are you sure that pgrep
is returning something?
You can check the log to see what's sent to the adapter (See :h dap.set_log_level
)
The error message can't parse: [json.exception.out_of_range.403] key 'processId' not found
is definitely coming from the adapter.
The other two processId
places you linked are unrelated.
Ok, you were right in setting the processId. Got further by dropping my preLaunchTask and instead manually starting the program, and then only using the processId function to get the pid. However, this just lead me to a new issue: The breakpoint is pending and will be resolved when debugging starts.
I will dig deeper another day. Here are some fun debug output though, as I am seeing a lot of these and it is probably a symptom of whatever is wrong:
[ DEBUG ] 2021-11-23T00:03:21Z+0100 ] ...nvim/site/pack/packer/start/nvim-dap/lua/dap/session.lua:536 ] {
body = {
module = {
id = "e6de5815-2070-4ff5-948f-2fde01972daa",
name = "System.Private.CoreLib.dll",
path = "/opt/dotnet/shared/Microsoft.NETCore.App/3.1.18/System.Private.CoreLib.dll",
symbolStatus = "Symbols not found."
},
reason = "new"
},
event = "module",
seq = 8,
type = "event"
}
Are you using a debug build that has the debug symbols?
Are you using a debug build that has the debug symbols?
I am fairly sure that I am. I can get it to work if I do a configuration with a request type of 'launch' instead of 'attach'. Not at all sure what I am missing for attaching properly.
I finally got further.
Seems that starting a dotnet application with dotnet run --project Beehive
did not work properly.
But start it with dotnet Beehive/bin/Debug/netcoreapp3.1/Beehive.dll
did.
Leaving this comment for others to find, and then I will close it.
Edit: Seems like I was attaching to the wrong process - the dotnet run, instead of its subprocess which was the actual program.
Debug adapter definition and debug configuration
Debug adapter version
No response
Steps to Reproduce
I am trying to run the above config in a simple .NET Core project: https://github.com/MikaelElkiaer/Beehive
Using the config above I try to start debugging via
lua require'dap'.continue()
.Expected Result
No error like the one in title.
Actual Result
I see
Error on attach: can't parse: [json.exception.out_of_range.403] key 'processId' not found
.I get the same error if I try an even simpler config with
pid = require('dap.utils').pick_process
and without the preLaunchTask.I have little to no idea how to provide more info, but if you could point me in the right direction I'd be happy to provide more info.