// Copyright 2021 The Go Authors. All rights reserved.// Use of this source code is governed by a BSD-style// license that can be found in the LICENSE file.package fuzzimport ()// ResetCoverage sets all of the counters for each edge of the instrumented// source code to 0.func () { := coverage()clear()}// SnapshotCoverage copies the current counter values into coverageSnapshot,// preserving them for later inspection. SnapshotCoverage also rounds each// counter down to the nearest power of two. This lets the coordinator store// multiple values for each counter by OR'ing them together.func () { := coverage()for , := range { |= >> 1 |= >> 2 |= >> 4 -= >> 1coverageSnapshot[] = }}// diffCoverage returns a set of bits set in snapshot but not in base.// If there are no new bits set, diffCoverage returns nil.func diffCoverage(, []byte) []byte {iflen() != len() {panic(fmt.Sprintf("the number of coverage bits changed: before=%d, after=%d", len(), len())) } := falsefor := range {if []&^[] != 0 { = truebreak } }if ! {returnnil } := make([]byte, len())for := range { [] = [] &^ [] }return}// countNewCoverageBits returns the number of bits set in snapshot that are not// set in base.func countNewCoverageBits(, []byte) int { := 0for := range { += bits.OnesCount8([] &^ []) }return}// isCoverageSubset returns true if all the base coverage bits are set in// snapshot.func isCoverageSubset(, []byte) bool {for , := range {if &[] != {returnfalse } }returntrue}// hasCoverageBit returns true if snapshot has at least one bit set that is// also set in base.func hasCoverageBit(, []byte) bool {for := range {if []&[] != 0 {returntrue } }returnfalse}func countBits( []byte) int { := 0for , := range { += bits.OnesCount8() }return}var ( coverageEnabled = len(coverage()) > 0 coverageSnapshot = make([]byte, len(coverage()))// _counters and _ecounters mark the start and end, respectively, of where // the 8-bit coverage counters reside in memory. They're known to cmd/link, // which specially assigns their addresses for this purpose. _counters, _ecounters [0]byte)
The pages are generated with Goldsv0.7.0-preview. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds.