crashmonitor

Imports

Imports #

"os"
"runtime/debug"
"bytes"
"fmt"
"io"
"log"
"os"
"reflect"
"runtime/debug"
"strconv"
"strings"
"golang.org/x/telemetry/internal/counter"

Constants & Variables

childExitHook var #

(stubbed by test)

var childExitHook = *ast.FuncLit

incrementCounter var #

(stubbed by test)

var incrementCounter = *ast.FuncLit

setCrashOutput var #

var setCrashOutput func(*os.File) error

Functions

Child function #

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()

Parent function #

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)

Supported function #

Supported reports whether the runtime supports [runtime/debug.SetCrashOutput]. TODO(adonovan): eliminate once go1.23+ is assured.

func Supported() bool

init function #

func init()

min function #

func min(x int, y int) int

parseStackPCs function #

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)

sentinel function #

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

telemetryCounterName function #

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)

writeSentinel function #

func writeSentinel(out io.Writer)

Generated with Arrow