github.com/shogo82148/std@v1.22.1-0.20240327122250-4e474527810c/cmd/internal/goobj/funcinfo.go (about) 1 // Copyright 2019 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 goobj 6 7 import ( 8 "github.com/shogo82148/std/bytes" 9 "github.com/shogo82148/std/internal/abi" 10 ) 11 12 // CUFileIndex is used to index the filenames that are stored in the 13 // per-package/per-CU FileList. 14 type CUFileIndex uint32 15 16 // FuncInfo is serialized as a symbol (aux symbol). The symbol data is 17 // the binary encoding of the struct below. 18 type FuncInfo struct { 19 Args uint32 20 Locals uint32 21 FuncID abi.FuncID 22 FuncFlag abi.FuncFlag 23 StartLine int32 24 File []CUFileIndex 25 InlTree []InlTreeNode 26 } 27 28 func (a *FuncInfo) Write(w *bytes.Buffer) 29 30 // FuncInfoLengths is a cache containing a roadmap of offsets and 31 // lengths for things within a serialized FuncInfo. Each length field 32 // stores the number of items (e.g. files, inltree nodes, etc), and the 33 // corresponding "off" field stores the byte offset of the start of 34 // the items in question. 35 type FuncInfoLengths struct { 36 NumFile uint32 37 FileOff uint32 38 NumInlTree uint32 39 InlTreeOff uint32 40 Initialized bool 41 } 42 43 func (*FuncInfo) ReadFuncInfoLengths(b []byte) FuncInfoLengths 44 45 func (*FuncInfo) ReadArgs(b []byte) uint32 46 47 func (*FuncInfo) ReadLocals(b []byte) uint32 48 49 func (*FuncInfo) ReadFuncID(b []byte) abi.FuncID 50 51 func (*FuncInfo) ReadFuncFlag(b []byte) abi.FuncFlag 52 53 func (*FuncInfo) ReadStartLine(b []byte) int32 54 55 func (*FuncInfo) ReadFile(b []byte, filesoff uint32, k uint32) CUFileIndex 56 57 func (*FuncInfo) ReadInlTree(b []byte, inltreeoff uint32, k uint32) InlTreeNode 58 59 // InlTreeNode is the serialized form of FileInfo.InlTree. 60 type InlTreeNode struct { 61 Parent int32 62 File CUFileIndex 63 Line int32 64 Func SymRef 65 ParentPC int32 66 } 67 68 func (inl *InlTreeNode) Write(w *bytes.Buffer) 69 70 // Read an InlTreeNode from b, return the remaining bytes. 71 func (inl *InlTreeNode) Read(b []byte) []byte