GoPLS Viewer

Home|gopls/internal/pkgbits/sync.go
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
5package pkgbits
6
7import (
8    "fmt"
9    "strings"
10)
11
12// fmtFrames formats a backtrace for reporting reader/writer desyncs.
13func fmtFrames(pcs ...uintptr) []string {
14    res := make([]string0len(pcs))
15    walkFrames(pcs, func(file stringline intname stringoffset uintptr) {
16        // Trim package from function name. It's just redundant noise.
17        name = strings.TrimPrefix(name"cmd/compile/internal/noder.")
18
19        res = append(resfmt.Sprintf("%s:%v: %s +0x%v"filelinenameoffset))
20    })
21    return res
22}
23
24type frameVisitor func(file stringline intname stringoffset uintptr)
25
26// SyncMarker is an enum type that represents markers that may be
27// written to export data to ensure the reader and writer stay
28// synchronized.
29type SyncMarker int
30
31//go:generate stringer -type=SyncMarker -trimprefix=Sync
32
33const (
34    _ SyncMarker = iota
35
36    // Public markers (known to go/types importers).
37
38    // Low-level coding markers.
39    SyncEOF
40    SyncBool
41    SyncInt64
42    SyncUint64
43    SyncString
44    SyncValue
45    SyncVal
46    SyncRelocs
47    SyncReloc
48    SyncUseReloc
49
50    // Higher-level object and type markers.
51    SyncPublic
52    SyncPos
53    SyncPosBase
54    SyncObject
55    SyncObject1
56    SyncPkg
57    SyncPkgDef
58    SyncMethod
59    SyncType
60    SyncTypeIdx
61    SyncTypeParamNames
62    SyncSignature
63    SyncParams
64    SyncParam
65    SyncCodeObj
66    SyncSym
67    SyncLocalIdent
68    SyncSelector
69
70    // Private markers (only known to cmd/compile).
71    SyncPrivate
72
73    SyncFuncExt
74    SyncVarExt
75    SyncTypeExt
76    SyncPragma
77
78    SyncExprList
79    SyncExprs
80    SyncExpr
81    SyncExprType
82    SyncAssign
83    SyncOp
84    SyncFuncLit
85    SyncCompLit
86
87    SyncDecl
88    SyncFuncBody
89    SyncOpenScope
90    SyncCloseScope
91    SyncCloseAnotherScope
92    SyncDeclNames
93    SyncDeclName
94
95    SyncStmts
96    SyncBlockStmt
97    SyncIfStmt
98    SyncForStmt
99    SyncSwitchStmt
100    SyncRangeStmt
101    SyncCaseClause
102    SyncCommClause
103    SyncSelectStmt
104    SyncDecls
105    SyncLabeledStmt
106    SyncUseObjLocal
107    SyncAddLocal
108    SyncLinkname
109    SyncStmt1
110    SyncStmtsEnd
111    SyncLabel
112    SyncOptLabel
113)
114
MembersX
fmtFrames
fmtFrames.pcs
fmtFrames.res
frameVisitor
SyncMarker
Members
X