syzkaller/pkg/cover/cover.go
Dmitry Vyukov 36d1c4540a all: fix gometalinter warnings
Fix typos, non-canonical code, remove dead code, etc.
2018-03-08 18:48:26 +01:00

31 lines
687 B
Go

// Copyright 2015 syzkaller project authors. All rights reserved.
// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
// Package cover provides types for working with coverage information (arrays of covered PCs).
package cover
type Cover map[uint32]struct{}
func (cov *Cover) Merge(raw []uint32) {
c := *cov
if c == nil {
c = make(Cover)
*cov = c
}
for _, pc := range raw {
c[pc] = struct{}{}
}
}
func (cov Cover) Serialize() []uint32 {
res := make([]uint32, 0, len(cov))
for pc := range cov {
res = append(res, pc)
}
return res
}
func RestorePC(pc uint32, base uint32) uint64 {
return uint64(base)<<32 + uint64(pc)
}