mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/pprof: store temporary files in temporary directory
Fixes #9180. Change-Id: Id5adaea0ca9005946fb89c88a10c6f59d8c0943c Reviewed-on: https://go-review.googlesource.com/12202 Reviewed-by: Andrew Gerrand <adg@golang.org>
This commit is contained in:
parent
2bd1e5e50b
commit
505f6e335e
2 changed files with 20 additions and 2 deletions
|
|
@ -9,6 +9,7 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
|
@ -185,9 +186,26 @@ func saveSVGToFile() PostProcessor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var vizTmpDir string
|
||||||
|
|
||||||
|
func makeVizTmpDir() error {
|
||||||
|
if vizTmpDir != "" {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
name, err := ioutil.TempDir("", "pprof-")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
vizTmpDir = name
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func invokeVisualizer(interactive **bool, format PostProcessor, suffix string, visualizers []string) PostProcessor {
|
func invokeVisualizer(interactive **bool, format PostProcessor, suffix string, visualizers []string) PostProcessor {
|
||||||
return func(input *bytes.Buffer, output io.Writer, ui plugin.UI) error {
|
return func(input *bytes.Buffer, output io.Writer, ui plugin.UI) error {
|
||||||
tempFile, err := tempfile.New(os.Getenv("PPROF_TMPDIR"), "pprof", "."+suffix)
|
if err := makeVizTmpDir(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
tempFile, err := tempfile.New(vizTmpDir, "pprof", "."+suffix)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -894,7 +894,7 @@ var usageMsg = "Output file parameters (for file-based output formats):\n" +
|
||||||
" -help This message"
|
" -help This message"
|
||||||
|
|
||||||
var usageMsgVars = "Environment Variables:\n" +
|
var usageMsgVars = "Environment Variables:\n" +
|
||||||
" PPROF_TMPDIR Location for temporary files (default $HOME/pprof)\n" +
|
" PPROF_TMPDIR Location for saved profiles (default $HOME/pprof)\n" +
|
||||||
" PPROF_TOOLS Search path for object-level tools\n" +
|
" PPROF_TOOLS Search path for object-level tools\n" +
|
||||||
" PPROF_BINARY_PATH Search path for local binary files\n" +
|
" PPROF_BINARY_PATH Search path for local binary files\n" +
|
||||||
" default: $HOME/pprof/binaries\n" +
|
" default: $HOME/pprof/binaries\n" +
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue