runtime/coverage: runtime routines to emit coverage data

This patch fleshes out the runtime support for emitting coverage data
at the end of a run of an instrumented binary. Data is emitted in the
form of a pair of files, a meta-out-file and counter-data-outfile,
each written to the dir GOCOVERDIR. The meta-out-file is emitted only
if required; no need to emit again if an existing meta-data file with
the same hash and length is present.

Updates #51430.

Change-Id: I59d20a4b8c05910c933ee29527972f8e401b1685
Reviewed-on: https://go-review.googlesource.com/c/go/+/355451
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Than McIntosh <thanm@google.com>
This commit is contained in:
Than McIntosh 2021-10-11 07:34:20 -04:00
parent 7a74829858
commit 87db4ffada
9 changed files with 932 additions and 31 deletions

View file

@ -23,3 +23,12 @@ type CovMetaBlob struct {
CounterMode uint8 // coverage.CounterMode
CounterGranularity uint8 // coverage.CounterGranularity
}
// CovCounterBlob is a container for encapsulating a counter section
// (BSS variable) for an instrumented Go module. Here "counters"
// points to the counter payload and "len" is the number of uint32
// entries in the section.
type CovCounterBlob struct {
Counters *uint32
Len uint64
}