blob: b93111b859bc9e31288af4e410d426a519fc5664 [file] [log] [blame]
Stephen Hines86277eb2015-03-23 12:06:32 -07001//===-- sanitizer/coverage_interface.h --------------------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// Public interface for sanitizer coverage.
11//===----------------------------------------------------------------------===//
12
13#ifndef SANITIZER_COVERAG_INTERFACE_H
14#define SANITIZER_COVERAG_INTERFACE_H
15
16#include <sanitizer/common_interface_defs.h>
17
18#ifdef __cplusplus
19extern "C" {
20#endif
21
22 // Initialize coverage.
23 void __sanitizer_cov_init();
24 // Record and dump coverage info.
25 void __sanitizer_cov_dump();
26 // Open <name>.sancov.packed in the coverage directory and return the file
27 // descriptor. Returns -1 on failure, or if coverage dumping is disabled.
28 // This is intended for use by sandboxing code.
29 intptr_t __sanitizer_maybe_open_cov_file(const char *name);
Pirama Arumuga Nainar799172d2016-03-03 15:50:30 -080030 // Get the number of unique covered blocks (or edges).
Stephen Hines86277eb2015-03-23 12:06:32 -070031 // This can be useful for coverage-directed in-process fuzzers.
32 uintptr_t __sanitizer_get_total_unique_coverage();
Pirama Arumuga Nainar799172d2016-03-03 15:50:30 -080033 // Get the number of unique indirect caller-callee pairs.
34 uintptr_t __sanitizer_get_total_unique_caller_callee_pairs();
Stephen Hines86277eb2015-03-23 12:06:32 -070035
36 // Reset the basic-block (edge) coverage to the initial state.
37 // Useful for in-process fuzzing to start collecting coverage from scratch.
38 // Experimental, will likely not work for multi-threaded process.
39 void __sanitizer_reset_coverage();
40 // Set *data to the array of covered PCs and return the size of that array.
41 // Some of the entries in *data will be zero.
42 uintptr_t __sanitizer_get_coverage_guards(uintptr_t **data);
43
Pirama Arumuga Nainar7c915052015-04-08 08:58:29 -070044 // The coverage instrumentation may optionally provide imprecise counters.
45 // Rather than exposing the counter values to the user we instead map
46 // the counters to a bitset.
47 // Every counter is associated with 8 bits in the bitset.
48 // We define 8 value ranges: 1, 2, 3, 4-7, 8-15, 16-31, 32-127, 128+
49 // The i-th bit is set to 1 if the counter value is in the i-th range.
50 // This counter-based coverage implementation is *not* thread-safe.
51
52 // Returns the number of registered coverage counters.
53 uintptr_t __sanitizer_get_number_of_counters();
54 // Updates the counter 'bitset', clears the counters and returns the number of
55 // new bits in 'bitset'.
56 // If 'bitset' is nullptr, only clears the counters.
57 // Otherwise 'bitset' should be at least
58 // __sanitizer_get_number_of_counters bytes long and 8-aligned.
59 uintptr_t
60 __sanitizer_update_counter_bitset_and_clear_counters(uint8_t *bitset);
Stephen Hines86277eb2015-03-23 12:06:32 -070061#ifdef __cplusplus
62} // extern "C"
63#endif
64
65#endif // SANITIZER_COVERAG_INTERFACE_H