]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/vendor/github.com/google/pprof: refresh from upstream
authorRaul Silvera <rsilvera@google.com>
Wed, 1 Mar 2017 00:07:36 +0000 (16:07 -0800)
committerBrad Fitzpatrick <bradfitz@golang.org>
Wed, 1 Mar 2017 00:23:37 +0000 (00:23 +0000)
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>

14 files changed:
src/cmd/vendor/github.com/google/pprof/doc/pprof.md
src/cmd/vendor/github.com/google/pprof/driver/driver.go
src/cmd/vendor/github.com/google/pprof/internal/binutils/addr2liner.go
src/cmd/vendor/github.com/google/pprof/internal/binutils/addr2liner_llvm.go
src/cmd/vendor/github.com/google/pprof/internal/binutils/binutils_test.go
src/cmd/vendor/github.com/google/pprof/internal/binutils/disasm.go
src/cmd/vendor/github.com/google/pprof/internal/binutils/disasm_test.go
src/cmd/vendor/github.com/google/pprof/internal/driver/cli.go
src/cmd/vendor/github.com/google/pprof/internal/driver/fetch.go
src/cmd/vendor/github.com/google/pprof/internal/driver/fetch_test.go
src/cmd/vendor/github.com/google/pprof/internal/driver/options.go
src/cmd/vendor/github.com/google/pprof/internal/report/report_test.go
src/cmd/vendor/github.com/google/pprof/internal/symbolizer/symbolizer_test.go
src/cmd/vendor/vendor.json

index e5340f05c2ba604c58e1425e3dfcbf9612b9c57b..d2c7e26e311875cf5055bf1de9fd4477037ef4b2 100644 (file)
@@ -84,7 +84,7 @@ pprof text reports show the location hierarchy in text format.
 
 * **-text:** Prints the location entries, one per line, including the flat and cum
   values.
-* **-tree:** Prints each location entry with its predecessors and successors. 
+* **-tree:** Prints each location entry with its predecessors and successors.
 * **-peek= _regex_:** Print the location entry with all its predecessors and
   successors, without trimming any entries.
 * **-traces:** Prints each sample with a location per line.
@@ -120,9 +120,10 @@ profile must contain data with the appropriate level of detail.
 
 pprof will look for source files on its current working directory and all its
 ancestors. pprof will look for binaries on the directories specified in the
-`$PPROF_BINARY_PATH` environment variable, by default `$HOME/pprof/binaries`. It
-will look binaries up by name, and if the profile includes linker build ids, it
-will also search for them in a directory named as the build id.
+`$PPROF_BINARY_PATH` environment variable, by default `$HOME/pprof/binaries`
+(`%USERPROFILE%\pprof\binaries` on Windows). It will look binaries up by name,
+and if the profile includes linker build ids, it will also search for them in
+a directory named as the build id.
 
 pprof uses the binutils tools to examine and disassemble the binaries. By
 default it will search for those tools in the current path, but it can also
index 82c2e2a7cd488aeec20b755e45bc9069479741a1..d01d0fa344003d9e85a56515cd8c08205309cb55 100644 (file)
@@ -42,12 +42,12 @@ func (o *Options) InternalOptions() *plugin.Options {
                sym = &internalSymbolizer{o.Sym}
        }
        return &plugin.Options{
-               o.Writer,
-               o.Flagset,
-               o.Fetch,
-               sym,
-               obj,
-               o.UI,
+               Writer:  o.Writer,
+               Flagset: o.Flagset,
+               Fetch:   o.Fetch,
+               Sym:     sym,
+               Obj:     obj,
+               UI:      o.UI,
        }
 }
 
index 6b9e6abb22f7c39457c0bd01d67dcdc5433a3398..e3a7777253a2b3ff168bff2c3996db122cee740d 100644 (file)
@@ -164,7 +164,10 @@ func (d *addr2Liner) readFrame() (plugin.Frame, bool) {
                }
        }
 
-       return plugin.Frame{funcname, fileline, linenumber}, false
+       return plugin.Frame{
+               Func: funcname,
+               File: fileline,
+               Line: linenumber}, false
 }
 
 // addrInfo returns the stack frame information for a specific program
index 17ff5fd836b574142af11df6dc598378cb1634ed..7692b0a5cb252da39b0bc5a55a5b25f89dc12608 100644 (file)
@@ -121,7 +121,7 @@ func (d *llvmSymbolizer) readFrame() (plugin.Frame, bool) {
 
        fileline, err := d.readString()
        if err != nil {
-               return plugin.Frame{funcname, "", 0}, true
+               return plugin.Frame{Func: funcname}, true
        }
 
        linenumber := 0
@@ -144,7 +144,7 @@ func (d *llvmSymbolizer) readFrame() (plugin.Frame, bool) {
                }
        }
 
-       return plugin.Frame{funcname, fileline, linenumber}, false
+       return plugin.Frame{Func: funcname, File: fileline, Line: linenumber}, false
 }
 
 // addrInfo returns the stack frame information for a specific program
index b7190e7ae253a5c06a7985c6cc1396460c61d84c..b0ba5f67a86663fba74c19976923600c616bea71 100644 (file)
@@ -49,7 +49,7 @@ func TestAddr2Liner(t *testing.T) {
                }
                for l, f := range s {
                        level := (len(s) - l) * 1000
-                       want := plugin.Frame{functionName(level), fmt.Sprintf("file%d", level), level}
+                       want := plugin.Frame{Func: functionName(level), File: fmt.Sprintf("file%d", level), Line: level}
 
                        if f != want {
                                t.Errorf("AddrInfo(%#x)[%d]: = %+v, want %+v", addr, l, f, want)
index fcdc555dc14242902cf22a377b7d93e27876bda6..1a3b6f8d6aec278b050d62fc0d7ca58195f1cce2 100644 (file)
@@ -46,7 +46,7 @@ func findSymbols(syms []byte, file string, r *regexp.Regexp, address uint64) ([]
                        continue
                }
                if match := matchSymbol(names, start, symAddr-1, r, address); match != nil {
-                       symbols = append(symbols, &plugin.Sym{match, file, start, symAddr - 1})
+                       symbols = append(symbols, &plugin.Sym{Name: match, File: file, Start: start, End: symAddr - 1})
                }
                names, start = []string{name}, symAddr
        }
index bb080238847d40270302a677e4749313f5937926..7fc25741ce2c87f174b1d689c475b35c8d843bfc 100644 (file)
@@ -46,16 +46,16 @@ func TestFindSymbols(t *testing.T) {
                        "line.*[AC]",
                        testsyms,
                        []plugin.Sym{
-                               {[]string{"lineA001"}, "object.o", 0x1000, 0x1FFF},
-                               {[]string{"line200A"}, "object.o", 0x2000, 0x2FFF},
-                               {[]string{"lineB00C"}, "object.o", 0x3000, 0x3FFF},
+                               {Name: []string{"lineA001"}, File: "object.o", Start: 0x1000, End: 0x1FFF},
+                               {Name: []string{"line200A"}, File: "object.o", Start: 0x2000, End: 0x2FFF},
+                               {Name: []string{"lineB00C"}, File: "object.o", Start: 0x3000, End: 0x3FFF},
                        },
                },
                {
                        "Dumb::operator",
                        testsyms,
                        []plugin.Sym{
-                               {[]string{"Dumb::operator()(char const*) const"}, "object.o", 0x3000, 0x3FFF},
+                               {Name: []string{"Dumb::operator()(char const*) const"}, File: "object.o", Start: 0x3000, End: 0x3FFF},
                        },
                },
        }
@@ -109,7 +109,7 @@ func TestFunctionAssembly(t *testing.T) {
        }
        testcases := []testcase{
                {
-                       plugin.Sym{[]string{"symbol1"}, "", 0x1000, 0x1FFF},
+                       plugin.Sym{Name: []string{"symbol1"}, Start: 0x1000, End: 0x1FFF},
                        `  1000: instruction one
   1001: instruction two
   1002: instruction three
@@ -123,7 +123,7 @@ func TestFunctionAssembly(t *testing.T) {
                        },
                },
                {
-                       plugin.Sym{[]string{"symbol2"}, "", 0x2000, 0x2FFF},
+                       plugin.Sym{Name: []string{"symbol2"}, Start: 0x2000, End: 0x2FFF},
                        `  2000: instruction one
   2001: instruction two
 `,
index 093cdbbe046eac0817391a7ec874f959925aa5be..0005ead70bb33f721dd5dccb129b9cc35fc044cc 100644 (file)
@@ -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"
index 9c6acc0ec95f96b7d3115a70ca5d3527a4358b8e..f9e8231419fea41c0c42b1233c15123624e3ec3d 100644 (file)
@@ -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 {
index f03f28417a36e976a0c8dfa8b2218ad592a01bdf..e592b77cc8332035447e5ba040505f236f486bc2 100644 (file)
@@ -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)
                }
        }
 }
index 73681d2823b50fa04ed0ab06b429cad42ca11537..cb20e948b4fcb827082bb3719f9638ad2993c471 100644 (file)
@@ -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
 }
index 38678d92dd1810197b2db4efb9bd621cf67d1773..28cf6b4ce38e510de72cb623a3956a038a1ac4bb 100644 (file)
@@ -230,7 +230,7 @@ func TestDisambiguation(t *testing.T) {
                sibling: "sibling",
        }
 
-       g := &graph.Graph{n}
+       g := &graph.Graph{Nodes: n}
 
        names := getDisambiguatedNames(g)
 
index 66fbece399e5284e6e57e0c8a5ed8b077f0b9a96..66cad3eaa10b48ee541b12dd9253f99d887c0c27 100644 (file)
@@ -207,11 +207,18 @@ func checkSymbolizedLocation(a uint64, got []profile.Line) error {
 }
 
 var mockAddresses = map[uint64][]plugin.Frame{
-       1000: []plugin.Frame{{"fun11", "file11.src", 10}},
-       2000: []plugin.Frame{{"fun21", "file21.src", 20}, {"fun22", "file22.src", 20}},
-       3000: []plugin.Frame{{"fun31", "file31.src", 30}, {"fun32", "file32.src", 30}, {"fun33", "file33.src", 30}},
-       4000: []plugin.Frame{{"fun41", "file41.src", 40}, {"fun42", "file42.src", 40}, {"fun43", "file43.src", 40}, {"fun44", "file44.src", 40}},
-       5000: []plugin.Frame{{"fun51", "file51.src", 50}, {"fun52", "file52.src", 50}, {"fun53", "file53.src", 50}, {"fun54", "file54.src", 50}, {"fun55", "file55.src", 50}},
+       1000: []plugin.Frame{frame("fun11", "file11.src", 10)},
+       2000: []plugin.Frame{frame("fun21", "file21.src", 20), frame("fun22", "file22.src", 20)},
+       3000: []plugin.Frame{frame("fun31", "file31.src", 30), frame("fun32", "file32.src", 30), frame("fun33", "file33.src", 30)},
+       4000: []plugin.Frame{frame("fun41", "file41.src", 40), frame("fun42", "file42.src", 40), frame("fun43", "file43.src", 40), frame("fun44", "file44.src", 40)},
+       5000: []plugin.Frame{frame("fun51", "file51.src", 50), frame("fun52", "file52.src", 50), frame("fun53", "file53.src", 50), frame("fun54", "file54.src", 50), frame("fun55", "file55.src", 50)},
+}
+
+func frame(fname, file string, line int) plugin.Frame {
+       return plugin.Frame{
+               Func: fname,
+               File: file,
+               Line: line}
 }
 
 type mockObjTool struct{}
index 3c86dea3a39acdf9f38007f6683084ca1cd289e2..71b2905d87ba0e42eadbe4ebcbf061cf2859f619 100644 (file)
@@ -9,8 +9,8 @@
                {
                        "canonical": "github.com/google/pprof",
                        "local": "github.com/google/pprof",
-                       "revision": "8b5491579fe32b2af1befa740ac5e6114cbd3e56",
-                       "revisionTime": "2017-02-17T22:14:04Z",
+                       "revision": "e41fb7133e7ebb84ba6af2f6443032c728db26d3",
+                       "revisionTime": "2017-03-01T00:04:42Z",
                },
                {
                        "canonical": "golang.org/x/arch/x86/x86asm",