type Frames … type Frame … // CallersFrames takes a slice of PC values returned by [Callers] and // prepares to return function/file/line information. // Do not change the slice until you are done with the [Frames]. func CallersFrames(callers []uintptr) *Frames { … } // Next returns a [Frame] representing the next call frame in the slice // of PC values. If it has already returned all call frames, Next // returns a zero [Frame]. // // The more result indicates whether the next call to Next will return // a valid [Frame]. It does not necessarily indicate whether this call // returned one. // // See the [Frames] example for idiomatic usage. func (ci *Frames) Next() (frame Frame, more bool) { … } // runtime_FrameStartLine returns the start line of the function in a Frame. // // runtime_FrameStartLine should be an internal detail, // but widely used packages access it using linkname. // Notable members of the hall of shame include: // - github.com/grafana/pyroscope-go/godeltaprof // // Do not remove or change the type signature. // See go.dev/issue/67401. // //go:linkname runtime_FrameStartLine runtime/pprof.runtime_FrameStartLine func runtime_FrameStartLine(f *Frame) int { … } // runtime_FrameSymbolName returns the full symbol name of the function in a Frame. // For generic functions this differs from f.Function in that this doesn't replace // the shape name to "...". // // runtime_FrameSymbolName should be an internal detail, // but widely used packages access it using linkname. // Notable members of the hall of shame include: // - github.com/grafana/pyroscope-go/godeltaprof // // Do not remove or change the type signature. // See go.dev/issue/67401. // //go:linkname runtime_FrameSymbolName runtime/pprof.runtime_FrameSymbolName func runtime_FrameSymbolName(f *Frame) string { … } // runtime_expandFinalInlineFrame expands the final pc in stk to include all // "callers" if pc is inline. // // runtime_expandFinalInlineFrame should be an internal detail, // but widely used packages access it using linkname. // Notable members of the hall of shame include: // - github.com/grafana/pyroscope-go/godeltaprof // - github.com/pyroscope-io/godeltaprof // // Do not remove or change the type signature. // See go.dev/issue/67401. // //go:linkname runtime_expandFinalInlineFrame runtime/pprof.runtime_expandFinalInlineFrame func runtime_expandFinalInlineFrame(stk []uintptr) []uintptr { … } // expandCgoFrames expands frame information for pc, known to be // a non-Go function, using the cgoSymbolizer hook. expandCgoFrames // returns nil if pc could not be expanded. func expandCgoFrames(pc uintptr) []Frame { … } type Func … func (f *Func) raw() *_func { … } func (f *Func) funcInfo() funcInfo { … } func (f *_func) funcInfo() funcInfo { … } type pcHeader … type moduledata … type modulehash … var pinnedTypemaps … var firstmoduledata … var lastmoduledatap … var modulesSlice … // activeModules returns a slice of active modules. // // A module is active once its gcdatamask and gcbssmask have been // assembled and it is usable by the GC. // // This is nosplit/nowritebarrier because it is called by the // cgo pointer checking code. // //go:nosplit //go:nowritebarrier func activeModules() []*moduledata { … } // modulesinit creates the active modules slice out of all loaded modules. // // When a module is first loaded by the dynamic linker, an .init_array // function (written by cmd/link) is invoked to call addmoduledata, // appending to the module to the linked list that starts with // firstmoduledata. // // There are two times this can happen in the lifecycle of a Go // program. First, if compiled with -linkshared, a number of modules // built with -buildmode=shared can be loaded at program initialization. // Second, a Go program can load a module while running that was built // with -buildmode=plugin. // // After loading, this function is called which initializes the // moduledata so it is usable by the GC and creates a new activeModules // list. // // Only one goroutine may call modulesinit at a time. func modulesinit() { … } type functab … type textsect … type findfuncbucket … func moduledataverify() { … } const debugPcln … func moduledataverify1(datap *moduledata) { … } // textAddr returns md.text + off, with special handling for multiple text sections. // off is a (virtual) offset computed at internal linking time, // before the external linker adjusts the sections' base addresses. // // The text, or instruction stream is generated as one large buffer. // The off (offset) for a function is its offset within this buffer. // If the total text size gets too large, there can be issues on platforms like ppc64 // if the target of calls are too far for the call instruction. // To resolve the large text issue, the text is split into multiple text sections // to allow the linker to generate long calls when necessary. // When this happens, the vaddr for each text section is set to its offset within the text. // Each function's offset is compared against the section vaddrs and ends to determine the containing section. // Then the section relative offset is added to the section's // relocated baseaddr to compute the function address. // // It is nosplit because it is part of the findfunc implementation. // //go:nosplit func (md *moduledata) textAddr(off32 uint32) uintptr { … } // textOff is the opposite of textAddr. It converts a PC to a (virtual) offset // to md.text, and returns if the PC is in any Go text section. // // It is nosplit because it is part of the findfunc implementation. // //go:nosplit func (md *moduledata) textOff(pc uintptr) (uint32, bool) { … } // funcName returns the string at nameOff in the function name table. func (md *moduledata) funcName(nameOff int32) string { … } // FuncForPC returns a *[Func] describing the function that contains the // given program counter address, or else nil. // // If pc represents multiple functions because of inlining, it returns // the *Func describing the innermost function, but with an entry of // the outermost function. // // For completely unclear reasons, even though they can import runtime, // some widely used packages access this using linkname. // Notable members of the hall of shame include: // - gitee.com/quant1x/gox // // Do not remove or change the type signature. // See go.dev/issue/67401. // //go:linkname FuncForPC func FuncForPC(pc uintptr) *Func { … } // Name returns the name of the function. func (f *Func) Name() string { … } // Entry returns the entry address of the function. func (f *Func) Entry() uintptr { … } // FileLine returns the file name and line number of the // source code corresponding to the program counter pc. // The result will not be accurate if pc is not a program // counter within f. func (f *Func) FileLine(pc uintptr) (file string, line int) { … } // startLine returns the starting line number of the function. i.e., the line // number of the func keyword. func (f *Func) startLine() int32 { … } // findmoduledatap looks up the moduledata for a PC. // // It is nosplit because it's part of the isgoexception // implementation. // //go:nosplit func findmoduledatap(pc uintptr) *moduledata { … } type funcInfo … func (f funcInfo) valid() bool { … } func (f funcInfo) _Func() *Func { … } // isInlined reports whether f should be re-interpreted as a *funcinl. func (f *_func) isInlined() bool { … } // entry returns the entry PC for f. // // entry should be an internal detail, // but widely used packages access it using linkname. // Notable members of the hall of shame include: // - github.com/phuslu/log // // Do not remove or change the type signature. // See go.dev/issue/67401. func (f funcInfo) entry() uintptr { … } //go:linkname badFuncInfoEntry runtime.funcInfo.entry func badFuncInfoEntry(funcInfo) uintptr // findfunc looks up function metadata for a PC. // // It is nosplit because it's part of the isgoexception // implementation. // // findfunc should be an internal detail, // but widely used packages access it using linkname. // Notable members of the hall of shame include: // - github.com/phuslu/log // // Do not remove or change the type signature. // See go.dev/issue/67401. // //go:nosplit //go:linkname findfunc func findfunc(pc uintptr) funcInfo { … } type srcFunc … func (f funcInfo) srcFunc() srcFunc { … } // name should be an internal detail, // but widely used packages access it using linkname. // Notable members of the hall of shame include: // - github.com/phuslu/log // // Do not remove or change the type signature. // See go.dev/issue/67401. func (s srcFunc) name() string { … } //go:linkname badSrcFuncName runtime.srcFunc.name func badSrcFuncName(srcFunc) string type pcvalueCache … type pcvalueCacheEnt … // pcvalueCacheKey returns the outermost index in a pcvalueCache to use for targetpc. // It must be very cheap to calculate. // For now, align to goarch.PtrSize and reduce mod the number of entries. // In practice, this appears to be fairly randomly and evenly distributed. func pcvalueCacheKey(targetpc uintptr) uintptr { … } // Returns the PCData value, and the PC where this value starts. func pcvalue(f funcInfo, off uint32, targetpc uintptr, strict bool) (int32, uintptr) { … } func funcname(f funcInfo) string { … } func funcpkgpath(f funcInfo) string { … } func funcfile(f funcInfo, fileno int32) string { … } // funcline1 should be an internal detail, // but widely used packages access it using linkname. // Notable members of the hall of shame include: // - github.com/phuslu/log // // Do not remove or change the type signature. // See go.dev/issue/67401. // //go:linkname funcline1 func funcline1(f funcInfo, targetpc uintptr, strict bool) (file string, line int32) { … } func funcline(f funcInfo, targetpc uintptr) (file string, line int32) { … } func funcspdelta(f funcInfo, targetpc uintptr) int32 { … } // funcMaxSPDelta returns the maximum spdelta at any point in f. func funcMaxSPDelta(f funcInfo) int32 { … } func pcdatastart(f funcInfo, table uint32) uint32 { … } func pcdatavalue(f funcInfo, table uint32, targetpc uintptr) int32 { … } func pcdatavalue1(f funcInfo, table uint32, targetpc uintptr, strict bool) int32 { … } // Like pcdatavalue, but also return the start PC of this PCData value. func pcdatavalue2(f funcInfo, table uint32, targetpc uintptr) (int32, uintptr) { … } // funcdata returns a pointer to the ith funcdata for f. // funcdata should be kept in sync with cmd/link:writeFuncs. func funcdata(f funcInfo, i uint8) unsafe.Pointer { … } // step advances to the next pc, value pair in the encoded table. func step(p []byte, pc *uintptr, val *int32, first bool) (newp []byte, ok bool) { … } // readvarint reads a varint from p. func readvarint(p []byte) (read uint32, val uint32) { … } type stackmap … //go:nowritebarrier func stackmapdata(stkmap *stackmap, n int32) bitvector { … }