• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright 2015 syzkaller project authors. All rights reserved.
2// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
3
4// Package cover provides types for working with coverage information (arrays of covered PCs).
5package cover
6
7type Cover map[uint32]struct{}
8
9func (cov *Cover) Merge(raw []uint32) {
10	c := *cov
11	if c == nil {
12		c = make(Cover)
13		*cov = c
14	}
15	for _, pc := range raw {
16		c[pc] = struct{}{}
17	}
18}
19
20func (cov Cover) Serialize() []uint32 {
21	res := make([]uint32, 0, len(cov))
22	for pc := range cov {
23		res = append(res, pc)
24	}
25	return res
26}
27
28func RestorePC(pc uint32, base uint32) uint64 {
29	return uint64(base)<<32 + uint64(pc)
30}
31