diff options
Diffstat (limited to 'src/cmd/vendor/github.com/google/pprof/internal/driver/driver.go')
| -rw-r--r-- | src/cmd/vendor/github.com/google/pprof/internal/driver/driver.go | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/src/cmd/vendor/github.com/google/pprof/internal/driver/driver.go b/src/cmd/vendor/github.com/google/pprof/internal/driver/driver.go index 6a1e64c600..27681c540f 100644 --- a/src/cmd/vendor/github.com/google/pprof/internal/driver/driver.go +++ b/src/cmd/vendor/github.com/google/pprof/internal/driver/driver.go @@ -59,9 +59,8 @@ func PProf(eo *plugin.Options) error { return interactive(p, o) } +// generateRawReport is allowed to modify p. func generateRawReport(p *profile.Profile, cmd []string, cfg config, o *plugin.Options) (*command, *report.Report, error) { - p = p.Copy() // Prevent modification to the incoming profile. - // Identify units of numeric tags in profile. numLabelUnits := identifyNumLabelUnits(p, o.UI) @@ -110,6 +109,7 @@ func generateRawReport(p *profile.Profile, cmd []string, cfg config, o *plugin.O return c, rpt, nil } +// generateReport is allowed to modify p. func generateReport(p *profile.Profile, cmd []string, cfg config, o *plugin.Options) error { c, rpt, err := generateRawReport(p, cmd, cfg, o) if err != nil { @@ -201,7 +201,6 @@ func applyCommandOverrides(cmd string, outputFormat int, cfg config) config { case report.Proto, report.Raw, report.Callgrind: trim = false cfg.Granularity = "addresses" - cfg.NoInlines = false } if !trim { @@ -365,3 +364,23 @@ func valueExtractor(ix int) sampleValueFunc { return v[ix] } } + +// profileCopier can be used to obtain a fresh copy of a profile. +// It is useful since reporting code may mutate the profile handed to it. +type profileCopier []byte + +func makeProfileCopier(src *profile.Profile) profileCopier { + // Pre-serialize the profile. We will deserialize every time a fresh copy is needed. + var buf bytes.Buffer + src.WriteUncompressed(&buf) + return profileCopier(buf.Bytes()) +} + +// newCopy returns a new copy of the profile. +func (c profileCopier) newCopy() *profile.Profile { + p, err := profile.ParseUncompressed([]byte(c)) + if err != nil { + panic(err) + } + return p +} |
