aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2016-07-13 13:22:47 -0700
committerIan Lance Taylor <iant@golang.org>2016-07-13 21:18:19 +0000
commit29ed5da5f2804cab0f6f1c97309673ac5d22a99d (patch)
treebc118c80697c2e6ffbd4e5c9d5a104c11580a809
parent4d00937cecdea85b6f1eb894a6d28a53f5f2ff8a (diff)
downloadgo-29ed5da5f2804cab0f6f1c97309673ac5d22a99d.tar.gz
go-29ed5da5f2804cab0f6f1c97309673ac5d22a99d.zip
runtime/pprof: don't print extraneous 0 after goexit
This fixes erroneous handling of the more result parameter of runtime.Frames.Next. Fixes #16349. Change-Id: I4f1c0263dafbb883294b31dbb8922b9d3e650200 Reviewed-on: https://go-review.googlesource.com/24911 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
-rw-r--r--src/runtime/pprof/pprof.go5
-rw-r--r--src/runtime/pprof/pprof_test.go4
2 files changed, 5 insertions, 4 deletions
diff --git a/src/runtime/pprof/pprof.go b/src/runtime/pprof/pprof.go
index f2cd81adb1..b7c41f13de 100644
--- a/src/runtime/pprof/pprof.go
+++ b/src/runtime/pprof/pprof.go
@@ -353,12 +353,9 @@ func printStackRecord(w io.Writer, stk []uintptr, allFrames bool) {
if name == "" {
show = true
fmt.Fprintf(w, "#\t%#x\n", frame.PC)
- } else {
+ } else if name != "runtime.goexit" && (show || !strings.HasPrefix(name, "runtime.")) {
// Hide runtime.goexit and any runtime functions at the beginning.
// This is useful mainly for allocation traces.
- if name == "runtime.goexit" || !show && strings.HasPrefix(name, "runtime.") {
- continue
- }
show = true
fmt.Fprintf(w, "#\t%#x\t%s+%#x\t%s:%d\n", frame.PC, name, frame.PC-frame.Entry, frame.File, frame.Line)
}
diff --git a/src/runtime/pprof/pprof_test.go b/src/runtime/pprof/pprof_test.go
index a6f5eda458..a0930155a5 100644
--- a/src/runtime/pprof/pprof_test.go
+++ b/src/runtime/pprof/pprof_test.go
@@ -497,6 +497,10 @@ func TestBlockProfile(t *testing.T) {
t.Fatalf("Bad profile header:\n%v", prof)
}
+ if strings.HasSuffix(prof, "#\t0x0\n\n") {
+ t.Errorf("Useless 0 suffix:\n%v", prof)
+ }
+
for _, test := range tests {
if !regexp.MustCompile(strings.Replace(test.re, "\t", "\t+", -1)).MatchString(prof) {
t.Fatalf("Bad %v entry, expect:\n%v\ngot:\n%v", test.name, test.re, prof)