Closed zjturner closed 5 years ago
@zjturner of course, DAs are supported on Windows otherwise VS Code debugging would not work in Windows at all.
But I'm not sure that your "main" is a good test test program... VS Code expects that responses are returned by the DAs promptly and it will kill the DA after a timeout.
We have a great developer community over on slack where extension authors help each other. This is a great place for you to ask questions and find support.
Happy Coding!
@weinand I only resorted to this test after trying many other thing. Of course, my real adapter calls fgets
on stdin
, which also terminates. And the amount of time before it kills my process is on the order of 1 second or less, so there is not enough time to really do anything.
Is there any way to adjust this timeout so I can confirm whether this is actually the problem?
How can I re-open this, since it's not yet clear to me that this isn't a bug in VS Code?
Can you run your DA in server mode? (so that VS Code can connect to via a socket instead of stdin/stdout?
Running in server mode is indeed something I have tried, and it works (In the sense that VS Code does not kill it). But I'd like to be able to debug it in non-server mode if possible. Reading from a socket and reading from stdin have some differences, and it would be nice to be able to debug the file codepath.
how does the package.json of your debugger extension look like? At least this part:
If you have LiveShare installed, uninstall it and see whether it makes a difference.
I have a lot of stuff under there, so I guess I'll post it all since I'm not sure which part matters. I wonder if it has to do with the fact that I don't specify .exe
? Maybe I'll try that.
"debuggers": [
{
"type": "lldb-vscode",
"label": "Native LLDB Debugger",
"enableBreakpointsFor": {
"languageIds": [
"ada",
"arm",
"asm",
"c",
"cpp",
"crystal",
"d",
"fortan",
"fortran-modern",
"nim",
"objective-c",
"objectpascal",
"pascal",
"rust",
"swift"
]
},
"program": "./bin/lldb-vscode",
"configurationAttributes": {
"launch": {
"required": [
"program"
],
"properties": {
"program": {
"type": "string",
"description": "Path to the program to debug."
},
"args": {
"type": [ "array", "string" ],
"description": "Program arguments.",
"default": []
},
"cwd": {
"type": "string",
"description": "Program working directory.",
"default": "${workspaceRoot}"
},
"env": {
"type": "array",
"description": "Additional environment variables.",
"default": []
},
"stopOnEntry": {
"type": "boolean",
"description": "Automatically stop after launch.",
"default": false
},
"disableASLR": {
"type": "boolean",
"description": "Enable or disable Address space layout randomization if the debugger supports it.",
"default": true
},
"disableSTDIO": {
"type": "boolean",
"description": "Don't retrieve STDIN, STDOUT and STDERR as the program is running.",
"default": false
},
"shellExpandArguments": {
"type": "boolean",
"description": "Expand program arguments as a shell would without actually launching the program in a shell.",
"default": false
},
"detachOnError": {
"type": "boolean",
"description": "Detach from the program.",
"default": false
},
"trace": {
"type": "boolean",
"description": "Enable logging of the Debug Adapter Protocol.",
"default": true
},
"sourcePath": {
"type": "string",
"description": "Specify a source path to remap \"./\" to allow full paths to be used when setting breakpoints in binaries that have relative source paths."
},
"sourceMap": {
"type": "array",
"description": "Specify an array of path remappings; each element must itself be a two element array containing a source and desination pathname. Overrides sourcePath.",
"default": []
},
"debuggerRoot": {
"type": "string",
"description": "Specify a working directory to set the debug adaptor to so relative object files can be located."
},
"initCommands": {
"type": "array",
"description": "Initialization commands executed upon debugger startup.",
"default": []
},
"preRunCommands": {
"type": "array",
"description": "Commands executed just before the program is launched.",
"default": []
},
"stopCommands": {
"type": "array",
"description": "Commands executed each time the program stops.",
"default": []
},
"exitCommands": {
"type": "array",
"description": "Commands executed at the end of debugging session.",
"default": []
}
}
},
"attach": {
"properties": {
"program": {
"type": "string",
"description": "Path to the program to attach to."
},
"pid": {
"type": [
"number",
"string"
],
"description": "System process ID to attach to."
},
"waitFor": {
"type": "boolean",
"description": "If set to true, then wait for the process to launch by looking for a process with a basename that matches `program`. No process ID needs to be specified when using this flag.",
"default": true
},
"trace": {
"type": "boolean",
"description": "Enable logging of the Debug Adapter Protocol.",
"default": true
},
"sourcePath": {
"type": "string",
"description": "Specify a source path to remap \"./\" to allow full paths to be used when setting breakpoints in binaries that have relative source paths."
},
"sourceMap": {
"type": "array",
"description": "Specify an array of path remappings; each element must itself be a two element array containing a source and desination pathname. Overrides sourcePath.",
"default": []
},
"debuggerRoot": {
"type": "string",
"description": "Specify a working directory to set the debug adaptor to so relative object files can be located."
},
"attachCommands": {
"type": "array",
"description": "Custom commands that are executed instead of attaching to a process ID or to a process by name. These commands may optionally create a new target and must perform an attach. A valid process must exist after these commands complete or the \"attach\" will fail.",
"default": []
},
"initCommands": {
"type": "array",
"description": "Initialization commands executed upon debugger startup.",
"default": []
},
"preRunCommands": {
"type": "array",
"description": "Commands executed just before the program is attached to.",
"default": []
},
"stopCommands": {
"type": "array",
"description": "Commands executed each time the program stops.",
"default": []
},
"exitCommands": {
"type": "array",
"description": "Commands executed at the end of debugging session.",
"default": []
}
}
}
},
"initialConfigurations": [
{
"type": "lldb-vscode",
"request": "launch",
"name": "Debug",
"program": "${workspaceRoot}/<your program>",
"args": [],
"env": [],
"cwd": "${workspaceRoot}"
}
],
"configurationSnippets": [
{
"label": "LLDB: Launch",
"description": "",
"body": {
"type": "lldb-vscode",
"request": "launch",
"name": "${2:Launch}",
"program": "^\"\\${workspaceRoot}/${1:<your program>}\"",
"args": [],
"env": [],
"cwd": "^\"\\${workspaceRoot}\""
}
}
]
}
and your "program" attribute doesn't require a ".exe" on Windows?
Interestingly, adding the .exe
seems to have made a difference. I don't have time to investigate this more as I'm leaving for the day, but I will say that VS Code was definitely launching my adapter even when I don't have .exe
, but adding it seems to make it wait longer before killing it, which is extremely strange. So maybe there actually is some kind of bug here when you forget to specify .exe
in your program name. It should either report an error or behave identically.
I'll dig in more tomorrow.
I've got a Debug Adapter for LLDB (lldb.llvm.org) which works fine on Linux. I'm trying to get this working on Windows and running into some problems. The second I make a call into the CRT to read from stdin the adapter process just exits. I have tried attaching to the debug adapter to see if I can figure out what's going on, but even this doesn't seem to work. It seems that after some period of time (very short), VS Code just kills the adapter for no apparent reason. My main function looks like this:
And I can see using DbgView that Checkpoint 1 is printed and Checkpoint 2 is not printed. Instead, the process just starts up and immediately dies.
Are debug adapters supported on Windows, because AFAICT I'm not doing anything special or interesting at all, and it just straight up doesn't work.