aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/vendor/github.com/google/pprof/internal/driver/cli.go
diff options
context:
space:
mode:
authorHana Kim <hakim@google.com>2018-05-30 10:54:20 -0400
committerHyang-Ah Hana Kim <hyangah@gmail.com>2018-05-30 16:31:37 +0000
commitd5bc3b96c6fb758561e6274c8f69232623157ca4 (patch)
tree2d156042108d713fc5118d11f713c620d8eb1a95 /src/cmd/vendor/github.com/google/pprof/internal/driver/cli.go
parentfb0d6e4bd18da45fdb2b88640d368e919d3b6c7c (diff)
downloadgo-d5bc3b96c6fb758561e6274c8f69232623157ca4.tar.xz
cmd/vendor/.../pprof: sync at rev 1ddc9e2
This includes changes in pprof to support - the new -diff_base flag - fix for a bug in handling of legacy Go heap profiles Update #25096 Change-Id: I826ac9244f31cc2c4415388c44a0cbe77303e460 Reviewed-on: https://go-review.googlesource.com/115295 Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src/cmd/vendor/github.com/google/pprof/internal/driver/cli.go')
-rw-r--r--src/cmd/vendor/github.com/google/pprof/internal/driver/cli.go49
1 files changed, 39 insertions, 10 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 c3c22e7c96..a5153e1511 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
@@ -15,6 +15,7 @@
package driver
import (
+ "errors"
"fmt"
"os"
"strings"
@@ -28,6 +29,7 @@ type source struct {
ExecName string
BuildID string
Base []string
+ DiffBase bool
Normalize bool
Seconds int
@@ -43,7 +45,8 @@ type source struct {
func parseFlags(o *plugin.Options) (*source, []string, error) {
flag := o.Flagset
// Comparisons.
- flagBase := flag.StringList("base", "", "Source for base profile for comparison")
+ flagBase := flag.StringList("base", "", "Source for base profile for profile subtraction")
+ flagDiffBase := flag.StringList("diff_base", "", "Source for diff base profile for comparison")
// Source options.
flagSymbolize := flag.String("symbolize", "", "Options for profile symbolization")
flagBuildID := flag.String("buildid", "", "Override build id for first mapping")
@@ -85,7 +88,7 @@ func parseFlags(o *plugin.Options) (*source, []string, error) {
usageMsgVars)
})
if len(args) == 0 {
- return nil, nil, fmt.Errorf("no profile source specified")
+ return nil, nil, errors.New("no profile source specified")
}
var execName string
@@ -112,7 +115,7 @@ func parseFlags(o *plugin.Options) (*source, []string, error) {
return nil, nil, err
}
if cmd != nil && *flagHTTP != "" {
- return nil, nil, fmt.Errorf("-http is not compatible with an output format on the command line")
+ return nil, nil, errors.New("-http is not compatible with an output format on the command line")
}
si := pprofVariables["sample_index"].value
@@ -140,15 +143,13 @@ func parseFlags(o *plugin.Options) (*source, []string, error) {
Comment: *flagAddComment,
}
- for _, s := range *flagBase {
- if *s != "" {
- source.Base = append(source.Base, *s)
- }
+ if err := source.addBaseProfiles(*flagBase, *flagDiffBase); err != nil {
+ return nil, nil, err
}
normalize := pprofVariables["normalize"].boolValue()
if normalize && len(source.Base) == 0 {
- return nil, nil, fmt.Errorf("Must have base profile to normalize by")
+ return nil, nil, errors.New("must have base profile to normalize by")
}
source.Normalize = normalize
@@ -158,6 +159,34 @@ func parseFlags(o *plugin.Options) (*source, []string, error) {
return source, cmd, nil
}
+// addBaseProfiles adds the list of base profiles or diff base profiles to
+// the source. This function will return an error if both base and diff base
+// profiles are specified.
+func (source *source) addBaseProfiles(flagBase, flagDiffBase []*string) error {
+ base, diffBase := dropEmpty(flagBase), dropEmpty(flagDiffBase)
+ if len(base) > 0 && len(diffBase) > 0 {
+ return errors.New("-base and -diff_base flags cannot both be specified")
+ }
+
+ source.Base = base
+ if len(diffBase) > 0 {
+ source.Base, source.DiffBase = diffBase, true
+ }
+ return nil
+}
+
+// dropEmpty list takes a slice of string pointers, and outputs a slice of
+// non-empty strings associated with the flag.
+func dropEmpty(list []*string) []string {
+ var l []string
+ for _, s := range list {
+ if *s != "" {
+ l = append(l, *s)
+ }
+ }
+ return l
+}
+
// installFlags creates command line flags for pprof variables.
func installFlags(flag plugin.FlagSet) flagsInstalled {
f := flagsInstalled{
@@ -240,7 +269,7 @@ func outputFormat(bcmd map[string]*bool, acmd map[string]*string) (cmd []string,
for n, b := range bcmd {
if *b {
if cmd != nil {
- return nil, fmt.Errorf("must set at most one output format")
+ return nil, errors.New("must set at most one output format")
}
cmd = []string{n}
}
@@ -248,7 +277,7 @@ func outputFormat(bcmd map[string]*bool, acmd map[string]*string) (cmd []string,
for n, s := range acmd {
if *s != "" {
if cmd != nil {
- return nil, fmt.Errorf("must set at most one output format")
+ return nil, errors.New("must set at most one output format")
}
cmd = []string{n, *s}
}