aboutsummaryrefslogtreecommitdiff
path: root/test/inline_callers.go
diff options
context:
space:
mode:
authorKeith Randall <keithr@alum.mit.edu>2019-01-05 14:31:23 -0800
committerKeith Randall <khr@golang.org>2019-01-08 21:54:04 +0000
commit956879dd0bf31b26d2425c2eadbeb19b90812187 (patch)
tree7d4bb468334d274917f03a783d7d3441e7478c1e /test/inline_callers.go
parent033b6501817aefebc6fc56b6212ff6abf14c8127 (diff)
downloadgo-956879dd0bf31b26d2425c2eadbeb19b90812187.tar.gz
go-956879dd0bf31b26d2425c2eadbeb19b90812187.zip
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 <khr@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'test/inline_callers.go')
-rw-r--r--test/inline_callers.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/test/inline_callers.go b/test/inline_callers.go
index f2c05622dd..ee7d647072 100644
--- a/test/inline_callers.go
+++ b/test/inline_callers.go
@@ -31,7 +31,7 @@ func testCallers(skp int) (frames []string) {
skip = skp
f()
for i := 0; i < npcs; i++ {
- fn := runtime.FuncForPC(pcs[i])
+ fn := runtime.FuncForPC(pcs[i] - 1)
frames = append(frames, fn.Name())
if fn.Name() == "main.main" {
break
@@ -56,10 +56,10 @@ func testCallersFrames(skp int) (frames []string) {
}
var expectedFrames [][]string = [][]string{
- 0: {"runtime.Callers", "main.testCallers", "main.testCallers", "main.testCallers", "main.testCallers", "main.main"},
- 1: {"main.testCallers", "main.testCallers", "main.testCallers", "main.testCallers", "main.main"},
- 2: {"main.testCallers", "main.testCallers", "main.testCallers", "main.main"},
- 3: {"main.testCallers", "main.testCallers", "main.main"},
+ 0: {"runtime.Callers", "main.h", "main.g", "main.f", "main.testCallers", "main.main"},
+ 1: {"main.h", "main.g", "main.f", "main.testCallers", "main.main"},
+ 2: {"main.g", "main.f", "main.testCallers", "main.main"},
+ 3: {"main.f", "main.testCallers", "main.main"},
4: {"main.testCallers", "main.main"},
5: {"main.main"},
}