Comments (64)
Thank you @Thesmader and @puremourning 😎
I finally got it working and compiled a quick guide which worked for me: https://gist.github.com/nachtmaar/9579a3ded4a3f3e14afbc427172f8098
from vimspector.
Unable to restart debugging. Please try ending the debug session and starting again
This error is slightly misleading, as it was added to catch a bug in VS Code some time ago. It comes from here:
if (!args || !args.dartSdkPath || (this.requiresProgram && !args.program)) {
this.logToUser("Unable to restart debugging. Please try ending the debug session and starting again.\n");
In this case, I suspect this is related to the changes mentioned above - that the debug adapter now takes the SDK paths instead of paths to the binaries. You'll need to replace dartPath
with dartSdkPath
(and provide the path to the SDK root, not the binary) and the same for flutterSdkPath
.
from vimspector.
Vimspector is a DAP client, and does not have language/extension specific code
Ah, ofcourse. I'd overlooked that as there are some other projects using the DAP that are Dart-specific extensions for editors.
assuming that the basic protocol stuff is sufficient without the custom stuff.
A generic DAP client should absolutely work with the new SDK debug adapters without any of the custom messages. If that doesn't seem to be the case I would consider it a bug (which should be filed in the Dart/Flutter SDKs - and I'd appreciate being pinged on them) :-)
from vimspector.
I've got a PR open here:
It includes:
- switching to using
runInTerminalRequest
when using"console": "terminal"
(instead of custom commands) - don't send
dart.log
events unless the client sent"sendLogsToClient": true
in the launch args - assume the SDK supports
--write-service-info
(required for spawning in the clients terminal) if the"useWriteServiceInfo"
key is not supplied (VS Code does an SDK version check and always sends this flag, but defaulting to on will cut down on boilerplate here - you will need a Dart SDK at least v2.7.0 for it to work though)
I'll check on the test results and merge to master later, but in the meantime you're free to check out that branch to test using the terminal mode. Let me know if you have any problems!
from vimspector.
Thanks a lot, @DanTup. I was able to get the debugger running! I will try to check if everything works as expected 😄.
from vimspector.
@Thesmader, may you share your working config? I am trying to follow the steps but with no success. My configuration:
.gadgets.json
{
"adapters": {
"multi-session": {
"host": "${host}",
"port": "${port}"
},
"dart-code": {
"variables": {
"root": "/Users/ts/.vscode/extensions/dart-code.dart-code-3.19.2"
},
"type": "dart",
"command": [
"node",
"${root}/src/debug/debug.js",
"flutter"
]
}
}
}
.vimspector.json
{
"configurations": {
"Launch": {
"adapter": "dart-code",
"configuration": {
"request": "launch",
"type": "flutter",
"dartSdkPath": "/Users/ts/Documents/flutter",
"program": "/Users/ts/Documents/github/personal/pikis/lib/main.dart",
"cwd": "/Users/ts/Documents/github/personal/pikis"
}
}
}
}
Log:
2021-02-16 22:27:12,714 - INFO - **** INITIALISING NEW VIMSPECTOR SESSION ****
2021-02-16 22:27:12,714 - INFO - API is: neo
2021-02-16 22:27:12,714 - INFO - VIMSPECTOR_HOME = /Users/ts/.config/nvim/plugged/vimspector
2021-02-16 22:27:12,714 - INFO - gadgetDir = /Users/ts/.config/nvim/plugged/vimspector/gadgets/macos
2021-02-16 22:27:12,717 - INFO - User requested start debug session with {}
2021-02-16 22:27:12,718 - DEBUG - Reading configurations from: None
2021-02-16 22:27:12,718 - DEBUG - Reading configurations from: /Users/ts/Documents/github/personal/pikis/.vimspector.json
2021-02-16 22:27:12,719 - DEBUG - Reading gadget config: /Users/ts/.config/nvim/plugged/vimspector/gadgets/macos/.gadgets.json
2021-02-16 22:27:12,720 - DEBUG - Reading gadget config: None
2021-02-16 22:27:12,721 - INFO - Configuration: {"adapter": "dart-code", "configuration": {"request": "launch", "type": "flutter", "dartSdkPath": "/Users/ts/Documents/flutter", "program": "/Users/ts/Documents/github/personal/pikis/lib/main.dart", "cwd": "/Users/ts/Documents/github/personal/pikis"}}
2021-02-16 22:27:12,721 - INFO - Adapter: {"variables": {"root": "/Users/ts/.vscode/extensions/dart-code.dart-code-3.19.2"}, "type": "dart", "command": ["node", "/Users/ts/.vscode/extensions/dart-code.dart-code-3.19.2/src/debug/debug.js", "flutter"]}
2021-02-16 22:27:13,555 - DEBUG - LAUNCH!
2021-02-16 22:27:13,557 - INFO - Starting debug adapter with: {"variables": {"root": "/Users/ts/.vscode/extensions/dart-code.dart-code-3.19.2"}, "type": "dart", "command": ["node", "/Users/ts/.vscode/extensions/dart-code.dart-code-3.19.2/src/debug/debug.js", "flutter"]}
2021-02-16 22:27:13,557 - DEBUG - Connection Type: neojob
2021-02-16 22:27:13,560 - INFO - Debug Adapter Started
2021-02-16 22:27:13,561 - DEBUG - Sending Message: {"command": "initialize", "arguments": {"adapterID": "adapter", "clientID": "vimspector", "clientName": "vimspector", "linesStartAt1": true, "columnsStartAt1": true, "locale": "en_GB", "pathFormat": "path", "supportsVariableType": true, "supportsVariablePaging": false, "supportsRunInTerminalRequest": true}, "seq": 0, "type": "request"}
2021-02-16 22:27:14,289 - INFO - The server has terminated with status 1
2021-02-16 22:27:14,291 - DEBUG - Closing down: Aborting request {'command': 'initialize', 'arguments': {'adapterID': 'adapter', 'clientID': 'vimspector', 'clientName': 'vimspector', 'linesStartAt1': True, 'columnsStartAt1': True, 'locale': 'en_GB', 'pathFormat': 'path', 'supportsVariableType': True, 'supportsVariablePaging': False, 'supportsRunInTerminalRequest': True}, 'seq': 0, 'type': 'request'}
2021-02-16 22:27:14,292 - INFO - User Msg: Request for initialize aborted: Closing down
2021-02-16 22:27:14,384 - DEBUG - No server exit handler
from vimspector.
@sidlatau Here you go:
.vimspector.json(placed in my flutter project root) :
{
"configurations": {
"launch": {
"adapter": "dart-code",
"configuration": {
"request": "launch",
"type": "flutter",
"flutterSdkPath": "/home/thesmader/dev/env/flutter/",
"dartSdkPath": "/home/thesmader/dev/env/flutter/bin/cache/dart-sdk/bin",
"program": "./lib/main.dart",
"cwd": "/home/thesmader/dev/project-elaichi/elaichi"
}
}
}
}
.gadgets.json :
{
"adapters": {
"dart": {
"command": [
"node",
"${root}/out/dist/debug.js",
"dart"
],
"type": "dart",
"variables": {
"root": "/home/thesmader/dev/env/dartcode"
}
},
"dart-code": {
"command": [
"node",
"${root}/out/dist/debug.js",
"flutter"
],
"type": "flutter",
"variables": {
"root": "/home/thesmader/dev/env/dartcode"
}
},
"multi-session": {
"host": "${host}",
"port": "${port}"
},
"vscode-python": {
"command": [
"node",
"${gadgetDir}/vscode-python/out/client/debugger/debugAdapter/main.js"
],
"name": "vscode-python"
}
}
}
from vimspector.
The next versions of the Dart/Flutter SDKs include their own DAP implementations. Instructions on using them and any custom messages they support are documented here:
- Dart: https://github.com/dart-lang/sdk/blob/main/pkg/dds/tool/dap/README.md
- Flutter: https://github.com/flutter/flutter/blob/master/packages/flutter_tools/lib/src/debug_adapters/README.md
It's up to the editor to start the correct debug adapter based on the context it has for the project that's open and whether the user is trying to run tests.
VS Code isn't using them yet as there are a few minor things outstanding it needs (nothing significant that would prevent other editors using them), but will do soon.
Please file issues and ping me if you have any issues integrating against these :-)
from vimspector.
Is there a dart debug adapter?
from vimspector.
I know in this plugin, they use dart debug adapter:
https://github.com/Dart-Code/Dart-Code
But i don't know is it a seperate module or coupled with that plugin.
from vimspector.
https://github.com/Dart-Code/Dart-Code/blob/master/package.json#L955
That's where the debug plugin definition is found. It should be possible to make a .vimspector.json
to work with it.
I haven't tried it but something like this might work:
{
"adapters" {
"dart-code": {
"name": "dart",
"command": [
"node",
"$HOME/.vscode/<PATH TO BUNDLE>/src/debug/dart_debug_entry.js"
],
"attach": {
"pidProperty": "observatoryUri",
"pidSelect": "ask"
}
}
},
"configurations": {
"Dart - Launch": {
"adapter": "dart-code",
"configuration": {
"request": "launch",
"cwd": "string",
"deviceId": "string",
"enableAsserts": "boolean",
"program": "string",
"showMemoryUsage": "boolean",
"flutterMode": "enum [ debug, release, profile ]",
"args": "array[string]",
"env": " ?? ",
"vmAdditionalArgs": "array[string]"
}
},
"Dart - Attach": {
"adapter": "dart-code",
"configuration": {
"request": "attach",
"cwd": "string",
"packages": "string"
}
}
}
Obviously, fill in the actual values and PATH_TO_BUNDLE, etc.
Let me know how you get on. I have found that I often have to read the vscode plugin code to work out the actual set of arguments required by the adapter, but once vimspector starts the adapter and initialises it successfully, it tends to work.
~/.vimspector.log is very useful in debugging these configs too.
Feel free to ask on Gitter for assistance.
from vimspector.
The dart adapter should be workable with something like the above config. I'm not likely to add official support for it unless there's a really strong need
from vimspector.
OK, i started to actually debug a simple dart app.
After following this tutorial and generated a binary file, i created this .vimspector and put it in root of my project:
{
"adapters": {
"dart-code": {
"name": "dart",
"command": [
"node",
"$HOME/.vscode-oss/extensions/dart-code.dart-code-3.8.0/src/debug/dart_debug_entry.js"
],
"attach": {
"pidProperty": "observatoryUri",
"pidSelect": "ask"
}
}
},
"configurations": {
"Dart - Launch": {
"adapter": "dart-code",
"configuration": {
"request": "launch",
"cwd": "${workspaceRoot}",
"program": "${workspaceRoot}/bin/myapp"
}
},
"Dart - Attach": {
"adapter": "dart-code",
"configuration": {
"request": "attach",
"cwd": "${workspaceRoot}"
}
}
}
}
But it gives me these errors:
https://gist.github.com/LinArcX/b797a27cdc0015dadb406156b8216a18
Edit 1: I didn't cloned Dart-Code repo. Instead installed vscode and through it, installed dart plugin.
Edit 2: I've noticed that there isn't any dart_debug_entry.js Dart-Code.(Is it the root of evil?)
from vimspector.
So it looks like the visual studio extension uses webpack which obviously vimspector can't use.
Also even if you can get around that (I did by building from source), the debug adapter requires vscode and does not work outside of it, due to a design-o:
Error: Cannot find module 'vscode'
Require stack:
- /Users/ben/Development/vimspector/Dart-Code/out/src/extension/config.js
- /Users/ben/Development/vimspector/Dart-Code/out/src/debug/dart_debug_impl.js
- /Users/ben/Development/vimspector/Dart-Code/out/src/debug/dart_debug_entry.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:966:17)
at Function.Module._load (internal/modules/cjs/loader.js:859:27)
at Module.require (internal/modules/cjs/loader.js:1028:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (/Users/ben/Development/vimspector/Dart-Code/out/src/extension/config.js:12:18)
at Module._compile (internal/modules/cjs/loader.js:1139:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1159:10)
at Module.load (internal/modules/cjs/loader.js:988:32)
at Function.Module._load (internal/modules/cjs/loader.js:896:14)
at Module.require (internal/modules/cjs/loader.js:1028:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/Users/ben/Development/vimspector/Dart-Code/out/src/extension/config.js',
'/Users/ben/Development/vimspector/Dart-Code/out/src/debug/dart_debug_impl.js',
'/Users/ben/Development/vimspector/Dart-Code/out/src/debug/dart_debug_entry.js'
]
}
So basically the dart debug adapter that's embedded in Dart-Code cannot be used standalone, so IMO should not be listed on the DAP implementations page. Feel free to raise a bug with them to make it standalone (it should be possible, it's only their config
module that seems to require vscode, which I assume means the DA doesn't actually require it).
from vimspector.
If you want to replicate my testing:
- clone the Dart-Code repo
npm install
npm run build-tests
- check out the minimal project in
support/test/dart/cli
in this branch of vimspector, in particular this vimspector.json:
{
"adapters": {
"dart-code": {
"variables": {
"root": "/Users/ben/Development/vimspector/Dart-Code"
},
"type": "dart",
"command": [
"node",
"${root}/out/src/debug/dart_debug_entry.js"
],
"configuration": {
"console": "terminal"
}
}
},
"configurations": {
"Launch": {
"adapter": "dart-code",
"configuration": {
"request": "launch",
"type": "dart",
"program": "${file}"
}
}
}
}
obviously adjust root
variable accordingly, but it still won't work.
from vimspector.
In fact, you already know this. Because it was pointed out to you here, right. https://www.reddit.com/r/vim/comments/ahyf9a/debug_adapter_protocoldap_plugin_for_vim/
I am talking about the DART debug adapter from https://github.com/Dart-Code/Dart-Code . I have contacted the author and he mentioned that the debug adapter could run only in VSCode since it has a runtime dependency on it.
So yeah, dart can't work with vimspector unless someone else write a debug adapter that is independent of vscode.
from vimspector.
@puremourning As @DanTup said, I've tired latest commit of Dart-Code with your instructions.
But i've got this error message:
Unable to restart debugging. Please try ending the debug session and starting again.
I don't know if this issue related to Dart-Code or vimspector. If related to Dart-Code let me know to report to @DanTup.
from vimspector.
It's unlikely to be vimspector saying that. And you didn't post any diagnostics, so i can't decide one way or the other, but reading @DanTup's latest comment, i guess it's not quite there yet.
from vimspector.
@puremourning Sorry.
This is the output of .vimspector.log
in my home directory:
Is there any log should i send for diagnostics?
from vimspector.
2020-03-24 20:42:15,399 - DEBUG - Message received: {'seq': 2, 'type': 'event', 'event': 'output', 'body': {'category': 'console', 'output': 'Unable to restart debugging. Please try ending the debug session and starting again.\n'}}
2020-03-24 20:42:15,404 - DEBUG - Message received: {'seq': 3, 'type': 'event', 'event': 'terminated'}
The debug adapter said that message. I don't know why - either because the launch configuration is bogus, or because it is broken - either way it's not a vimspector issue.
Is there any log should i send for diagnostics?
See the GitHub issue template
from vimspector.
That message happens when the launch config doesn't include the required fields:
It was added to catch an old bug in VS Code so the message seems a bit strange here - but it's correct to fail here if you don't pass args.dartPath
and args.program
(we need dartPath
to know where the Dart executable is, and program
to know what script to run).
from vimspector.
Thanks!
try this:
{
"adapters": {
"dart-code": {
"variables": {
"root": "/Users/ben/Development/vimspector/Dart-Code"
},
"type": "dart",
"command": [
"node",
"${root}/out/src/debug/dart_debug_entry.js"
],
"configuration": {
"console": "terminal"
}
}
},
"configurations": {
"Launch": {
"adapter": "dart-code",
"configuration": {
"request": "launch",
"type": "dart",
"dartPath": "/path/to/dart",
"program": "${file}"
}
}
}
}
Change "dartPath": "/path/to/dart",
obviously
from vimspector.
Is
"console": "terminal"
Related to behaviour in the debug adapter? If so, this probably won't work going forwards, as that mode is specifically to support the VS Code terminal, and will send messages back to the client expecting it to spawn the process (so it can be owned by the clients terminal rather than a sub-processes of the debug adapter).
from vimspector.
i think it's trying to use the runInTerminal
request? I honestly don't remember. I guess i reverse engineered what's there some time ago and never got it to work.
from vimspector.
Ugh, I didn't even realise there was such a request. I basically implemented my own request/response to do that in the recent changes (which means it's VS Code specific).
I'll look at moving over to using this soon (in the meantime, you probably want to remove that and use the non-terminal way of running them, assuming you support that).
from vimspector.
In my experience runInTerminal is best because it allows attaching stdin. The other methods are usually kinda wonky for console apps at least.
from vimspector.
Yeah, supporting stdin is the reason I was adding support for this. I'll try and get it swapped over (in the meantime, not using terminal
should at least make it work without stdin support to verify the debug adapter is working).
I've opened Dart-Code/Dart-Code#2314 for changing to support runInTerminalRequest
that you can subscribe to if you want notification when it's done (I'll hope to look at it this week).
from vimspector.
"dartPath": "/path/to/dart",
https://gist.github.com/LinArcX/dde56327ff23d2853f80f261932201f4
from vimspector.
Does it just hang there? Looks like it an initializeRequest
is sent, but there's no configurationDone
sent?
from vimspector.
DA didn't send the initialized
event: https://microsoft.github.io/debug-adapter-protocol/specification#Events_Initialized
from vimspector.
Also, FWIW rather than custom messages, you could just use the output message:
2020-03-24 23:30:28,102 - DEBUG - Message received: {'seq': 5, 'type': 'event', 'event': 'dart.log', 'body': {'message': ' PID: 3245', 'severity': 0, 'category': 9}}
2020-03-24 23:30:28,102 - WARNING - User Msg: Unhandled event: dart.log
https://microsoft.github.io/debug-adapter-protocol/specification#Events_Output
from vimspector.
I got it to work.
- clone the Dart-Code repo
- npm install
- npm run build-tests
Use this vimspector.json (change paths as appropriate):
{
"adapters": {
"dart-code": {
"variables": {
"root": "/Users/ben/Development/vimspector/Dart-Code" // change this
},
"type": "dart",
"command": [
"node",
"${root}/out/src/debug/dart_debug_entry.js"
]
}
},
"configurations": {
"Launch": {
"adapter": "dart-code",
"configuration": {
"request": "launch",
"type": "dart",
"dartPath": "/usr/local/bin/dart", // change this to path to dat
"program": "${file}", // change this to the main.dart
"cwd": "${workspaceRoot}"
}
}
}
}
from vimspector.
DA didn't send the initialized event:
Oh, this is interesting... We're sending this after launchRequest
. I'm not sure if this is correct though (it's working in VS Code, but I'm not sure it's correct now)...
FWIW rather than custom messages, you could just use the output message:
We do use output messages, but dart.log
is different - it's the internal logging from the DA being sent to the client (we have some diagnostics in the VS Code client - you can run the Dart: Capture Logs command to start writing it to disk). Perhaps we should add a flag to enable it though, so it's not unnecessarily spammy for other clients.
I got it to work.
Oh, what changed to fix the initializedEvent
?
from vimspector.
'Oh, what changed to fix the initializedEvent?
Nothing - i mean - @LinArcX log showed that Vimspector didn't receive it (though it did send and get response to launch
). But when i tried it, it worked.
The initialisation sequence for DAP is kinda hairy. There's an explanation on their tracker somewhere about the true sequence of events, but i also documented it here: https://github.com/puremourning/vimspector/blob/master/python3/vimspector/debug_session.py#L709
from vimspector.
Actually, there is a difference. When i tested, i got an exception in the dart DA log about from
not being valid. I traced the code and found that the cwd
launch option is mandatory, and added it. Maybe that was related.
from vimspector.
When i tested, i got an exception in the dart DA log about from not being valid. I traced the code and found that the
cwd
launch option is mandatory
I'm not sure exactly what this means (not sure what "from" is), but if anything is giving bad errors that make it hard to track down, let me know and I'll try to improve.
It does look like cwd
may be required - but to simplify things we could perhaps just take the directory from program
(assuming it's absolute)?
from vimspector.
i think cwd being mandatory is fine. That's common amongst the DAs i've seen. There are two choices otherwise - try and guess from the other arguments, or use the WD of the DA itself. Neither are likely to be better than asking for it to be supplied. A lot of vscode-side plugins default it to workspaceRoot (as i used above) and vimspector gadget config can to that too.
from vimspector.
not sure what "from" is
Sorry this was on my other mac, hence the hand-wavy repot. IIRC it was the from
argument in a call to path.<somthing>
when launching the program. IIRC it was sensible - something like getting a canonical path or other.
Throwing typescript unhandled promise exceptions when something goes wrong is par for the course in debug adapters, so that's fine too i guess.
from vimspector.
I checked again and couldn't see any obvious way it should fail without a cwd
. If you can repro this and get a log, I'd be interested in either handling it, or at least making sure the failure includes a good message.
I've found a few other issues with the changes in that PR, so may not get around to finishing/merging today, but I'll ping when I think it should all be working and is in master.
from vimspector.
(node:3486) UnhandledPromiseRejectionWarning: TypeError [ERR_INVALID_ARG_TYPE]: The "from" argument must be of type string. Received undefined
at validateString (internal/validators.js:118:11)
at Object.relative (path.js:1053:5)
at DartDebugSession.sourceFileForArgs (/Users/ben/Development/Dart-Code/out/src/debug/dart_debug_impl.js:236:21)
at DartDebugSession.buildAppArgs (/Users/ben/Development/Dart-Code/out/src/debug/dart_debug_impl.js:280:27)
at DartDebugSession.spawnProcess (/Users/ben/Development/Dart-Code/out/src/debug/dart_debug_impl.js:239:30)
at DartDebugSession. (/Users/ben/Development/Dart-Code/out/src/debug/dart_debug_impl.js:152:38)
at Generator.next ()
at /Users/ben/Development/Dart-Code/out/src/debug/dart_debug_impl.js:8:71
at new Promise ()
at __awaiter (/Users/ben/Development/Dart-Code/out/src/debug/dart_debug_impl.js:4:12)
(node:3486) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag--unhandled-rejections=strict
(see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:3486) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
from vimspector.
Full log:
Reading from channel output...
2020-03-25 14:18:01,325 - INFO - **** INITIALISING NEW VIMSPECTOR SESSION ****
2020-03-25 14:18:01,325 - INFO - API is:
2020-03-25 14:18:01,325 - INFO - VIMSPECTOR_HOME = /Users/ben/.vim/bundle/vimspector
2020-03-25 14:18:01,330 - INFO - gadgetDir = /Users/ben/.vim/bundle/vimspector/gadgets/macos
2020-03-25 14:18:01,331 - DEBUG - Toggle found bp at /Users/ben/.vim/bundle/vimspector/support/test/dart/cli/bin/main.dart:4 ? False (New)
2020-03-25 14:18:01,783 - INFO - User requested start debug session with {}
2020-03-25 14:18:01,784 - DEBUG - Reading gadget config: /Users/ben/.vim/bundle/vimspector/gadgets/macos/.gadgets.json
2020-03-25 14:18:01,785 - DEBUG - Reading gadget config: None
2020-03-25 14:18:01,785 - INFO - Configuration: {"adapter": "dart-code", "configuration": {"request": "launch", "type": "dart", "program": "/Users/ben/.vim/bundle/vimspector/support/test/dart/cli/bin/main.dart", "dartPath": "dart"}}
2020-03-25 14:18:01,785 - INFO - Adapter: {"variables": {"root": "/Users/ben/Development/Dart-Code"}, "type": "dart", "command": ["node", "/Users/ben/Development/Dart-Code/out/src/debug/dart_debug_entry.js"], "configuration": {"console": "terminal"}}
2020-03-25 14:18:01,804 - INFO - Starting debug adapter with: {"variables": {"root": "/Users/ben/Development/Dart-Code"}, "type": "dart", "command": ["node", "/Users/ben/Development/Dart-Code/out/src/debug/dart_debug_entry.js"], "configuration": {"console": "terminal"}}
2020-03-25 14:18:01,807 - INFO - Debug Adapter Started
2020-03-25 14:18:01,808 - DEBUG - Sending Message: {"command": "initialize", "arguments": {"adapterID": "adapter", "clientID": "vimspector", "clientName": "vimspector", "linesStartAt1": true, "columnsStartAt1": true, "locale": "en_GB", "pathFormat": "path", "supportsVariableType": true, "supportsVariablePaging": false, "supportsRunInTerminalRequest": true}, "seq": 0, "type": "request"}
2020-03-25 14:18:01,808 - DEBUG - Calling: vimspector#internal#job#Send(g:vimspector_internal_arg_0)
2020-03-25 14:18:01,878 - DEBUG - Message received: {'seq': 1, 'type': 'response', 'request_seq': 0, 'command': 'initialize', 'success': True, 'body': {'supportsConfigurationDoneRequest': True, 'supportsEvaluateForHovers': True, 'supportsDelayedStackTraceLoading': True, 'supportsConditionalBreakpoints': True, 'supportsLogPoints': True, 'supportsTerminateRequest': True, 'supportsRestartFrame': True, 'exceptionBreakpointFilters': [{'filter': 'All', 'label': 'All Exceptions', 'default': False}, {'filter': 'Unhandled', 'label': 'Uncaught Exceptions', 'default': True}]}}
2020-03-25 14:18:01,879 - DEBUG - LAUNCH!
2020-03-25 14:18:01,879 - DEBUG - Sending Message: {"command": "launch", "arguments": {"console": "terminal", "request": "launch", "type": "dart", "program": "/Users/ben/.vim/bundle/vimspector/support/test/dart/cli/bin/main.dart", "dartPath": "dart", "name": "test"}, "seq": 1, "type": "request"}
2020-03-25 14:18:01,879 - DEBUG - Calling: vimspector#internal#job#Send(g:vimspector_internal_arg_0)
2020-03-25 14:18:01,880 - DEBUG - Message received: {'seq': 2, 'type': 'response', 'request_seq': 1, 'command': 'launch', 'success': True}
2020-03-25 14:18:01,905 - INFO - Server stderr: (node:3486) UnhandledPromiseRejectionWarning: TypeError [ERR_INVALID_ARG_TYPE]: The "from" argument must be of type string. Received undefined
at validateString (internal/validators.js:118:11)
at Object.relative (path.js:1053:5)
at DartDebugSession.sourceFileForArgs (/Users/ben/Development/Dart-Code/out/src/debug/dart_debug_impl.js:236:21)
at DartDebugSession.buildAppArgs (/Users/ben/Development/Dart-Code/out/src/debug/dart_debug_impl.js:280:27)
at DartDebugSession.spawnProcess (/Users/ben/Development/Dart-Code/out/src/debug/dart_debug_impl.js:239:30)
at DartDebugSession.<anonymous> (/Users/ben/Development/Dart-Code/out/src/debug/dart_debug_impl.js:152:38)
at Generator.next (<anonymous>)
at /Users/ben/Development/Dart-Code/out/src/debug/dart_debug_impl.js:8:71
at new Promise (<anonymous>)
at __awaiter (/Users/ben/Development/Dart-Code/out/src/debug/dart_debug_impl.js:4:12)
2020-03-25 14:18:01,910 - INFO - Server stderr: (node:3486) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:3486) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
from vimspector.
fwiw adding cwd
to launch args fixes it.
Though i just spotted in the log, this:
2020-03-25 14:27:06,028 - DEBUG - Requesting source: {'name': 'dart:isolate-patch/isolate_patch.dart', 'sourceReference': 3, 'adapterData': {'type': '@Script', 'fixedId': True, 'id': 'libraries/@1026248/scripts/dart%3Aisolate-patch%2Fisolate_patch.dart/0', 'uri': 'dart:isolate-patch/isolate_patch.dart', '_kind': 'kernel'}, 'origin': 'from the Dart SDK', 'presentationHint': 'deemphasize'}
2020-03-25 14:27:06,028 - DEBUG - Sending Message: {"command": "source", "arguments": {"sourceReference": 3, "source": {"name": "dart:isolate-patch/isolate_patch.dart", "sourceReference": 3, "adapterData": {"type": "@Script", "fixedId": true, "id": "libraries/@1026248/scripts/dart%3Aisolate-patch%2Fisolate_patch.dart/0", "uri": "dart:isolate-patch/isolate_patch.dart", "_kind": "kernel"}, "origin": "from the Dart SDK", "presentationHint": "deemphasize"}}, "seq": 8, "type": "request"}
2020-03-25 14:27:06,028 - DEBUG - Calling: vimspector#internal#job#Send(g:vimspector_internal_arg_0)
2020-03-25 14:27:06,028 - DEBUG - Message received: {'seq': 88, 'type': 'event', 'event': 'dart.log', 'body': {'message': '<== {"jsonrpc":"2.0","id":"31","result":{"type":"Sentinel","kind":"Collected","valueAsString":"<collected>"}}\n', 'severity': 0, 'category': 9}}
2020-03-25 14:27:06,028 - WARNING - User Msg: Unhandled event: dart.log
2020-03-25 14:27:06,029 - DEBUG - Message received: {'seq': 89, 'type': 'response', 'request_seq': 8, 'command': 'source', 'success': False, 'message': "TypeError: Cannot read property 'data' of undefined\n at DartDebugSession.sourceRequest (/Users/ben/Development/Dart-Code/out/src/debug/dart_debug_impl.js:679:32)\n at DartDebugSession.dispatchRequest (/Users/ben/Development/Dart-Code/node_modules/vscode-debugadapter/lib/debugSession.js:411:22)\n at DartDebugSession._handleData (/Users/ben/Development/Dart-Code/node_modules/vscode-debugadapter/lib/protocol.js:97:38)\n at Socket.<anonymous> (/Users/ben/Development/Dart-Code/node_modules/vscode-debugadapter/lib/protocol.js:18:44)\n at Socket.emit (events.js:316:20)\n at addChunk (_stream_readable.js:297:12)\n at readableAddChunk (_stream_readable.js:273:9)\n at Socket.Readable.push (_stream_readable.js:214:10)\n at Pipe.onStreamRead (internal/stream_base_commons.js:186:23)", 'body': {'error': {'id': 1104, 'format': '{_stack}', 'variables': {'_exception': "Cannot read property 'data' of undefined", '_stack': "TypeError: Cannot read property 'data' of undefined\n at DartDebugSession.sourceRequest (/Users/ben/Development/Dart-Code/out/src/debug/dart_debug_impl.js:679:32)\n at DartDebugSession.dispatchRequest (/Users/ben/Development/Dart-Code/node_modules/vscode-debugadapter/lib/debugSession.js:411:22)\n at DartDebugSession._handleData (/Users/ben/Development/Dart-Code/node_modules/vscode-debugadapter/lib/protocol.js:97:38)\n at Socket.<anonymous> (/Users/ben/Development/Dart-Code/node_modules/vscode-debugadapter/lib/protocol.js:18:44)\n at Socket.emit (events.js:316:20)\n at addChunk (_stream_readable.js:297:12)\n at readableAddChunk (_stream_readable.js:273:9)\n at Socket.Readable.push (_stream_readable.js:214:10)\n at Pipe.onStreamRead (internal/stream_base_commons.js:186:23)"}, 'sendTelemetry': True}}}
2020-03-25 14:27:06,029 - ERROR - Request failed: TypeError: Cannot read property 'data' of undefined
at DartDebugSession.sourceRequest (/Users/ben/Development/Dart-Code/out/src/debug/dart_debug_impl.js:679:32)
at DartDebugSession.dispatchRequest (/Users/ben/Development/Dart-Code/node_modules/vscode-debugadapter/lib/debugSession.js:411:22)
at DartDebugSession._handleData (/Users/ben/Development/Dart-Code/node_modules/vscode-debugadapter/lib/protocol.js:97:38)
at Socket.<anonymous> (/Users/ben/Development/Dart-Code/node_modules/vscode-debugadapter/lib/protocol.js:18:44)
at Socket.emit (events.js:316:20)
at addChunk (_stream_readable.js:297:12)
at readableAddChunk (_stream_readable.js:273:9)
at Socket.Readable.push (_stream_readable.js:214:10)
at Pipe.onStreamRead (internal/stream_base_commons.js:186:23)
That might be my bug. I might be not supplying something on the source
request that i should be
from vimspector.
@puremourning thanks! I found the cwd
issue and think I've fixed it. When there's a cwd we use a relative path to run the script (eg. dart bin/main.dart
) but we just assumed it was always there, rather than just using the full path if it wasn't.
I've pushed a fix for that to master, as well as merging all of the runInTerminalRequest
changes. Let me know if this doesn't work for you (or if you can provide instructions for me to set this up to run locally/in a container, I can debug locally - though I've never used Vim so might need baby steps!).
(sourceRequest)
Request failed: TypeError: Cannot read property 'data' of undefined
Was the sourceReference
that you passed here one that was returned from the debug adapter? If so, this seems like a bug. Can you get a log that includes the response where the sourceReference
came from? What happens here is pretty straight forward - we just dump data into a dictionary and then return the key, and then look it back up later. We do clear that data when we're terminating though, so if this was during shutdown that could explain it (though we should probably handle it more gracefully).
from vimspector.
Was the sourceReference that you passed here one that was returned from the debug adapter?
Yes, absolutely, it would be in response a a stackTrace entry containing that sourceReference
(i don't think there's anywhere else that vimspector resolves sourceReferences to sources).
Unfortunately, i can't repro the exception now, which is irksome.
There's a container image in docker hub puremourning/vimspector:manual
that can be used to run vimspector in a minimal environment. But for now i can't repro it the issue here, so i wouldn't bother if i were you.
from vimspector.
Ok, if you see it again do let me know. I did check the code again, but can't see any obvious route (except during shutdown - though I'm not sure you would've requested source after requesting terminate/disconnect).
Does running in a terminal work ok for you now? (or can you give some basic instructions on what I'd need to do to test this here, starting from running the container above?). Thanks!
from vimspector.
Yep, run in terminal worked (terminal on the right has the stdout).
Instructions to test it out in the container:
cd /some/path
git clone https://github.com/puremourning/vimspector
cd vimspector
git checkout dart
docker pull puremouring/vimspector:manual
cd tests/manual
./run
This should put you in the container
- install dart: https://dart.dev/get-dart
- sudo sh -c 'curl -o- https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -'
- sudo sh -c 'curl -o- https://storage.googleapis.com/download.dartlang.org/linux/debian/dart_stable.list > /etc/apt/sources.list.d/dart_stable.list'
- sudo apt-get update && sudo apt install dart
- (container)
cd vimspector
- (container)
./install.py --force-enable-dart
- (container)
./support/test/run_test_vim support/test/dart/cli/bin/main.dart
That should put you in Vim with main.dart
loaded.
- Set a breakpoint on the first line of
main
by moving the cursor there and pressing<F9>
(hint: pressj
to move the cursor down one line, and press<F9>
to toggle breakpoint) - Start debugging with
<F5>
This should fire everything up and you should see something ugly like this:
It's asking about exception breakpoints, just hit enter a couple of times:
et voilà. Other key shortcuts defined here: https://github.com/puremourning/vimspector#human-mode
It's ugly because the container is really for running the regression tests so it's super minimal.
from vimspector.
Oh! When i start debugging, my computer freeze and i should shut down by hand!
This is latest log file:
https://gist.github.com/LinArcX/75ec9f7dd96b558ed4a6f80efd52424f
from vimspector.
shrug; don't see anything in the vimspector log; again i don't see the initialized
event being sent from the DA .
Does this project work if you use this DA with VScode ?
from vimspector.
@puremourning cool, thanks for testing and for the instructions!
@LinArcX do you mean your whole machine froze? :/
What version of the Dart SDK are you using? You could try including ``"sendLogsToClient": truethat would cause the
dart.log` events for all the Dart VM service traffic to be logged to see if that reveals anything. Otherwise, it may be worth trying to figure out how your project differs from @puremourning's test above (and running in VS Code as suggested).
By the way, this DA was written entirely for VS Code, so there may be some places where we make assumptions (for example, whether line numbers are 1-based or not) that may need fixing up for other clients. If you notice anything not working correctly like that, do raise issues in the Dart-Code repo!
from vimspector.
https://github.com/puremourning/vimspector/wiki/languages
from vimspector.
Hi @puremourning. I have been trying to get vimspector to work with dart/flutter. Initially, I tried out the following .vimspector.json
from your comment earlier on this issue.
I got it to work.
{ "adapters": { "dart-code": { "variables": { "root": "/Users/ben/Development/vimspector/Dart-Code" // change this }, "type": "dart", "command": [ "node", "${root}/out/src/debug/dart_debug_entry.js" ] } }, "configurations": { "Launch": { "adapter": "dart-code", "configuration": { "request": "launch", "type": "dart", "dartPath": "/usr/local/bin/dart", // change this to path to dat "program": "${file}", // change this to the main.dart "cwd": "${workspaceRoot}" } } } }
With this :call vimspector#Launch()
did not do anything. Afterwards, I moved the adapter configuration from .vimspector.json
to .gadgets.json
present in the vimspector plugin directory. Now when I :call vimspector#Launch()
a prompt asks me to enter the value for root. On hitting Esc in the prompt, the plugin brings up the UI interface for debugging. There is a floating window saying: "Intialising debug adapter..." and there is a message: "Channel exit with status 1". The screenshot of these is attached below:
Can anything be done to make this work? Here is the vimspector log output:
2020-11-15 12:18:19,024 - INFO - **** INITIALISING NEW VIMSPECTOR SESSION ****
2020-11-15 12:18:19,024 - INFO - API is: neo
2020-11-15 12:18:19,024 - INFO - VIMSPECTOR_HOME = /home/thesmader/.config/nvim/plugged/vimspector
2020-11-15 12:18:19,026 - INFO - gadgetDir = /home/thesmader/.config/nvim/plugged/vimspector/gadgets/linux
2020-11-15 12:18:36,372 - INFO - User requested start debug session with {}
2020-11-15 12:18:36,376 - DEBUG - Reading configurations from: None
2020-11-15 12:18:36,377 - DEBUG - Reading configurations from: /home/thesmader/dev/riverpod_practice/.vimspector.json
2020-11-15 12:18:36,380 - DEBUG - Reading gadget config: /home/thesmader/.config/nvim/plugged/vimspector/gadgets/linux/.gadgets.json
2020-11-15 12:18:36,384 - DEBUG - Reading gadget config: None
2020-11-15 12:18:39,973 - DEBUG - Value for root not set in ${root}/src/debug/dart_debug_entry.ts (from ${root}/src/debug/dart_debug_entry.ts): set to
2020-11-15 12:18:39,974 - INFO - Configuration: {"adapter": "dart-code", "configuration": {"request": "launch", "type": "flutter", "dartPath": "/home/thesmader/dev/env/flutter/bin/cache/dart-sdk/bin/dart", "program": "/home/thesmader/dev/riverpod_practice/lib/main.dart", "cwd": "/home/thesmader/dev/riverpod_practice"}}
2020-11-15 12:18:39,974 - INFO - Adapter: {"varibales": {"root": "/home/thesmader/dev/env/dartcode"}, "type": "dart", "command": ["node", "/src/debug/dart_debug_entry.ts"]}
2020-11-15 12:18:40,355 - INFO - Starting debug adapter with: {"varibales": {"root": "/home/thesmader/dev/env/dartcode"}, "type": "dart", "command": ["node", "/src/debug/dart_debug_entry.ts"]}
2020-11-15 12:18:40,362 - INFO - Debug Adapter Started
2020-11-15 12:18:40,363 - DEBUG - Sending Message: {"command": "initialize", "arguments": {"adapterID": "adapter", "clientID": "vimspector", "clientName": "vimspector", "linesStartAt1": true, "columnsStartAt1": true, "locale": "en_GB", "pathFormat": "path", "supportsVariableType": true, "supportsVariablePaging": false, "supportsRunInTerminalRequest": true}, "seq": 0, "type": "request"}
2020-11-15 12:18:19,024 - INFO - **** INITIALISING NEW VIMSPECTOR SESSION ****
2020-11-15 12:18:19,024 - INFO - API is: neo
2020-11-15 12:18:19,024 - INFO - VIMSPECTOR_HOME = /home/thesmader/.config/nvim/plugged/vimspector
2020-11-15 12:18:19,026 - INFO - gadgetDir = /home/thesmader/.config/nvim/plugged/vimspector/gadgets/linux
2020-11-15 12:18:36,372 - INFO - User requested start debug session with {}
2020-11-15 12:18:36,376 - DEBUG - Reading configurations from: None
2020-11-15 12:18:36,377 - DEBUG - Reading configurations from: /home/thesmader/dev/riverpod_practice/.vimspector.json
2020-11-15 12:18:36,380 - DEBUG - Reading gadget config: /home/thesmader/.config/nvim/plugged/vimspector/gadgets/linux/.gadgets.json
2020-11-15 12:18:36,384 - DEBUG - Reading gadget config: None
2020-11-15 12:18:39,973 - DEBUG - Value for root not set in ${root}/src/debug/dart_debug_entry.ts (from ${root}/src/debug/dart_debug_entry.ts): set to
2020-11-15 12:18:39,974 - INFO - Configuration: {"adapter": "dart-code", "configuration": {"request": "launch", "type": "flutter", "dartPath": "/home/thesmader/dev/env/flutter/bin/cache/dart-sdk/bin/dart", "program": "/home/thesmader/dev/riverpod_practice/lib/main.dart", "cwd": "/home/thesmader/dev/riverpod_practice"}}
2020-11-15 12:18:39,974 - INFO - Adapter: {"varibales": {"root": "/home/thesmader/dev/env/dartcode"}, "type": "dart", "command": ["node", "/src/debug/dart_debug_entry.ts"]}
2020-11-15 12:18:40,355 - INFO - Starting debug adapter with: {"varibales": {"root": "/home/thesmader/dev/env/dartcode"}, "type": "dart", "command": ["node", "/src/debug/dart_debug_entry.ts"]}
2020-11-15 12:18:40,362 - INFO - Debug Adapter Started
2020-11-15 12:18:40,363 - DEBUG - Sending Message: {"command": "initialize", "arguments": {"adapterID": "adapter", "clientID": "vimspector", "clientName": "vimspector", "linesStartAt1": true, "columnsStartAt1": true, "locale": "en_GB", "pathFormat": "path", "supportsVariableType": true, "supportsVariablePaging": false, "supportsRunInTerminalRequest": true}, "seq": 0, "type": "request"}
2020-11-15 12:18:40,486 - INFO - The server has terminated with status 1
2020-11-15 12:18:40,489 - DEBUG - Closing down: Aborting request {'command': 'initialize', 'arguments': {'adapterID': 'adapter', 'clientID': 'vimspector', 'clientName': 'vimspector', 'linesStartAt1': True, 'columnsStartAt1': True, 'locale': 'en_GB', 'pathFormat': 'path', 'supportsVariableType': True, 'supportsVariablePaging': False, 'supportsRunInTerminalRequest': True}, 'seq': 0, 'type': 'request'}
2020-11-15 12:18:40,490 - INFO - User Msg: Request for initialize aborted: Closing down
2020-11-15 12:18:40,493 - DEBUG - No server exit handler
2020-11-15 12:18:40,486 - INFO - The server has terminated with status 1
2020-11-15 12:18:40,489 - DEBUG - Closing down: Aborting request {'command': 'initialize', 'arguments': {'adapterID': 'adapter', 'clientID': 'vimspector', 'clientName': 'vimspector', 'linesStartAt1': True, 'columnsStartAt1': True, 'locale': 'en_GB', 'pathFormat': 'path', 'supportsVariableType': True, 'supportsVariablePaging': False, 'supportsRunInTerminalRequest': True}, 'seq': 0, 'type': 'request'}
2020-11-15 12:18:40,490 - INFO - User Msg: Request for initialize aborted: Closing down
2020-11-15 12:18:40,493 - DEBUG - No server exit handler
EDIT:
My .gagdgets.json is as follows:
{
"adapters": {
"multi-session": {
"host": "${host}",
"port": "${port}"
},
"vscode-python": {
"command": [
"node",
"${gadgetDir}/vscode-python/out/client/debugger/debugAdapter/main.js"
],
"name": "vscode-python"
},
"dart-code": {
"varibales": {
"root": "/home/thesmader/dev/env/dartcode"
},
"type": "dart",
"command": [
"node",
"${root}/src/debug/dart_debug_entry.ts"
]
}
}
}
.vimspector.json:
{
"configurations": {
"Launch": {
"adapter": "dart-code",
"configuration": {
"request": "launch",
"type": "flutter",
"dartPath": "/home/thesmader/dev/env/flutter/bin/cache/dart-sdk/bin/dart",
"program": "/home/thesmader/dev/riverpod_practice/lib/main.dart",
"cwd": "/home/thesmader/dev/riverpod_practice"
}
}
}
}
from vimspector.
Fix e typo? varibales
from vimspector.
Sorry about that. The typo got introduced some time while moving around stuff. Correcting that fixes the issue of the prompt asking for the value of root. But the rest of the problem with the floating window and the channel exit status persists. Still not able to use the debugger. Here's the vimspector log:
2020-11-15 14:42:37,334 - INFO - **** INITIALISING NEW VIMSPECTOR SESSION ****
2020-11-15 14:42:37,335 - INFO - API is: neo
2020-11-15 14:42:37,335 - INFO - VIMSPECTOR_HOME = /home/thesmader/.config/nvim/plugged/vimspector
2020-11-15 14:42:37,339 - INFO - gadgetDir = /home/thesmader/.config/nvim/plugged/vimspector/gadgets/linux
2020-11-15 14:42:37,343 - INFO - User requested start debug session with {}
2020-11-15 14:42:37,345 - DEBUG - Reading configurations from: None
2020-11-15 14:42:37,345 - DEBUG - Reading configurations from: /home/thesmader/dev/riverpod_practice/.vimspector.json
2020-11-15 14:42:37,346 - DEBUG - Reading gadget config: /home/thesmader/.config/nvim/plugged/vimspector/gadgets/linux/.gadgets.json
2020-11-15 14:42:37,347 - DEBUG - Reading gadget config: None
2020-11-15 14:42:37,347 - INFO - Configuration: {"adapter": "dart-code", "configuration": {"request": "launch", "type": "flutter", "dartPath": "/home/thesmader/dev/env/flutter/bin/cache/dart-sdk/bin/dart", "program": "/home/thesmader/dev/riverpod_practice/lib/main.dart", "cwd": "/home/thesmader/dev/riverpod_practice"}}
2020-11-15 14:42:37,347 - INFO - Adapter: {"variables": {"root": "/home/thesmader/dev/env/dartcode"}, "type": "dart", "command": ["node", "/home/thesmader/dev/env/dartcode/src/debug/dart_debug_entry.ts"]}
2020-11-15 14:42:37,554 - INFO - Starting debug adapter with: {"variables": {"root": "/home/thesmader/dev/env/dartcode"}, "type": "dart", "command": ["node", "/home/thesmader/dev/env/dartcode/src/debug/dart_debug_entry.ts"]}
2020-11-15 14:42:37,562 - INFO - Debug Adapter Started
2020-11-15 14:42:37,563 - DEBUG - Sending Message: {"command": "initialize", "arguments": {"adapterID": "adapter", "clientID": "vimspector", "clientName": "vimspector", "linesStartAt1": true, "columnsStartAt1": true, "locale": "en_GB", "pathFormat": "path", "supportsVariableType": true, "supportsVariablePaging": false, "supportsRunInTerminalRequest": true}, "seq": 0, "type": "request"}
2020-11-15 14:42:37,765 - INFO - The server has terminated with status 1
2020-11-15 14:42:37,774 - DEBUG - Closing down: Aborting request {'command': 'initialize', 'arguments': {'adapterID': 'adapter', 'clientID': 'vimspector', 'clientName': 'vimspector', 'linesStartAt1': True, 'columnsStartAt1': True, 'locale': 'en_GB', 'pathFormat': 'path', 'supportsVariableType': True, 'supportsVariablePaging': False, 'supportsRunInTerminalRequest': True}, 'seq': 0, 'type': 'request'}
2020-11-15 14:42:37,775 - INFO - User Msg: Request for initialize aborted: Closing down
2020-11-15 14:42:37,783 - DEBUG - No server exit handler
from vimspector.
This seems wrong. Shouldn’t it point to a JS file?
/home/thesmader/dev/env/dartcode/src/debug/dart_debug_entry.ts
What happens if you run the command from the command line ?
This adapter is not tested or supported so you’re going to have to work out how to start the adapter and make it work. https://github.com/puremourning/vimspector/wiki/languages I’m willing to help but I don’t have time to do everything sorry
from vimspector.
The debug adapter has changed slightly in recent versions, so if you're using latest code you may need to tweak how you launch it. It's now run like:
node out/dist/debug.js flutter
All of the debug adapters are bundled into debug.js
and the first arg is the name of the debugger to use. If you just run node out/dist/debug.js
it'll print the possible options.
Note: There are some upcoming tweaks to the fields you'll need to pass into launchRequest
, designed to make things a little simpler (for example not needing to pass the SDK version, we'll just take the SDK path and we'll look up the version in the debug adapter):
Those changes are unreleased, though if you're building from source you might have them and need to adjust (if you're using the js extracted from the latest release vsix, it'll be the original variables still).
from vimspector.
@puremourning thanks for pointing that out. I was missing out on the step of building the Dart-Code source. As @DanTup specified in the above comment, I tried to run the debugger from a Flutter project by tweaking the command. According to the logs, it seems that the debugger service does start, but it gets terminated right after. Here's the vimspector log:
2020-11-15 22:05:22,315 - INFO - **** INITIALISING NEW VIMSPECTOR SESSION ****
2020-11-15 22:05:22,315 - INFO - API is: neo
2020-11-15 22:05:22,315 - INFO - VIMSPECTOR_HOME = /home/thesmader/.config/nvim/plugged/vimspector
2020-11-15 22:05:22,319 - INFO - gadgetDir = /home/thesmader/.config/nvim/plugged/vimspector/gadgets/linux
2020-11-15 22:05:35,381 - INFO - User requested start debug session with {}
2020-11-15 22:05:35,386 - DEBUG - Reading configurations from: None
2020-11-15 22:05:35,387 - DEBUG - Reading configurations from: /home/thesmader/dev/riverpod_practice/.vimspector.json
2020-11-15 22:05:35,389 - DEBUG - Reading gadget config: /home/thesmader/.config/nvim/plugged/vimspector/gadgets/linux/.gadgets.json
2020-11-15 22:05:35,392 - DEBUG - Reading gadget config: None
2020-11-15 22:05:35,395 - INFO - Configuration: {"adapter": "dart-code", "configuration": {"request": "launch", "type": "flutter", "dartPath": "/home/thesmader/dev/env/flutter/bin/cache/dart-sdk/bin/dart", "program": "/home/thesmader/dev/riverpod_practice/lib/main.dart", "cwd": "/home/thesmader/dev/riverpod_practice"}}
2020-11-15 22:05:35,396 - INFO - Adapter: {"variables": {"root": "/home/thesmader/dev/env/dartcode"}, "type": "flutter", "command": ["node", "/home/thesmader/dev/env/dartcode/out/dist/debug.js", "flutter"]}
2020-11-15 22:05:35,711 - INFO - Starting debug adapter with: {"variables": {"root": "/home/thesmader/dev/env/dartcode"}, "type": "flutter", "command": ["node", "/home/thesmader/dev/env/dartcode/out/dist/debug.js", "flutter"]}
2020-11-15 22:05:35,715 - INFO - Debug Adapter Started
2020-11-15 22:05:35,716 - DEBUG - Sending Message: {"command": "initialize", "arguments": {"adapterID": "adapter", "clientID": "vimspector", "clientName": "vimspector", "linesStartAt1": true, "columnsStartAt1": true, "locale": "en_GB", "pathFormat": "path", "supportsVariableType": true, "supportsVariablePaging": false, "supportsRunInTerminalRequest": true}, "seq": 0, "type": "request"}
2020-11-15 22:05:22,315 - INFO - **** INITIALISING NEW VIMSPECTOR SESSION ****
2020-11-15 22:05:22,315 - INFO - API is: neo
2020-11-15 22:05:22,315 - INFO - VIMSPECTOR_HOME = /home/thesmader/.config/nvim/plugged/vimspector
2020-11-15 22:05:22,319 - INFO - gadgetDir = /home/thesmader/.config/nvim/plugged/vimspector/gadgets/linux
2020-11-15 22:05:35,381 - INFO - User requested start debug session with {}
2020-11-15 22:05:35,386 - DEBUG - Reading configurations from: None
2020-11-15 22:05:35,387 - DEBUG - Reading configurations from: /home/thesmader/dev/riverpod_practice/.vimspector.json
2020-11-15 22:05:35,389 - DEBUG - Reading gadget config: /home/thesmader/.config/nvim/plugged/vimspector/gadgets/linux/.gadgets.json
2020-11-15 22:05:35,392 - DEBUG - Reading gadget config: None
2020-11-15 22:05:35,395 - INFO - Configuration: {"adapter": "dart-code", "configuration": {"request": "launch", "type": "flutter", "dartPath": "/home/thesmader/dev/env/flutter/bin/cache/dart-sdk/bin/dart", "program": "/home/thesmader/dev/riverpod_practice/lib/main.dart", "cwd": "/home/thesmader/dev/riverpod_practice"}}
2020-11-15 22:05:35,396 - INFO - Adapter: {"variables": {"root": "/home/thesmader/dev/env/dartcode"}, "type": "flutter", "command": ["node", "/home/thesmader/dev/env/dartcode/out/dist/debug.js", "flutter"]}
2020-11-15 22:05:35,711 - INFO - Starting debug adapter with: {"variables": {"root": "/home/thesmader/dev/env/dartcode"}, "type": "flutter", "command": ["node", "/home/thesmader/dev/env/dartcode/out/dist/debug.js", "flutter"]}
2020-11-15 22:05:35,715 - INFO - Debug Adapter Started
2020-11-15 22:05:35,716 - DEBUG - Sending Message: {"command": "initialize", "arguments": {"adapterID": "adapter", "clientID": "vimspector", "clientName": "vimspector", "linesStartAt1": true, "columnsStartAt1": true, "locale": "en_GB", "pathFormat": "path", "supportsVariableType": true, "supportsVariablePaging": false, "supportsRunInTerminalRequest": true}, "seq": 0, "type": "request"}
2020-11-15 22:05:35,841 - DEBUG - Message received: {'seq': 1, 'type': 'response', 'request_seq': 0, 'command': 'initialize', 'success': True, 'body': {'supportsRestartRequest': True, 'supportsConfigurationDoneRequest': True, 'supportsEvaluateForHovers': True, 'supportsDelayedStackTraceLoading': True, 'supportsConditionalBreakpoints': True, 'supportsLogPoints': True, 'supportsTerminateRequest': True, 'supportsRestartFrame': True, 'supportsClipboardContext': True, 'exceptionBreakpointFilters': [{'filter': 'All', 'label': 'All Exceptions', 'default': False}, {'filter': 'Unhandled', 'label': 'Uncaught Exceptions', 'default': True}]}}
2020-11-15 22:05:35,842 - DEBUG - LAUNCH!
2020-11-15 22:05:35,842 - DEBUG - Sending Message: {"command": "launch", "arguments": {"request": "launch", "type": "flutter", "dartPath": "/home/thesmader/dev/env/flutter/bin/cache/dart-sdk/bin/dart", "program": "/home/thesmader/dev/riverpod_practice/lib/main.dart", "cwd": "/home/thesmader/dev/riverpod_practice", "name": "test"}, "seq": 1, "type": "request"}
2020-11-15 22:05:35,841 - DEBUG - Message received: {'seq': 1, 'type': 'response', 'request_seq': 0, 'command': 'initialize', 'success': True, 'body': {'supportsRestartRequest': True, 'supportsConfigurationDoneRequest': True, 'supportsEvaluateForHovers': True, 'supportsDelayedStackTraceLoading': True, 'supportsConditionalBreakpoints': True, 'supportsLogPoints': True, 'supportsTerminateRequest': True, 'supportsRestartFrame': True, 'supportsClipboardContext': True, 'exceptionBreakpointFilters': [{'filter': 'All', 'label': 'All Exceptions', 'default': False}, {'filter': 'Unhandled', 'label': 'Uncaught Exceptions', 'default': True}]}}
2020-11-15 22:05:35,842 - DEBUG - LAUNCH!
2020-11-15 22:05:35,842 - DEBUG - Sending Message: {"command": "launch", "arguments": {"request": "launch", "type": "flutter", "dartPath": "/home/thesmader/dev/env/flutter/bin/cache/dart-sdk/bin/dart", "program": "/home/thesmader/dev/riverpod_practice/lib/main.dart", "cwd": "/home/thesmader/dev/riverpod_practice", "name": "test"}, "seq": 1, "type": "request"}
2020-11-15 22:05:35,847 - DEBUG - Message received: {'seq': 2, 'type': 'event', 'event': 'output', 'body': {'category': 'console', 'output': 'Unable to restart debugging. Please try ending the debug session and starting again.\n'}}
2020-11-15 22:05:35,852 - DEBUG - Message received: {'seq': 3, 'type': 'event', 'event': 'terminated'}
2020-11-15 22:05:35,852 - INFO - User Msg: Debugging was terminated by the server.
2020-11-15 22:05:35,847 - DEBUG - Message received: {'seq': 2, 'type': 'event', 'event': 'output', 'body': {'category': 'console', 'output': 'Unable to restart debugging. Please try ending the debug session and starting again.\n'}}
2020-11-15 22:05:35,852 - DEBUG - Message received: {'seq': 3, 'type': 'event', 'event': 'terminated'}
2020-11-15 22:05:35,852 - INFO - User Msg: Debugging was terminated by the server.
2020-11-15 22:05:50,845 - DEBUG - Timeout: Aborting request {'command': 'launch', 'arguments': {'request': 'launch', 'type': 'flutter', 'dartPath': '/home/thesmader/dev/env/flutter/bin/cache/dart-sdk/bin/dart', 'program': '/home/thesmader/dev/riverpod_practice/lib/main.dart', 'cwd': '/home/thesmader/dev/riverpod_practice', 'name': 'test'}, 'seq': 1, 'type': 'request'}
2020-11-15 22:05:50,845 - DEBUG - Timeout: Aborting request {'command': 'launch', 'arguments': {'request': 'launch', 'type': 'flutter', 'dartPath': '/home/thesmader/dev/env/flutter/bin/cache/dart-sdk/bin/dart', 'program': '/home/thesmader/dev/riverpod_practice/lib/main.dart', 'cwd': '/home/thesmader/dev/riverpod_practice', 'name': 'test'}, 'seq': 1, 'type': 'request'}
.gadgets.json:
{
"adapters": {
"multi-session": {
"host": "${host}",
"port": "${port}"
},
"vscode-python": {
"command": [
"node",
"${gadgetDir}/vscode-python/out/client/debugger/debugAdapter/main.js"
],
"name": "vscode-python"
},
"dart-code": {
"variables": {
"root": "/home/thesmader/dev/env/dartcode"
},
"type": "flutter",
"command": [
"node",
"${root}/out/dist/debug.js",
"flutter"
]
}
}
}
.vimspector.json
{
"configurations": {
"Launch": {
"adapter": "dart-code",
"configuration": {
"request": "launch",
"type": "flutter",
"dartPath": "/home/thesmader/dev/env/flutter/bin/cache/dart-sdk/bin/dart",
"program": "/home/thesmader/dev/riverpod_practice/lib/main.dart",
"cwd": "/home/thesmader/dev/riverpod_practice"
}
}
}
}
Do I need to include anything more in my configurations? Pardon me if there are any mistakes. Anything to guide me in the correct way would help.
from vimspector.
Thanks, @Thesmader, I was also able to get the debugger running with your config!
from vimspector.
Anyone fancy updating https://github.com/puremourning/vimspector/wiki/languages ?
from vimspector.
I'll do it tonight 😄.
from vimspector.
Added instructions for Dart & Flutter to the wiki:
https://github.com/puremourning/vimspector/wiki/languages#dart--flutter
from vimspector.
So glad to see this working so well! Is there a way to support hot reloading while debugging? I tried typing r into the console but that doesn't seem to work. Really glad to see this overall!
Edit:
looking at the dartcode documentation this is an option available, but setting inside my configuration doesn't seem to make any difference. I'm not familiar with vimspector's architecture so I may be setting something wrong 😅. Are the options within dartcode supported?
from vimspector.
@puremourning btw, I can't comment on #434 because it's locked, but hot reload is available via the DAP (both old and new) via a custom request. If you can't get this working, please let me know :-)
from vimspector.
There's almost zero chance that vimspector will support dart's protocol customisations, sorry. Vimspector is a DAP client, and does not have language/extension specific code (with the regrettable exception of hot code reload for java).
Vimspector will also not be able to support the hot reload request unless the server sends an event to say that it should, like the java debugger does. Vimspector does not - cannot - watch for changes and know when a reload is necessary.
I see no reason why vimspector can't support the dart debug-adapter
mode however. This should be trivial, assuming that the basic protocol stuff is sufficient without the custom stuff.
from vimspector.
https://github.com/puremourning/vimspector/wiki/languages#dart--flutter
it seems that community has contributed working config for this, so there's not much for me to do in vimspector. I'm unlikely to include this in the core supported servers unless someone contributes that from the community and volunteers to maintain it.
from vimspector.
Related Issues (20)
- Python terminals buffers are not closed after exiting Vimspector HOT 6
- args not passed to debugger HOT 1
- [Feature Request] Restore cursor position when toggling in/out of breakpoints window HOT 1
- [Feature Request]: Does vimspector support debug c++ programs with coredump files? HOT 1
- Cannot install debugpy gadget: Checksum does not match expected HOT 5
- Vimspector Will Not Start with vscode-js-debug Adapter. HOT 6
- Can't expand a watch variable after 'restart' command HOT 3
- vimspectorRunToCursor and vimspectorGoToCurrentLine HOT 1
- netcoredbg: macos arm64 archive contains x86_64 build HOT 2
- Virtual env `bin/python` buffer remains open after `:VimspectorReset` HOT 8
- [Feature Request]: Deprecate and remove 'tarball' install
- [Nvim Install without GUI] python3/vimspector/installer.py report room HOT 2
- vimspector#Launch() fails with Invalid Option Name "winbar" HOT 2
- [Feature Request]: Do not open source file if the file does not exists HOT 2
- Variables in nested block scopes not displaying as expected HOT 4
- [Feature Request]: Ability to debug "as root" HOT 2
- Vimspector Launch server timout
- What about a platformio integration? HOT 1
- RunToCursor mapping is missing for s:mappings == VISUALSTUDIO HOT 2
- windows neovim cannot add watch variable (error at self.expression[ 'frameId' ] = frame[ 'id' ]) HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vimspector.