How can I use the vsdbg
adapter?
#869
Replies: 5 comments 5 replies
-
|
Beta Was this translation helpful? Give feedback.
-
Have you managed to get this running? |
Beta Was this translation helpful? Give feedback.
-
Hello. To be honest I have yet to find time to really have a look into the issue. This question relates to my effort to really adopt neovim for everyday development as a replacement for VSCode or VS on a windows machine. @mfussenegger has been very helpful. But I really need to research this more. |
Beta Was this translation helpful? Give feedback.
-
Launched dap.adapters.cppvsdbg = {
id = 'cppvsdbg',
type = 'executable',
command = 'D:\\vscode\\cppdbg\\extension\\debugAdapters\\vsdbg\\bin\\vsdbg.exe',
args = {
'--interpreter=vscode',
},
options = { detached = false, },
}
dap.set_log_level 'trace' -- for log output Also tried to mimic vscode in clientId = 'vscode';
clientname = 'Visual Studio Code'; In all cases
dap.log
|
Beta Was this translation helpful? Give feedback.
-
The debug adapter actually use that handshake to verify if you are using it with VSCode or not. so you will need to respond to that handshake request if you want it to work. I don't know for .Net as I'm not really into it but for C/C++, this is how I do it: declare module vsda {
export class signer {
sign(arg: string): string;
}
export class validator {
createNewMessage(arg: string): string;
validate(arg: string): 'ok' | 'error';
}
}
const vsda_location = '[VSCODE_INSTALL_DIR]\\resources\\app\\node_modules.asar.unpacked\\vsda\\build\\Release\\vsda.node';
const a: typeof vsda = require(vsda_location);
const signer: vsda.signer = new a.signer();
process.argv.forEach((value, index, array) => {
if (index >= 2) {
const r = signer.sign(value);
console.log(r);
}
}); And next, you will need to make a handler for the handshake request that use the node js code we just made. local utils = require('dap.utils')
local rpc = require('dap.rpc')
local function send_payload(client, payload)
local msg = rpc.msg_with_content_length(vim.json.encode(payload))
client.write(msg)
end
function RunHandshake(self, request_payload)
local signResult = io.popen('node C:\\debugadapter\\vsdbgsignature\\sign.js ' .. request_payload.arguments.value)
if signResult == nil then
utils.notify('error while signing handshake', vim.log.levels.ERROR)
return
end
local signature = signResult:read("*a")
signature = string.gsub(signature, '\n', '')
local response = {
type = "response",
seq = 0,
command = "handshake",
request_seq = request_payload.seq,
success = true,
body = {
signature = signature
}
}
send_payload(self.client, response)
end Next for my debug adapter setup I use this: dap.adapters.cppvsdbg = {
id='cppvsdbg',
type='executable',
command = '[USER_PROFILE_LOCATION]\\.vscode\\extensions\\ms-vscode.cpptools-1.18.5-win32-x64\\debugAdapters\\vsdbg\\bin\\vsdbg.exe',
args = { "--interpreter=vscode" },
options = {
externalTerminal = true,
-- logging = {
-- moduleLoad = false,
-- trace = true
-- }
},
runInTerminal = true,
reverse_request_handlers = {
handshake = RunHandshake,
},
} and for the configuration I use this: dap.configurations.cpp = {
{
name = 'Try vsdbg',
type = "cppvsdbg",
request = "launch",
program = function ()
return vim.fn.input('Path: ', vim.fn.getcwd() .. '\\Debug\\test.exe', 'file')
end,
cwd = vim.fn.getcwd(),
clientID = 'vscode',
clientName = 'Visual Studio Code',
externalTerminal = true,
columnsStartAt1 = true,
linesStartAt1 = true,
locale = "en",
pathFormat = "path",
externalConsole = true
-- console = "externalTerminal"
},
} and last thing, it's to be discussed but I noticed that the "stackTrace" request actually result in an error. This is I think to be discussed with the owner of the lib what he think should be done but it actually have some difference with the specification of the DAP. I the specification, in the "stackTrace" arguments, the field "startFrame" is not required and should be used as a 0 by the debug adapter if not specified. But vsdbg actually require you to specify it. So for the moment, I modified a bit my local copy of nvim-dap to set this field to 0. But I don't know if the lib actually want that too. |
Beta Was this translation helpful? Give feedback.
-
I am trying to implement a plugin for C# support in neovim. One feature that I would really like to implement would be to be able to
execute a single unit test that contains a breakpoint. I cannot figure how to make this with the
netcoredbg
project and I was experimenting with https://github.com/OmniSharp/omnisharp-vscode. If you download the release and unzip the file you get accessto the
vsdbg
executable that seems to have the same interface with thenetcoredbg
executable. So I made an adapter:and in my cs configuration:
and tried to execute a test.dll and got the following error:
Bellow are the logs I feel that there must be a mismatch on the sequences or the vscode debuger refuses to speak to non vscode dap clients. Has anyone tried this before?
Command Seq 0:
Response Seq 1:
Command Seq 1:
Event Seq 2:
Response Seq 3
Beta Was this translation helpful? Give feedback.
All reactions