Skip to content

Commit 1ab063c

Browse files
committed
testing: callerName only needs one PC in the traceback
callerName requested 2 PCs from Callers, and that causes both to be looked up in the file/line mapping. We really only need to do the work for one PC. (And in fact the caller doesn't need file/line at all, but the Callers API can't express that.) We used to request 2 PCs because in 1.11 and earlier we stored an inline skip count in the second entry. That's not necessary any more (as of 1.12). Fixes #32093 Change-Id: I7b272626ef6496e848ee8af388cdaafd2556857b Reviewed-on: https://go-review.googlesource.com/c/go/+/177858 Run-TryBot: Keith Randall <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> Reviewed-by: Caleb Spare <[email protected]>
1 parent 5c3f3fb commit 1ab063c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/testing/testing.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -771,7 +771,7 @@ func (c *common) Helper() {
771771
// for the caller after skip frames (where 0 means the current function).
772772
func callerName(skip int) string {
773773
// Make room for the skip PC.
774-
var pc [2]uintptr
774+
var pc [1]uintptr
775775
n := runtime.Callers(skip+2, pc[:]) // skip + runtime.Callers + callerName
776776
if n == 0 {
777777
panic("testing: zero callers found")

0 commit comments

Comments
 (0)