golang.org/x/tools@v0.21.1-0.20240520172518-788d39e776b1/internal/pkgbits/sync.go (about) 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 package pkgbits 6 7 import ( 8 "fmt" 9 "strings" 10 ) 11 12 // fmtFrames formats a backtrace for reporting reader/writer desyncs. 13 func fmtFrames(pcs ...uintptr) []string { 14 res := make([]string, 0, len(pcs)) 15 walkFrames(pcs, func(file string, line int, name string, offset 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(res, fmt.Sprintf("%s:%v: %s +0x%v", file, line, name, offset)) 20 }) 21 return res 22 } 23 24 type frameVisitor func(file string, line int, name string, offset 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. 29 type SyncMarker int 30 31 //go:generate stringer -type=SyncMarker -trimprefix=Sync 32 33 const ( 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 )