type gTraceState … // reset resets the gTraceState for a new goroutine. func (s *gTraceState) reset() { … } type mTraceState … type pTraceState … // traceLockInit initializes global trace locks. func traceLockInit() { … } // lockRankMayTraceFlush records the lock ranking effects of a // potential call to traceFlush. // // nosplit because traceAcquire is nosplit. // //go:nosplit func lockRankMayTraceFlush() { … } type traceBlockReason … const traceBlockGeneric … const traceBlockForever … const traceBlockNet … const traceBlockSelect … const traceBlockCondWait … const traceBlockSync … const traceBlockChanSend … const traceBlockChanRecv … const traceBlockGCMarkAssist … const traceBlockGCSweep … const traceBlockSystemGoroutine … const traceBlockPreempted … const traceBlockDebugCall … const traceBlockUntilGCEnds … const traceBlockSleep … var traceBlockReasonStrings … type traceGoStopReason … const traceGoStopGeneric … const traceGoStopGoSched … const traceGoStopPreempted … var traceGoStopReasonStrings … // traceEnabled returns true if the trace is currently enabled. // //go:nosplit func traceEnabled() bool { … } // traceAllocFreeEnabled returns true if the trace is currently enabled // and alloc/free events are also enabled. // //go:nosplit func traceAllocFreeEnabled() bool { … } // traceShuttingDown returns true if the trace is currently shutting down. func traceShuttingDown() bool { … } type traceLocker … const debugTraceReentrancy … // traceAcquire prepares this M for writing one or more trace events. // // nosplit because it's called on the syscall path when stack movement is forbidden. // //go:nosplit func traceAcquire() traceLocker { … } // traceAcquireEnabled is the traceEnabled path for traceAcquire. It's explicitly // broken out to make traceAcquire inlineable to keep the overhead of the tracer // when it's disabled low. // // nosplit because it's called by traceAcquire, which is nosplit. // //go:nosplit func traceAcquireEnabled() traceLocker { … } // ok returns true if the traceLocker is valid (i.e. tracing is enabled). // // nosplit because it's called on the syscall path when stack movement is forbidden. // //go:nosplit func (tl traceLocker) ok() bool { … } // traceRelease indicates that this M is done writing trace events. // // nosplit because it's called on the syscall path when stack movement is forbidden. // //go:nosplit func traceRelease(tl traceLocker) { … } // traceExitingSyscall marks a goroutine as exiting the syscall slow path. // // Must be paired with a traceExitedSyscall call. func traceExitingSyscall() { … } // traceExitedSyscall marks a goroutine as having exited the syscall slow path. func traceExitedSyscall() { … } // Gomaxprocs emits a ProcsChange event. func (tl traceLocker) Gomaxprocs(procs int32) { … } // ProcStart traces a ProcStart event. // // Must be called with a valid P. func (tl traceLocker) ProcStart() { … } // ProcStop traces a ProcStop event. func (tl traceLocker) ProcStop(pp *p) { … } // GCActive traces a GCActive event. // // Must be emitted by an actively running goroutine on an active P. This restriction can be changed // easily and only depends on where it's currently called. func (tl traceLocker) GCActive() { … } // GCStart traces a GCBegin event. // // Must be emitted by an actively running goroutine on an active P. This restriction can be changed // easily and only depends on where it's currently called. func (tl traceLocker) GCStart() { … } // GCDone traces a GCEnd event. // // Must be emitted by an actively running goroutine on an active P. This restriction can be changed // easily and only depends on where it's currently called. func (tl traceLocker) GCDone() { … } // STWStart traces a STWBegin event. func (tl traceLocker) STWStart(reason stwReason) { … } // STWDone traces a STWEnd event. func (tl traceLocker) STWDone() { … } // GCSweepStart prepares to trace a sweep loop. This does not // emit any events until traceGCSweepSpan is called. // // GCSweepStart must be paired with traceGCSweepDone and there // must be no preemption points between these two calls. // // Must be called with a valid P. func (tl traceLocker) GCSweepStart() { … } // GCSweepSpan traces the sweep of a single span. If this is // the first span swept since traceGCSweepStart was called, this // will emit a GCSweepBegin event. // // This may be called outside a traceGCSweepStart/traceGCSweepDone // pair; however, it will not emit any trace events in this case. // // Must be called with a valid P. func (tl traceLocker) GCSweepSpan(bytesSwept uintptr) { … } // GCSweepDone finishes tracing a sweep loop. If any memory was // swept (i.e. traceGCSweepSpan emitted an event) then this will emit // a GCSweepEnd event. // // Must be called with a valid P. func (tl traceLocker) GCSweepDone() { … } // GCMarkAssistStart emits a MarkAssistBegin event. func (tl traceLocker) GCMarkAssistStart() { … } // GCMarkAssistDone emits a MarkAssistEnd event. func (tl traceLocker) GCMarkAssistDone() { … } // GoCreate emits a GoCreate event. func (tl traceLocker) GoCreate(newg *g, pc uintptr, blocked bool) { … } // GoStart emits a GoStart event. // // Must be called with a valid P. func (tl traceLocker) GoStart() { … } // GoEnd emits a GoDestroy event. // // TODO(mknyszek): Rename this to GoDestroy. func (tl traceLocker) GoEnd() { … } // GoSched emits a GoStop event with a GoSched reason. func (tl traceLocker) GoSched() { … } // GoPreempt emits a GoStop event with a GoPreempted reason. func (tl traceLocker) GoPreempt() { … } // GoStop emits a GoStop event with the provided reason. func (tl traceLocker) GoStop(reason traceGoStopReason) { … } // GoPark emits a GoBlock event with the provided reason. // // TODO(mknyszek): Replace traceBlockReason with waitReason. It's silly // that we have both, and waitReason is way more descriptive. func (tl traceLocker) GoPark(reason traceBlockReason, skip int) { … } // GoUnpark emits a GoUnblock event. func (tl traceLocker) GoUnpark(gp *g, skip int) { … } // GoSwitch emits a GoSwitch event. If destroy is true, the calling goroutine // is simultaneously being destroyed. func (tl traceLocker) GoSwitch(nextg *g, destroy bool) { … } // emitUnblockStatus emits a GoStatus GoWaiting event for a goroutine about to be // unblocked to the trace writer. func (tl traceLocker) emitUnblockStatus(gp *g, gen uintptr) { … } // GoSysCall emits a GoSyscallBegin event. // // Must be called with a valid P. func (tl traceLocker) GoSysCall() { … } // GoSysExit emits a GoSyscallEnd event, possibly along with a GoSyscallBlocked event // if lostP is true. // // lostP must be true in all cases that a goroutine loses its P during a syscall. // This means it's not sufficient to check if it has no P. In particular, it needs to be // true in the following cases: // - The goroutine lost its P, it ran some other code, and then got it back. It's now running with that P. // - The goroutine lost its P and was unable to reacquire it, and is now running without a P. // - The goroutine lost its P and acquired a different one, and is now running with that P. func (tl traceLocker) GoSysExit(lostP bool) { … } // ProcSteal indicates that our current M stole a P from another M. // // inSyscall indicates that we're stealing the P from a syscall context. // // The caller must have ownership of pp. func (tl traceLocker) ProcSteal(pp *p, inSyscall bool) { … } // HeapAlloc emits a HeapAlloc event. func (tl traceLocker) HeapAlloc(live uint64) { … } // HeapGoal reads the current heap goal and emits a HeapGoal event. func (tl traceLocker) HeapGoal() { … } // GoCreateSyscall indicates that a goroutine has transitioned from dead to GoSyscall. // // Unlike GoCreate, the caller must be running on gp. // // This occurs when C code calls into Go. On pthread platforms it occurs only when // a C thread calls into Go code for the first time. func (tl traceLocker) GoCreateSyscall(gp *g) { … } // GoDestroySyscall indicates that a goroutine has transitioned from GoSyscall to dead. // // Must not have a P. // // This occurs when Go code returns back to C. On pthread platforms it occurs only when // the C thread is destroyed. func (tl traceLocker) GoDestroySyscall() { … } // trace_userTaskCreate emits a UserTaskCreate event. // //go:linkname trace_userTaskCreate runtime/trace.userTaskCreate func trace_userTaskCreate(id, parentID uint64, taskType string) { … } // trace_userTaskEnd emits a UserTaskEnd event. // //go:linkname trace_userTaskEnd runtime/trace.userTaskEnd func trace_userTaskEnd(id uint64) { … } // trace_userRegion emits a UserRegionBegin or UserRegionEnd event, // depending on mode (0 == Begin, 1 == End). // // TODO(mknyszek): Just make this two functions. // //go:linkname trace_userRegion runtime/trace.userRegion func trace_userRegion(id, mode uint64, name string) { … } // trace_userLog emits a UserRegionBegin or UserRegionEnd event. // //go:linkname trace_userLog runtime/trace.userLog func trace_userLog(id uint64, category, message string) { … } // traceThreadDestroy is called when a thread is removed from // sched.freem. // // mp must not be able to emit trace events anymore. // // sched.lock must be held to synchronize with traceAdvance. func traceThreadDestroy(mp *m) { … }