Skip to content

Commit a4d942e

Browse files
David KushnerChrisHines
authored andcommitted
Lazy fetch fixed frame in caller format logic.
1 parent 8f14d46 commit a4d942e

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

stack.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,14 +159,14 @@ func (c Call) PC() uintptr {
159159
}
160160

161161
func (c Call) frame() (*runtime.Frame) {
162-
window := append(c.pcs[:], c.pcs[1] - 1)
163-
frames := runtime.CallersFrames(window)
162+
frames := runtime.CallersFrames(c.pcs[:])
164163

165-
head, _ := frames.Next()
166164
frame, _ := frames.Next()
167-
168-
if head.Function == "runtime.sigpanic" {
169-
frame, _ = frames.Next()
165+
next, _ := frames.Next()
166+
if frame.Function == "runtime.sigpanic" {
167+
frame, _ = runtime.CallersFrames([]uintptr{next.PC - 1}).Next()
168+
} else {
169+
frame = next
170170
}
171171

172172
return &frame

0 commit comments

Comments
 (0)