How can I use the vsdbg adapter?
#869
Replies: 9 comments 12 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 outputAlso 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)
endNext 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.
-
|
Excellent!! |
Beta Was this translation helpful? Give feedback.
-
|
dap.listeners.after.event_initialized["set_exception_breakpoints"] = function()
dap.set_exception_breakpoints({"raised", "uncaught"})
endIs there any way to handle this? |
Beta Was this translation helpful? Give feedback.
-
|
@marcinjahn Did you get it working by any chance for .net? |
Beta Was this translation helpful? Give feedback.
-
|
I made a neovim plugin that works with ".net core compatible" debuggers |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
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
netcoredbgproject and I was experimenting with https://github.com/OmniSharp/omnisharp-vscode. If you download the release and unzip the file you get accessto the
vsdbgexecutable that seems to have the same interface with thenetcoredbgexecutable. 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:
{ "type": "request", "command": "initialize", "seq": 0, "arguments": { "clientId": "neovim", "clientname": "neovim", "adapterID": "nvim-dap", "pathFormat": "path", "columnsStartAt1": true, "linesStartAt1": true, "supportsRunInTerminalRequest": true, "supportsVariableType": true, "supportsProgressReporting": true, "locale": "en_US" } }Response Seq 1:
{ "seq": 1, "type": "response", "request_seq": 0, "success": false, "command": "initialize", "message": "", "body": { "supportsConfigurationDoneRequest": true, "supportsFunctionBreakpoints": true, "supportsConditionalBreakpoints": true, "supportsHitConditionalBreakpoints": true, "supportsEvaluateForHovers": true, "exceptionBreakpointFilters": [ { "filter": "all", "label": "All Exceptions", "description": "Break when an exception is thrown. ", "default": false, "supportsCondition": true } ], "supportsSetVariable": true, "supportsGotoTargetsRequest": true, "supportsModulesRequest": true, "additionalModuleColumns": [ { "attributeName": "vsLoadAddress", "label": "Load Address", "type": "string" }, { "attributeName": "vsPreferredLoadAddress", "label": "Preferred Load Address", "type": "string" }, { "attributeName": "vsModuleSize", "label": "Module Size", "type": "number" }, { "attributeName": "vsLoadOrder", "label": "Order", "type": "number" }, { "attributeName": "vsTimestampUTC", "label": "Timestamp", "type": "unixTimestampUTC" }, { "attributeName": "vsIs64Bit", "label": "64-bit", "type": "boolean" } ], "supportedChecksumAlgorithms": [ "MD5", "SHA1", "SHA256" ], "supportsExceptionOptions": true, "supportsValueFormattingOptions": true, "supportsExceptionInfoRequest": true, "supportTerminateDebuggee": true, "supportsSetExpression": true, "supportsReadMemoryRequest": true, "supportsCancelRequest": true, "supportsExceptionFilterOptions": true, "supportsExceptionConditions": true, "supportsLoadSymbolsRequest": true, "supportsModuleSymbolSearchLog": true, "supportsDebuggerProperties": true, "supportsSetSymbolOptions": true, "supportsHitBreakpointIds": true, "supportsVsIndividualBreakpointOperations": true, "supportsVsBreakpointLanguage": true, "supportsSetHitCount": true, "supportsVsCustomMessages": true, "supportsEvaluationOptions": true, "supportsExceptionStackTrace": true, "memoryReferencesAreAddresses": true, "supportsObjectFavorites": true, "supportsObjectId": true, "supportsVariableEnumerators": false } }Command Seq 1:
{ "type": "request", "command": "disconnect", "seq": 1, "arguments": { "terminateDebuggee": true, "restart": false } }Event Seq 2:
{ "seq": 2, "type": "event", "event": "output", "body": { "category": "telemetry", "output": "VS/Diagnostics/Debugger/vsdbg/DebugCompleted", "data": { "VS.Diagnostics.Debugger.vsdbg.OSFamily": "Windows", "VS.Diagnostics.Debugger.vsdbg.Version": "unknown", "VS.Diagnostics.Debugger.vsdbg.WindowsVersion": "10.0.19044", "VS.Diagnostics.Debugger.vsdbg.DebugCompleted.BreakCounter": 0, "VS.Diagnostics.Debugger.vsdbg.AdapterId": "unknown" } } }Response Seq 3
{ "seq": 3, "type": "response", "request_seq": 1, "success": true, "command": "disconnect" }Beta Was this translation helpful? Give feedback.
All reactions