golang / vscode-go

Go extension for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=golang.Go
Other
3.79k stars 729 forks source link

Improve automated path mapping in dlv debug adapter #3193

Open suzmue opened 4 months ago

suzmue commented 4 months ago

Is your feature request related to a problem? Please describe.

The legacy debug adapter implemented some support for automatic path mapping (#45). We want to deprecate the legacy debug adapter so should provide some automatic path mapping, which will likely take a different form than the legacy.

dlv dap uses the substitutePath setting in the launch.json attributes to configure mappings when the local and debugger paths do not match (such as with symlinked dirs, remote debugging, trimpath).

A lot of times users don’t know that they have to provide path mapping for the breakpoints to hit. Even if they do, they don’t provide the correct path mappings. So what happens is that the debugger appears to be running but no breakpoints are hit. This can cause a lot of confusion to the users.

Describe the solution you'd like We can use the local configuration of the main modules, module cache, and GOROOT, to help automate this configuration.

This will need implementation work in github.com/go-delve/delve to do the mapping and modifications to the extension to provide the necessary data from the client.

Additional context Related issues include #3175, #45

gm0stache commented 3 months ago

-> related? https://github.com/golang/vscode-go/issues/3096

hyangah commented 3 months ago

@suzmue Things seem complicated if Windows or case-insensitive OS is involved, since VS Code (DAP client) uses the absolute file paths instead of file uri or relative paths. In this case, I think we need more than Delve's substitutePath.