const traceStackSize … const logicalStackSentinel … // traceStack captures a stack trace from a goroutine and registers it in the trace // stack table. It then returns its unique ID. If gp == nil, then traceStack will // attempt to use the current execution context. // // skip controls the number of leaf frames to omit in order to hide tracer internals // from stack traces, see CL 5523. // // Avoid calling this function directly. gen needs to be the current generation // that this stack trace is being written out for, which needs to be synchronized with // generations moving forward. Prefer traceEventWriter.stack. func traceStack(skip int, gp *g, gen uintptr) uint64 { … } type traceStackTable … // put returns a unique id for the stack trace pcs and caches it in the table, // if it sees the trace for the first time. func (t *traceStackTable) put(pcs []uintptr) uint64 { … } // dump writes all previously cached stacks to trace buffers, // releases all memory and resets state. It must only be called once the caller // can guarantee that there are no more writers to the table. func (t *traceStackTable) dump(gen uintptr) { … } func dumpStacksRec(node *traceMapNode, w traceWriter, stackBuf []uintptr) traceWriter { … } // makeTraceFrames returns the frames corresponding to pcs. It may // allocate and may emit trace events. func makeTraceFrames(gen uintptr, pcs []uintptr) []traceFrame { … } type traceFrame … // makeTraceFrame sets up a traceFrame for a frame. func makeTraceFrame(gen uintptr, f Frame) traceFrame { … } // tracefpunwindoff returns true if frame pointer unwinding for the tracer is // disabled via GODEBUG or not supported by the architecture. func tracefpunwindoff() bool { … } // fpTracebackPCs populates pcBuf with the return addresses for each frame and // returns the number of PCs written to pcBuf. The returned PCs correspond to // "physical frames" rather than "logical frames"; that is if A is inlined into // B, this will return a PC for only B. func fpTracebackPCs(fp unsafe.Pointer, pcBuf []uintptr) (i int) { … } //go:linkname pprof_fpunwindExpand func pprof_fpunwindExpand(dst, src []uintptr) int { … } // fpunwindExpand expands a call stack from pcBuf into dst, // returning the number of PCs written to dst. // pcBuf and dst should not overlap. // // fpunwindExpand checks if pcBuf contains logical frames (which include inlined // frames) or physical frames (produced by frame pointer unwinding) using a // sentinel value in pcBuf[0]. Logical frames are simply returned without the // sentinel. Physical frames are turned into logical frames via inline unwinding // and by applying the skip value that's stored in pcBuf[0]. func fpunwindExpand(dst, pcBuf []uintptr) int { … } // startPCForTrace returns the start PC of a goroutine for tracing purposes. // If pc is a wrapper, it returns the PC of the wrapped function. Otherwise it // returns pc. func startPCForTrace(pc uintptr) uintptr { … }