delve: VS Code DAP does not map trimmed paths
- What version of Delve are you using (
dlv version)?
❯ dlv version
Delve Debugger
Version: 1.7.2
Build: $Id: 5b6f24e7fbcad3fe3bc574d3763b2f20afa1d6a1 $
- What version of Go are you using? (
go version)?
go version go1.16.4 linux/amd64
- What operating system and processor architecture are you using?
Windows 10 on x86_64 but running inside of WSL2 via VS Code’s remote extension
- What did you do?
Ran a go binary under delve via VS Code’s debugging pane/tooling with the Go extension installed. I stopped the execution of the program, and then clicked on a thread within the call stack frame. That opened up the call stack, and then I clicked on a particular stack frame.
- What did you expect to see?
I expected to see the source code of the file containing the function for the stack frame that I clicked on.
- What did you see instead?
A new source window in VS Code with the correct filename, but the contents were an error message from VS Code/delve:
Could not load source 'src/common/retryer/retry.go': Unsupported command: cannot process "source" request.
Here is a sanitized version of the trace from VS Code of the DAP communication:
[Trace - 08:39:49.662] client -> {"command":"scopes","arguments":{"frameId":1021},"type":"request","seq":15}
[Trace - 08:39:49.666] client <- {"seq":0,"type":"response","request_seq":15,"success":true,"command":"scopes","body":{"scopes":[{"name":"Locals (warning: optimized function)","variablesReference":1005,"expensive":false,"source":{}}]}}
[Trace - 08:39:49.722] client -> {"command":"variables","arguments":{"variablesReference":1005},"type":"request","seq":16}
[Trace - 08:39:49.725] client <- {"seq":0,"type":"response","request_seq":16,"success":true,"command":"variables","body":{"variables" <snipped>
[Trace - 08:45:19.434] client -> {"command":"source","arguments":{"sourceReference":0,"source":{"name":"retry.go","path":"src/common/retryer/retry.go"}},"type":"request","seq":17}
[Trace - 08:45:19.436] client <- {"seq":0,"type":"response","request_seq":17,"success":false,"command":"source","message":"Unsupported command","body":{"error":{"id":9999,"format":"Unsupported command: cannot process \"source\" request","showUser":false}}}
I’m not familiar with the delve codebase, but I believe the issue is here in the dap server code. It is responding with an unsupported error to all source requests. Curiously, the comment mentions that this command doesn’t make sense for Go since strings cannot be eval’d at runtime, but the DAP Source Request is not asking for code/commands to be source’d but instead for the debugger to return a particular piece of source code.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 19 (8 by maintainers)
I would suggest adding
{"/home/sherbein/Repositories/nuc/src/": "src/"}to your"substitutePath"configuration, to see if that helps with displaying the correct source. The path that delve is sending back is “src/common/retryer/retryer.go” and assuming that the file you have locally is at “/home/sherbein/Repositories/nuc/src/common/retryer/retryer.go” this should help map it.