aboutsummaryrefslogtreecommitdiff
path: root/internal/pkgbits/frames_go17.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/pkgbits/frames_go17.go')
-rw-r--r--internal/pkgbits/frames_go17.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/internal/pkgbits/frames_go17.go b/internal/pkgbits/frames_go17.go
new file mode 100644
index 000000000..2324ae7ad
--- /dev/null
+++ b/internal/pkgbits/frames_go17.go
@@ -0,0 +1,28 @@
+// Copyright 2021 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//go:build go1.7
+// +build go1.7
+
+package pkgbits
+
+import "runtime"
+
+// walkFrames calls visit for each call frame represented by pcs.
+//
+// pcs should be a slice of PCs, as returned by runtime.Callers.
+func walkFrames(pcs []uintptr, visit frameVisitor) {
+ if len(pcs) == 0 {
+ return
+ }
+
+ frames := runtime.CallersFrames(pcs)
+ for {
+ frame, more := frames.Next()
+ visit(frame.File, frame.Line, frame.Function, frame.PC-frame.Entry)
+ if !more {
+ return
+ }
+ }
+}