aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/trace
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmd/trace')
-rw-r--r--src/cmd/trace/pprof.go16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/cmd/trace/pprof.go b/src/cmd/trace/pprof.go
index 40803ac5f9..47be2a6d1c 100644
--- a/src/cmd/trace/pprof.go
+++ b/src/cmd/trace/pprof.go
@@ -15,10 +15,24 @@ import (
"net/http"
"os"
"os/exec"
+ "path/filepath"
+ "runtime"
"github.com/google/pprof/profile"
)
+func goCmd() string {
+ var exeSuffix string
+ if runtime.GOOS == "windows" {
+ exeSuffix = ".exe"
+ }
+ path := filepath.Join(runtime.GOROOT(), "bin", "go"+exeSuffix)
+ if _, err := os.Stat(path); err == nil {
+ return path
+ }
+ return "go"
+}
+
func init() {
http.HandleFunc("/io", serveSVGProfile(pprofIO))
http.HandleFunc("/block", serveSVGProfile(pprofBlock))
@@ -147,7 +161,7 @@ func serveSVGProfile(prof func(w io.Writer) error) http.HandlerFunc {
return
}
svgFilename := blockf.Name() + ".svg"
- if output, err := exec.Command("go", "tool", "pprof", "-svg", "-output", svgFilename, blockf.Name()).CombinedOutput(); err != nil {
+ if output, err := exec.Command(goCmd(), "tool", "pprof", "-svg", "-output", svgFilename, blockf.Name()).CombinedOutput(); err != nil {
http.Error(w, fmt.Sprintf("failed to execute go tool pprof: %v\n%s", err, output), http.StatusInternalServerError)
return
}