// Supported reports whether the runtime supports [runtime/debug.SetCrashOutput]. // // TODO(adonovan): eliminate once go1.23+ is assured. func Supported() bool { … } var setCrashOutput … // Parent sets up the parent side of the crashmonitor. It requires // exclusive use of a writable pipe connected to the child process's stdin. func Parent(pipe *os.File) { … } // Child runs the part of the crashmonitor that runs in the child process. // It expects its stdin to be connected via a pipe to the parent which has // run Parent. func Child() { … } var incrementCounter … var childExitHook … // The sentinel function returns its address. The difference between // this value as observed by calls in two different processes of the // same executable tells us the relative offset of their text segments. // // It would be nice if SetCrashOutput took care of this as it's fiddly // and likely to confuse every user at first. func sentinel() uint64 { … } func writeSentinel(out io.Writer) { … } // telemetryCounterName parses a crash report produced by the Go // runtime, extracts the stack of the first runnable goroutine, // converts each line into telemetry form ("symbol:relative-line"), // and returns this as the name of a counter. func telemetryCounterName(crash []byte) (string, error) { … } // parseStackPCs parses the parent process's program counters for the // first running goroutine out of a GOTRACEBACK=system traceback, // adjusting them so that they are valid for the child process's text // segment. // // This function returns only program counter values, ensuring that // there is no possibility of strings from the crash report (which may // contain PII) leaking into the telemetry system. func parseStackPCs(crash string) ([]uintptr, error) { … } func min(x, y int) int { … }