Skip to content

Commit e5ae0a9

Browse files
committed
internal/pkgbits: cleanup pre-Go 1.17 workaround
Now that golang/go#44505 is resolved, we can simplify frames_go1*.go. This was already done in GOROOT in https://go.dev/cl/420903. Change-Id: Ia7f2a123794fad62532bae2da267b0c8034917bc Reviewed-on: https://go-review.googlesource.com/c/tools/+/609955 LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]>
1 parent 264b4b5 commit e5ae0a9

File tree

3 files changed

+19
-49
lines changed

3 files changed

+19
-49
lines changed

internal/pkgbits/frames_go1.go

Lines changed: 0 additions & 21 deletions
This file was deleted.

internal/pkgbits/frames_go17.go

Lines changed: 0 additions & 28 deletions
This file was deleted.

internal/pkgbits/sync.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package pkgbits
66

77
import (
88
"fmt"
9+
"runtime"
910
"strings"
1011
)
1112

@@ -23,6 +24,24 @@ func fmtFrames(pcs ...uintptr) []string {
2324

2425
type frameVisitor func(file string, line int, name string, offset uintptr)
2526

27+
// walkFrames calls visit for each call frame represented by pcs.
28+
//
29+
// pcs should be a slice of PCs, as returned by runtime.Callers.
30+
func walkFrames(pcs []uintptr, visit frameVisitor) {
31+
if len(pcs) == 0 {
32+
return
33+
}
34+
35+
frames := runtime.CallersFrames(pcs)
36+
for {
37+
frame, more := frames.Next()
38+
visit(frame.File, frame.Line, frame.Function, frame.PC-frame.Entry)
39+
if !more {
40+
return
41+
}
42+
}
43+
}
44+
2645
// SyncMarker is an enum type that represents markers that may be
2746
// written to export data to ensure the reader and writer stay
2847
// synchronized.

0 commit comments

Comments
 (0)