summaryrefslogtreecommitdiff
path: root/src/cmd/pprof
diff options
context:
space:
mode:
authorAustin Clements <austin@google.com>2014-11-17 14:44:41 -0500
committerAustin Clements <austin@google.com>2014-11-17 14:44:41 -0500
commit51b70627de4361976a31889842452646029e6d66 (patch)
tree5379ff1537e5e81baff856d25a74e322f57b51c9 /src/cmd/pprof
parent0844a2d3d5215f609f1afbbd6fbb9b43fc8447eb (diff)
downloadgo-51b70627de4361976a31889842452646029e6d66.tar.gz
cmd/pprof: fix EOF handling when getting function source
getFunctionSource gathers five lines of "margin" around every requested sample line. However, if this margin went past the end of the source file, getFunctionSource would encounter an io.EOF error and abort with this error, resulting in listings like (pprof) list main.main ROUTINE ======================== main.main in ... 0 8.33s (flat, cum) 99.17% of Total Error: EOF (pprof) Modify the error handling in getFunctionSource so io.EOF is always considered non-fatal. If it reaches EOF, it simply returns the lines it has. LGTM=bradfitz R=rsc, bradfitz CC=golang-codereviews https://codereview.appspot.com/172600043
Diffstat (limited to 'src/cmd/pprof')
-rw-r--r--src/cmd/pprof/internal/report/source.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/cmd/pprof/internal/report/source.go b/src/cmd/pprof/internal/report/source.go
index 57300dd91..73ae1b4ea 100644
--- a/src/cmd/pprof/internal/report/source.go
+++ b/src/cmd/pprof/internal/report/source.go
@@ -358,9 +358,13 @@ func getFunctionSource(fun, file string, fns nodes, start, end int) (nodes, stri
for {
line, err := buf.ReadString('\n')
if err != nil {
- if line == "" || err != io.EOF {
+ if err != io.EOF {
return nil, file, err
}
+ if line == "" {
+ // end was at or past EOF; that's okay
+ break
+ }
}
if lineno >= start {
flat, cum := sumNodes(lineNodes[lineno])