aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/vendor/github.com/google/pprof/internal/driver/fetch.go
diff options
context:
space:
mode:
authorDmitri Shuralyov <dmitshur@golang.org>2023-08-15 11:45:57 -0400
committerGopher Robot <gobot@golang.org>2023-08-15 16:39:48 +0000
commit4d2855b55d8feb56eebc1fffb82c26b2ffc937b4 (patch)
tree44255974ff88b74c45637b25151d6e98fd1534f2 /src/cmd/vendor/github.com/google/pprof/internal/driver/fetch.go
parent1e245d21b8ec0a4afb459b6f146cbc0c47f5cb24 (diff)
downloadgo-4d2855b55d8feb56eebc1fffb82c26b2ffc937b4.tar.xz
cmd/pprof: update vendored github.com/google/pprof
Pull in the latest published version of github.com/google/pprof as part of the continuous process of keeping Go's dependencies up to date. Done with: go get github.com/google/pprof go mod tidy go mod vendor For #36905. Change-Id: I2a48e912712bc916c9d749acb1550682f919477e Reviewed-on: https://go-review.googlesource.com/c/go/+/519657 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Russ Cox <rsc@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Diffstat (limited to 'src/cmd/vendor/github.com/google/pprof/internal/driver/fetch.go')
-rw-r--r--src/cmd/vendor/github.com/google/pprof/internal/driver/fetch.go28
1 files changed, 19 insertions, 9 deletions
diff --git a/src/cmd/vendor/github.com/google/pprof/internal/driver/fetch.go b/src/cmd/vendor/github.com/google/pprof/internal/driver/fetch.go
index 5ddee33610..584c5d85e0 100644
--- a/src/cmd/vendor/github.com/google/pprof/internal/driver/fetch.go
+++ b/src/cmd/vendor/github.com/google/pprof/internal/driver/fetch.go
@@ -389,7 +389,7 @@ func collectMappingSources(p *profile.Profile, source string) plugin.MappingSour
// set to the remote source URL by collectMappingSources back to empty string.
func unsourceMappings(p *profile.Profile) {
for _, m := range p.Mapping {
- if m.BuildID == "" {
+ if m.BuildID == "" && filepath.VolumeName(m.File) == "" {
if u, err := url.Parse(m.File); err == nil && u.IsAbs() {
m.File = ""
}
@@ -408,9 +408,13 @@ func locateBinaries(p *profile.Profile, s *source, obj plugin.ObjTool, ui plugin
}
mapping:
for _, m := range p.Mapping {
+ var noVolumeFile string
var baseName string
+ var dirName string
if m.File != "" {
+ noVolumeFile = strings.TrimPrefix(m.File, filepath.VolumeName(m.File))
baseName = filepath.Base(m.File)
+ dirName = filepath.Dir(noVolumeFile)
}
for _, path := range filepath.SplitList(searchPath) {
@@ -420,7 +424,7 @@ mapping:
if matches, err := filepath.Glob(filepath.Join(path, m.BuildID, "*")); err == nil {
fileNames = append(fileNames, matches...)
}
- fileNames = append(fileNames, filepath.Join(path, m.File, m.BuildID)) // perf path format
+ fileNames = append(fileNames, filepath.Join(path, noVolumeFile, m.BuildID)) // perf path format
// Llvm buildid protocol: the first two characters of the build id
// are used as directory, and the remaining part is in the filename.
// e.g. `/ab/cdef0123456.debug`
@@ -429,10 +433,13 @@ mapping:
if m.File != "" {
// Try both the basename and the full path, to support the same directory
// structure as the perf symfs option.
- if baseName != "" {
- fileNames = append(fileNames, filepath.Join(path, baseName))
- }
- fileNames = append(fileNames, filepath.Join(path, m.File))
+ fileNames = append(fileNames, filepath.Join(path, baseName))
+ fileNames = append(fileNames, filepath.Join(path, noVolumeFile))
+ // Other locations: use the same search paths as GDB, according to
+ // https://sourceware.org/gdb/onlinedocs/gdb/Separate-Debug-Files.html
+ fileNames = append(fileNames, filepath.Join(path, noVolumeFile+".debug"))
+ fileNames = append(fileNames, filepath.Join(path, dirName, ".debug", baseName+".debug"))
+ fileNames = append(fileNames, filepath.Join(path, "usr", "lib", "debug", dirName, baseName+".debug"))
}
for _, name := range fileNames {
if f, err := obj.Open(name, m.Start, m.Limit, m.Offset, m.KernelRelocationSymbol); err == nil {
@@ -461,8 +468,8 @@ mapping:
l.Mapping = m
}
}
- // Replace executable filename/buildID with the overrides from source.
- // Assumes the executable is the first Mapping entry.
+ // If configured, apply executable filename override and (maybe, see below)
+ // build ID override from source. Assume the executable is the first mapping.
if execName, buildID := s.ExecName, s.BuildID; execName != "" || buildID != "" {
m := p.Mapping[0]
if execName != "" {
@@ -470,7 +477,10 @@ mapping:
// the source override is most likely missing it.
m.File = execName
}
- if buildID != "" {
+ // Only apply the build ID override if the build ID in the main mapping is
+ // missing. Overwriting the build ID in case it's present is very likely a
+ // wrong thing to do so we refuse to do that.
+ if buildID != "" && m.BuildID == "" {
m.BuildID = buildID
}
}