-
Notifications
You must be signed in to change notification settings - Fork 764
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
debug: hard to debug a binary built with -trimpath #1985
Comments
@suzmue @polinasok This may affect blaze users and google internal binary debugging. |
Related discussion in go-delve/delve#2754 |
I think this is a better place for it, so I'm copying my comment from #2609. Capitalization is another potential pitfall. The project I am working on has a dependency with a capitalized name in the path. With |
In fa820d4, we document a strategy for constructing substitution paths, namely: "substitutePath": [
// Main module.
{
"from": "${workspaceFolder}",
"to": "moduleName",
},
// Module cache paths.
{
"from": "${env:HOME}/go/pkg/mod/github.com",
"to": "github.com",
},
{
"from": "${env:HOME}/go/pkg/mod/golang.org",
"to": "golang.org",
},
...
// Standard library paths.
// This rule should come last since the empty "to" will match every path.
{ "from": "/path/to/local/goroot/pkg" , "to": ""}
], I use a different strategy. My main module depends on many modules in the cache, and this set of modules changes over time. The standard library packages, on the other hand, are relatively stable. I wanted to avoid enumerating the modules in the cache, so instead I enumerated the standard library packages. Because the standard library packages have no prefix (e.g. just "substitutePath": [
// Main module, built with -trimpath
{
"from": "${workspaceFolder}",
"to": "moduleName",
},
// Packages in GOROOT (standard library)
{
"from": "/home/myuser/.local/go/1.20.1/src/archive",
"to": "archive"
},
// ... Other entries omitted to save space ...
{
"from": "/home/myuser/.local/go/1.20.1/src/vendor",
"to": "vendor"
},
// Modules in GOMODCACHE
{
"from": "/home/myuser/.local/go/pkg/mod",
"to": "",
},
] While I find my strategy easier to use manually, I think would be easier to automatically generate substitutions for modules in the module cache. We would still need to generate one substitution for the standard library packages, and for that we would need (a) the go version of the executable (available as metadata in the executable), and (b) the path to the |
go version: go1.18beta1 (but the problem applies to older versions of go too)
dlv version: 2f13672765fe
When a binary is built with
-trimpath
, part of file paths are removed from the debug info.It is recommended to configure
substitutePath
to handle this.But, it is challenging to come up with good substitutePath rules since
-trimpath
produces file paths in the form of:e.g.:
runtime/map.go
e.g.:
golang.org/x/mod@v0.5.1/semver/semver.go
(this can be interpreted as a path relative to MODCACHE)e.g:
work/main.go
(when the main module's name iswork
)More complication:
-> original
module@version/package/path/file.go
is used instead of file path in vendor or replace directoryRepro:
Launch configuration
Delve DAP log
The text was updated successfully, but these errors were encountered: