Source file src/internal/fuzz/counters_supported.go

     1  // Copyright 2021 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  //go:build (darwin || linux || windows || freebsd) && (amd64 || arm64)
     6  
     7  package fuzz
     8  
     9  import (
    10  	"unsafe"
    11  )
    12  
    13  // coverage returns a []byte containing unique 8-bit counters for each edge of
    14  // the instrumented source code. This coverage data will only be generated if
    15  // `-d=libfuzzer` is set at build time. This can be used to understand the code
    16  // coverage of a test execution.
    17  func coverage() []byte {
    18  	addr := unsafe.Pointer(&_counters)
    19  	size := uintptr(unsafe.Pointer(&_ecounters)) - uintptr(addr)
    20  	return unsafe.Slice((*byte)(addr), int(size))
    21  }
    22  

View as plain text