| 1 | // Copyright 2021 The Go Authors. All rights reserved. |
|---|---|
| 2 | // Use of this source code is governed by a BSD-style |
| 3 | // license that can be found in the LICENSE file. |
| 4 | |
| 5 | //go:build go1.7 |
| 6 | // +build go1.7 |
| 7 | |
| 8 | package pkgbits |
| 9 | |
| 10 | import "runtime" |
| 11 | |
| 12 | // walkFrames calls visit for each call frame represented by pcs. |
| 13 | // |
| 14 | // pcs should be a slice of PCs, as returned by runtime.Callers. |
| 15 | func walkFrames(pcs []uintptr, visit frameVisitor) { |
| 16 | if len(pcs) == 0 { |
| 17 | return |
| 18 | } |
| 19 | |
| 20 | frames := runtime.CallersFrames(pcs) |
| 21 | for { |
| 22 | frame, more := frames.Next() |
| 23 | visit(frame.File, frame.Line, frame.Function, frame.PC-frame.Entry) |
| 24 | if !more { |
| 25 | return |
| 26 | } |
| 27 | } |
| 28 | } |
| 29 |
Members