package coverage

Import Path
	internal/coverage (on go.dev)

Dependency Relation
	imports 0 packages, and imported by 8 packages

Involved Source Files defs.go pkid.go
Package-Level Type Names (total 11)
/* sort by: | */
CounterFileFooter appears at the tail end of a counter data file, and stores the number of segments it contains. Magic [4]byte NumSegments uint32
CounterFileHeader stores files header information for a counter-data file. BigEndian bool CFlavor CounterFlavor Magic [4]byte MetaHash [16]byte Version uint32
CounterFlavor describes how function and counters are stored/represented in the counter section of the file. func internal/coverage/encodecounter.NewCoverageDataWriter(w io.Writer, flav CounterFlavor) *encodecounter.CoverageDataWriter const CtrRaw const CtrULeb128
CounterGranularity tracks the granularity of the coverage counters being used in a given coverage-instrumented program. ( CounterGranularity) String() string CounterGranularity : expvar.Var CounterGranularity : fmt.Stringer func internal/coverage/cmerge.(*Merger).Granularity() CounterGranularity func internal/coverage/decodemeta.(*CoverageMetaFileReader).CounterGranularity() CounterGranularity func internal/coverage/cmerge.(*Merger).SetModeAndGranularity(mdf string, cmode CounterMode, cgran CounterGranularity) error func internal/coverage/encodemeta.(*CoverageMetaFileWriter).Write(finalHash [16]byte, blobs [][]byte, mode CounterMode, granularity CounterGranularity) error const CtrGranularityInvalid const CtrGranularityPerBlock const CtrGranularityPerFunc
CounterMode tracks the "flavor" of the coverage counters being used in a given coverage-instrumented program. ( CounterMode) String() string CounterMode : expvar.Var CounterMode : fmt.Stringer func ParseCounterMode(mode string) CounterMode func internal/coverage/cmerge.(*Merger).Mode() CounterMode func internal/coverage/decodemeta.(*CoverageMetaFileReader).CounterMode() CounterMode func internal/coverage/cformat.NewFormatter(cm CounterMode) *cformat.Formatter func internal/coverage/cmerge.(*Merger).SetModeAndGranularity(mdf string, cmode CounterMode, cgran CounterGranularity) error func internal/coverage/encodemeta.(*CoverageMetaFileWriter).Write(finalHash [16]byte, blobs [][]byte, mode CounterMode, granularity CounterGranularity) error const CtrModeAtomic const CtrModeCount const CtrModeInvalid const CtrModeRegOnly const CtrModeSet const CtrModeTestMain
CounterSegmentHeader encapsulates information about a specific segment in a counter data file, which at the moment contains counters data from a single execution of a coverage-instrumented program. Following the segment header will be the string table and args table, and then (possibly) padding bytes to bring the byte size of the preamble up to a multiple of 4. Immediately following that will be the counter payloads. The "args" section of a segment is used to store annotations describing where the counter data came from; this section is basically a series of key-value pairs (can be thought of as an encoded 'map[string]string'). At the moment we only write os.Args() data to this section, using pairs of the form "argc=<integer>", "argv0=<os.Args[0]>", "argv1=<os.Args[1]>", and so on. In the future the args table may also include things like GOOS/GOARCH values, and/or tags indicating which tests were run to generate the counter data. ArgsLen uint32 FcnEntries uint64 StrTabLen uint32
CoverableUnit describes the source characteristics of a single program unit for which we want to gather coverage info. Coverable units are either "simple" or "intraline"; a "simple" coverable unit corresponds to a basic block (region of straight-line code with no jumps or control transfers). An "intraline" unit corresponds to a logical clause nested within some other simple unit. A simple unit will have a zero Parent value; for an intraline unit NxStmts will be zero and Parent will be set to 1 plus the index of the containing simple statement. Example: L7: q := 1 L8: x := (y == 101 || launch() == false) L9: r := x * 2 For the code above we would have three simple units (one for each line), then an intraline unit describing the "launch() == false" clause in line 8, with Parent pointing to the index of the line 8 unit in the units array. Note: in the initial version of the coverage revamp, only simple units will be in use. EnCol uint32 EnLine uint32 NxStmts uint32 Parent uint32 StCol uint32 StLine uint32 func internal/coverage/cformat.(*Formatter).AddUnit(file string, fname string, isfnlit bool, unit CoverableUnit, count uint32)
FuncDesc encapsulates the meta-data definitions for a single Go function. This version assumes that we're looking at a function before inlining; if we want to capture a post-inlining view of the world, the representations of source positions would need to be a good deal more complicated. Funcname string // true if this is a function literal Srcfile string Units []CoverableUnit func internal/coverage/decodemeta.(*CoverageMetaDataDecoder).ReadFunc(fidx uint32, f *FuncDesc) error func internal/coverage/encodemeta.HashFuncDesc(f *FuncDesc) [16]byte func internal/coverage/encodemeta.(*CoverageMetaDataBuilder).AddFunc(f FuncDesc) uint
MetaFileCollection contains information generated by the Go command and the read in by coverage test support functions within an executing "go test -cover" binary. ImportPaths []string MetaFileFragments []string
MetaFileHeader stores file header information for a meta-data file. CGranularity CounterGranularity CMode CounterMode Entries uint64 Magic [4]byte MetaFileHash [16]byte StrTabLength uint32 StrTabOffset uint32 TotalLength uint64 Version uint32
MetaSymbolHeader stores header information for a single meta-data blob, e.g. the coverage meta-data payload computed for a given Go package. // size of meta-symbol payload in bytes MetaHash [16]byte // string table index NumFiles uint32 NumFuncs uint32 // string table index // string table index
Package-Level Functions (total 3)
HardCodedPkgID returns the hard-coded ID for the specified package path, or -1 if we don't use a hard-coded ID. Hard-coded IDs start at -2 and decrease as we go down the list.
func Round4(x int) int
Package-Level Variables (total 2)
CovCounterMagic holds the magic string for a coverage counter-data file.
CovMetaMagic holds the magic string for a meta-data file.
Package-Level Constants (total 24)
CounterFilePref is the file prefix used when emitting coverage data output files. CounterFileTemplate describes the format of the file name: prefix followed by meta-file hash followed by process ID followed by emit UnixNanoTime.
const CounterFileRegexp = "^%s\\.(\\S+)\\.(\\d+)\\.(\\d+)+$"
const CounterFileTempl = "%s.%x.%d.%d"
CounterFileVersion stores the most recent counter data file version.
const CovMetaHeaderSize = 44 // keep in sync with above
const CtrModeAtomic CounterMode = 3 // "atomic" mode
const CtrModeCount CounterMode = 2 // "count" mode
const CtrModeRegOnly CounterMode = 4 // registration-only pseudo-mode
const CtrModeSet CounterMode = 1 // "set" mode
const CtrModeTestMain CounterMode = 5 // testmain pseudo-mode
"Raw" representation: all values (pkg ID, func ID, num counters, and counters themselves) are stored as uint32's.
"ULeb" representation: all values (pkg ID, func ID, num counters, and counters themselves) are stored with ULEB128 encoding.
const FirstCtrOffset = 3
const FuncIdOffset = 2
MetaFilePref is a prefix used when emitting meta-data files; these files are of the form "covmeta.<hash>", where hash is a hash computed from the hashes of all the package meta-data symbols in the program.
Name of file within the "go test -cover" temp coverdir directory containing a list of meta-data files for packages being tested in a "go test -coverpkg=... ..." run. This constant is shared by the Go command and by the coverage runtime.
MetaFileVersion contains the current (most recent) meta-data file version.
NotHardCoded is a package pseudo-ID indicating that a given package is not part of the runtime and doesn't require a hard-coded ID.
const NumCtrsOffset = 0
const PkgIdOffset = 1