microsoft / debug-adapter-protocol

Defines a common protocol for debug adapters.
https://microsoft.github.io/debug-adapter-protocol/
Other
1.43k stars 131 forks source link

Allow hinting `DebugProtocol.Source` to prefer `path` over `sourceReference` #224

Open SchoofsKelvin opened 3 years ago

SchoofsKelvin commented 3 years ago

It'd be nice if a new field (e.g. preference) gets added to DebugProtocol.Source to tell clients (IDEs) that if the Source can be mapped to a file, it should open that file instead of using sourceReference. Perhaps it's even worth making this the default, especially when combined with my item of checknotes below.

Details

This is mostly a big quality-of-life improvement towards IDE users, as these would now prefer the actual source files over cached versions provided by the debug adapter, assuming they're the same (using checksums). While the file content will be the exact same, mapping to an editable source file or mapping to a read-only "debug content file" is quite a large difference.

Hotreload example

Since this would still allow different Sources with the same path but a different sourceReference/checksums (and the IDE automatically picking between showing the path file or the read-only sourceReference viewer), we can also easily allow debug adapters to differentiate different versions of the same (path-specified) file, e.g. because of hotreloading:

Of course, this hotreload example is an advanced use case this change would allow. Just the QoL improvement to open the true (editable) source file instead of a snapshot if possible is already a very nice use case this allows.

DanTup commented 9 months ago

I found this issue while trying to find out how checksums worked. There's not much info in the spec about it ("The checksums associated with this file.") or what the client should do.

I'm interested in something like the above.. in particular I'd like to have VS Code use sources from disk when they match what's in the runtime (because if we download from the VM, the user sees two copies of the same file and has two sets of breakpoints and it's not clear why), but use downloaded source if they don't match (although this raises some questions about breakpoints).

I can't any mention in the VS Code API docs about checksums.

@weinand is it possible to implement anything at all like this today (for example just avoiding confusion from sources on disk not matching what's in the runtime)?

int19h commented 9 months ago

It would be nice to have it. We've hit similar issues with Python debugging, so now there's logic in place there to report "path" only even when source is actually retrievable. It would be nice to be able to report both and let the client decide smartly on which one is the most appropriate.

fbrosseau commented 9 months ago

I also had a related perspective on this:

189

Also related #407

Bramwelian commented 9 months ago

It is nice for debugging. Bring it on