From 956879dd0bf31b26d2425c2eadbeb19b90812187 Mon Sep 17 00:00:00 2001 From: Keith Randall Date: Sat, 5 Jan 2019 14:31:23 -0800 Subject: runtime: make FuncForPC return the innermost inlined frame Returning the innermost frame instead of the outermost makes code that walks the results of runtime.Caller{,s} still work correctly in the presence of mid-stack inlining. Fixes #29582 Change-Id: I2392e3dd5636eb8c6f58620a61cef2194fe660a7 Reviewed-on: https://go-review.googlesource.com/c/156364 Run-TryBot: Keith Randall Reviewed-by: Ian Lance Taylor --- src/runtime/runtime2.go | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/runtime/runtime2.go') diff --git a/src/runtime/runtime2.go b/src/runtime/runtime2.go index 290a7bd311..df9cbaef20 100644 --- a/src/runtime/runtime2.go +++ b/src/runtime/runtime2.go @@ -663,6 +663,17 @@ type _func struct { nfuncdata uint8 // must be last } +// Pseudo-Func that is returned for PCs that occur in inlined code. +// A *Func can be either a *_func or a *funcinl, and they are distinguished +// by the first uintptr. +type funcinl struct { + zero uintptr // set to 0 to distinguish from _func + entry uintptr // entry of the real (the "outermost") frame. + name string + file string + line int +} + // layout of Itab known to compilers // allocated in non-garbage-collected memory // Needs to be in sync with -- cgit v1.3-5-g9baa