// traceInitReadCPU initializes CPU profile -> tracer state for tracing. // // Returns a profBuf for reading from. func traceInitReadCPU() { … } // traceStartReadCPU creates a goroutine to start reading CPU profile // data into an active trace. // // traceAdvanceSema must be held. func traceStartReadCPU() { … } // traceStopReadCPU blocks until the trace CPU reading goroutine exits. // // traceAdvanceSema must be held, and tracing must be disabled. func traceStopReadCPU() { … } // traceReadCPU attempts to read from the provided profBuf[gen%2] and write // into the trace. Returns true if there might be more to read or false // if the profBuf is closed or the caller should otherwise stop reading. // // The caller is responsible for ensuring that gen does not change. Either // the caller must be in a traceAcquire/traceRelease block, or must be calling // with traceAdvanceSema held. // // No more than one goroutine may be in traceReadCPU for the same // profBuf at a time. // // Must not run on the system stack because profBuf.read performs race // operations. func traceReadCPU(gen uintptr) bool { … } // traceCPUFlush flushes trace.cpuBuf[gen%2]. The caller must be certain that gen // has completed and that there are no more writers to it. func traceCPUFlush(gen uintptr) { … } // traceCPUSample writes a CPU profile sample stack to the execution tracer's // profiling buffer. It is called from a signal handler, so is limited in what // it can do. mp must be the thread that is currently stopped in a signal. func traceCPUSample(gp *g, mp *m, pp *p, stk []uintptr) { … }