aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2015-06-18 16:19:18 +0200
committerDmitry Vyukov <dvyukov@google.com>2015-06-18 14:46:49 +0000
commit1b269463a58c2537bfa7b08ede4134001860254f (patch)
treed751632e5f2a76c0d4db83fb1549ab8321b3fe16 /src
parente72f5f67a1ba523ad647fe1c8c0e49e6aeb4141a (diff)
downloadgo-1b269463a58c2537bfa7b08ede4134001860254f.tar.xz
cmd/trace: gracefully handle empty profiles
Return a meaningful message when a profile is empty. Also rename "IO blocking" to "Network blocking", currently only network blocking is captured. Fixes #11098 Change-Id: Ib6f1292b8ade4805756fcb6696ba1fca8f9f39a9 Reviewed-on: https://go-review.googlesource.com/11243 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src')
-rw-r--r--src/cmd/trace/main.go2
-rw-r--r--src/cmd/trace/pprof.go4
2 files changed, 5 insertions, 1 deletions
diff --git a/src/cmd/trace/main.go b/src/cmd/trace/main.go
index ea6eef353f..c8a9231de7 100644
--- a/src/cmd/trace/main.go
+++ b/src/cmd/trace/main.go
@@ -124,7 +124,7 @@ var templMain = []byte(`
<body>
<a href="/trace">View trace</a><br>
<a href="/goroutines">Goroutine analysis</a><br>
-<a href="/io">IO blocking profile</a><br>
+<a href="/io">Network blocking profile</a><br>
<a href="/block">Synchronization blocking profile</a><br>
<a href="/syscall">Syscall blocking profile</a><br>
<a href="/sched">Scheduler latency profile</a><br>
diff --git a/src/cmd/trace/pprof.go b/src/cmd/trace/pprof.go
index 9e6f277978..154f04d56c 100644
--- a/src/cmd/trace/pprof.go
+++ b/src/cmd/trace/pprof.go
@@ -124,6 +124,10 @@ func httpSched(w http.ResponseWriter, r *http.Request) {
// generateSVGProfile generates pprof-like profile stored in prof and writes in to w.
func serveSVGProfile(w http.ResponseWriter, r *http.Request, prof map[uint64]Record) {
+ if len(prof) == 0 {
+ http.Error(w, "The profile is empty", http.StatusNotFound)
+ return
+ }
blockf, err := ioutil.TempFile("", "block")
if err != nil {
http.Error(w, fmt.Sprintf("failed to create temp file: %v", err), http.StatusInternalServerError)