diff options
author | Austin Clements <austin@google.com> | 2017-06-12 11:12:12 -0400 |
---|---|---|
committer | Austin Clements <austin@google.com> | 2017-09-22 22:17:20 +0000 |
commit | e97209515ad8c4042f5a3ef32068200366892fc2 (patch) | |
tree | 846d1f620bf7a5a4fa13a0fa64f0fda80c688938 /src/runtime/symtab.go | |
parent | 354fa9a84f7b88fe6b9ebf578e6671c2b511a402 (diff) | |
download | go-e97209515ad8c4042f5a3ef32068200366892fc2.tar.gz go-e97209515ad8c4042f5a3ef32068200366892fc2.zip |
runtime: hide <autogenerated> methods from call stack
The compiler generates wrapper methods to forward interface method
calls (which are always pointer-based) to value methods. These
wrappers appear in the call stack even though they are an
implementation detail. This leaves ugly "<autogenerated>" functions in
stack traces and can throw off skip counts for stack traces.
Fix this by considering these runtime frames in printed stack traces
so they will only be printed if runtime frames are being printed, and
by eliding them from the call stack expansion used by CallersFrames
and Caller.
This removes the test for issue 4388 since that was checking that
"<autogenerated>" appeared in the stack trace instead of something
even weirder. We replace it with various runtime package tests.
Fixes #16723.
Change-Id: Ice3f118c66f254bb71478a664d62ab3fc7125819
Reviewed-on: https://go-review.googlesource.com/45412
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/runtime/symtab.go')
-rw-r--r-- | src/runtime/symtab.go | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/runtime/symtab.go b/src/runtime/symtab.go index 7e001c96b1..0324fb7a1c 100644 --- a/src/runtime/symtab.go +++ b/src/runtime/symtab.go @@ -118,6 +118,7 @@ func (ci *Frames) Next() (frame Frame, more bool) { func (se *stackExpander) next(callers []uintptr) (ncallers []uintptr, frame Frame, more bool) { ncallers = callers +again: if !se.pcExpander.more { // Expand the next PC. if len(ncallers) == 0 { @@ -144,6 +145,13 @@ func (se *stackExpander) next(callers []uintptr) (ncallers []uintptr, frame Fram } frame = se.pcExpander.next() + if frame.File == "<autogenerated>" { + // Ignore autogenerated functions such as pointer + // method forwarding functions. These are an + // implementation detail that doesn't reflect the + // source code. + goto again + } return ncallers, frame, se.pcExpander.more || len(ncallers) > 0 } |