除了启动netcoredbg
的配置之外,我还希望有一个将dap
连接到正在运行的调试服务器的配置。为此,我添加了一个coreclrattach
适配器和相应的attach
配置:
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 = {},
},
}
在一个shell会话中,我开始调试,
/usr/local/netcoredbg --interpreter=vscode --server -- dotnet run -c Debug
在另一个会话中,我开始使用attach
配置进行调试
Configuration:
1: launch - netcoredbg
2: attach - netcoredbg
Type number and <Enter> or click with the mouse (q or empty cancels): 2
选择要调试的进程。
然而,附加似乎不工作,并提出了这个错误:
Error on attach: can't parse: [json.exception.out_of_range.403] key 'processId' not found
日志文件log.txt
imho没有附加信息:
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
我也试过
在我发现的另一个post中,使用了processId
而不是pid
-这是我从这本食谱中获得的。
因此,我调整了我的配置,
{
type = "coreclrattach",
name = "attach - netcoredbg",
request = "attach",
processId = require('dap.utils').pick_process,
args = {},
},
重复启动调试会话,但得到
Failed command 'configurationDone' : 0x80070057
有没有办法做到这一点?
也提出了一个关于netcoredbg
的问题:https://github.com/Samsung/netcoredbg/issues/139
1条答案
按热度按时间vwkv1x7d1#
我搞不清楚如何将NeoVim/DAP与netcoredbg连接起来-我基本上试图从DAP连接到netcoredbg,而不是启动netcoredbg,然后它自己连接到调试程序。
这是我的工作配置: