aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/vendor/github.com/google/pprof/internal/driver
diff options
context:
space:
mode:
authorRaul Silvera <rsilvera@google.com>2017-02-28 16:07:36 -0800
committerBrad Fitzpatrick <bradfitz@golang.org>2017-03-01 00:23:37 +0000
commitac4a86523c2521555b9ea104157fcc8cf5ce79f5 (patch)
treec4ccc95fd3f2775b6c851ed4125faeb0681747bc /src/cmd/vendor/github.com/google/pprof/internal/driver
parentbca0320641000d842341637f22f140c262adb360 (diff)
downloadgo-ac4a86523c2521555b9ea104157fcc8cf5ce79f5.tar.xz
cmd/vendor/github.com/google/pprof: refresh from upstream
Updating to commit e41fb7133e7ebb84ba6af2f6443032c728db26d3 from github.com/google/pprof This fixes #19322 Change-Id: Ia1c008a09f46ed19ef176046e38868eacb715682 Reviewed-on: https://go-review.googlesource.com/37617 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/cmd/vendor/github.com/google/pprof/internal/driver')
-rw-r--r--src/cmd/vendor/github.com/google/pprof/internal/driver/cli.go3
-rw-r--r--src/cmd/vendor/github.com/google/pprof/internal/driver/fetch.go25
-rw-r--r--src/cmd/vendor/github.com/google/pprof/internal/driver/fetch_test.go3
-rw-r--r--src/cmd/vendor/github.com/google/pprof/internal/driver/options.go2
4 files changed, 26 insertions, 7 deletions
diff --git a/src/cmd/vendor/github.com/google/pprof/internal/driver/cli.go b/src/cmd/vendor/github.com/google/pprof/internal/driver/cli.go
index 093cdbbe04..0005ead70b 100644
--- a/src/cmd/vendor/github.com/google/pprof/internal/driver/cli.go
+++ b/src/cmd/vendor/github.com/google/pprof/internal/driver/cli.go
@@ -268,4 +268,5 @@ var usageMsgVars = "\n\n" +
" PPROF_TOOLS Search path for object-level tools\n" +
" PPROF_BINARY_PATH Search path for local binary files\n" +
" default: $HOME/pprof/binaries\n" +
- " finds binaries by $name and $buildid/$name\n"
+ " finds binaries by $name and $buildid/$name\n" +
+ " * On Windows, %USERPROFILE% is used instead of $HOME"
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 9c6acc0ec9..f9e8231419 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
@@ -25,6 +25,7 @@ import (
"os"
"os/exec"
"path/filepath"
+ "runtime"
"strconv"
"strings"
"sync"
@@ -214,13 +215,24 @@ type profileSource struct {
err error
}
+func homeEnv() string {
+ switch runtime.GOOS {
+ case "windows":
+ return "USERPROFILE"
+ case "plan9":
+ return "home"
+ default:
+ return "HOME"
+ }
+}
+
// setTmpDir prepares the directory to use to save profiles retrieved
// remotely. It is selected from PPROF_TMPDIR, defaults to $HOME/pprof.
func setTmpDir(ui plugin.UI) (string, error) {
if profileDir := os.Getenv("PPROF_TMPDIR"); profileDir != "" {
return profileDir, nil
}
- for _, tmpDir := range []string{os.Getenv("HOME") + "/pprof", os.TempDir()} {
+ for _, tmpDir := range []string{os.Getenv(homeEnv()) + "/pprof", os.TempDir()} {
if err := os.MkdirAll(tmpDir, 0755); err != nil {
ui.PrintErr("Could not use temp dir ", tmpDir, ": ", err.Error())
continue
@@ -315,7 +327,7 @@ func locateBinaries(p *profile.Profile, s *source, obj plugin.ObjTool, ui plugin
searchPath := os.Getenv("PPROF_BINARY_PATH")
if searchPath == "" {
// Use $HOME/pprof/binaries as default directory for local symbolization binaries
- searchPath = filepath.Join(os.Getenv("HOME"), "pprof", "binaries")
+ searchPath = filepath.Join(os.Getenv(homeEnv()), "pprof", "binaries")
}
mapping:
for _, m := range p.Mapping {
@@ -332,8 +344,13 @@ mapping:
fileNames = append(fileNames, matches...)
}
}
- if baseName != "" {
- fileNames = append(fileNames, filepath.Join(path, baseName))
+ 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))
}
for _, name := range fileNames {
if f, err := obj.Open(name, m.Start, m.Limit, m.Offset); err == nil {
diff --git a/src/cmd/vendor/github.com/google/pprof/internal/driver/fetch_test.go b/src/cmd/vendor/github.com/google/pprof/internal/driver/fetch_test.go
index f03f28417a..e592b77cc8 100644
--- a/src/cmd/vendor/github.com/google/pprof/internal/driver/fetch_test.go
+++ b/src/cmd/vendor/github.com/google/pprof/internal/driver/fetch_test.go
@@ -57,6 +57,7 @@ func TestSymbolizationPath(t *testing.T) {
}{
{"", "/usr/bin/binary", "", "/usr/bin/binary", 0},
{"", "/usr/bin/binary", "fedcb10000", "/usr/bin/binary", 0},
+ {"/usr", "/bin/binary", "", "/usr/bin/binary", 0},
{"", "/prod/path/binary", "abcde10001", filepath.Join(tempdir, "pprof/binaries/abcde10001/binary"), 0},
{"/alternate/architecture", "/usr/bin/binary", "", "/alternate/architecture/binary", 0},
{"/alternate/architecture", "/usr/bin/binary", "abcde10001", "/alternate/architecture/binary", 0},
@@ -104,7 +105,7 @@ func TestCollectMappingSources(t *testing.T) {
}
got := collectMappingSources(p, url)
if !reflect.DeepEqual(got, tc.want) {
- t.Errorf("%s:%s, want %s, got %s", tc.file, tc.buildID, tc.want, got)
+ t.Errorf("%s:%s, want %v, got %v", tc.file, tc.buildID, tc.want, got)
}
}
}
diff --git a/src/cmd/vendor/github.com/google/pprof/internal/driver/options.go b/src/cmd/vendor/github.com/google/pprof/internal/driver/options.go
index 73681d2823..cb20e948b4 100644
--- a/src/cmd/vendor/github.com/google/pprof/internal/driver/options.go
+++ b/src/cmd/vendor/github.com/google/pprof/internal/driver/options.go
@@ -47,7 +47,7 @@ func setDefaults(o *plugin.Options) *plugin.Options {
d.UI = &stdUI{r: bufio.NewReader(os.Stdin)}
}
if d.Sym == nil {
- d.Sym = &symbolizer.Symbolizer{d.Obj, d.UI}
+ d.Sym = &symbolizer.Symbolizer{Obj: d.Obj, UI: d.UI}
}
return d
}