mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-20 10:24:12 +00:00
[fuzzer] add -use_full_coverage_set=1 which solves FullCoverageSetTest. This does not scale very well yet, but might be a good start.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@227507 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -76,6 +76,35 @@ void Fuzzer::ShuffleAndMinimize() {
|
||||
size_t Fuzzer::RunOne(const Unit &U) {
|
||||
UnitStartTime = system_clock::now();
|
||||
TotalNumberOfRuns++;
|
||||
if (Options.UseFullCoverageSet)
|
||||
return RunOneMaximizeFullCoverageSet(U);
|
||||
return RunOneMaximizeTotalCoverage(U);
|
||||
}
|
||||
|
||||
static uintptr_t HashOfArrayOfPCs(uintptr_t *PCs, uintptr_t NumPCs) {
|
||||
uintptr_t Res = 0;
|
||||
for (uintptr_t i = 0; i < NumPCs; i++) {
|
||||
Res = (Res + PCs[i]) * 7;
|
||||
}
|
||||
return Res;
|
||||
}
|
||||
|
||||
// Fuly reset the current coverage state, run a single unit,
|
||||
// compute a hash function from the full coverage set,
|
||||
// return non-zero if the hash value is new.
|
||||
// This produces tons of new units and as is it's only suitable for small tests,
|
||||
// e.g. test/FullCoverageSetTest.cpp. FIXME: make it scale.
|
||||
size_t Fuzzer::RunOneMaximizeFullCoverageSet(const Unit &U) {
|
||||
__sanitizer_reset_coverage();
|
||||
TestOneInput(U.data(), U.size());
|
||||
uintptr_t *PCs;
|
||||
uintptr_t NumPCs =__sanitizer_get_coverage_guards(&PCs);
|
||||
if (FullCoverageSets.insert(HashOfArrayOfPCs(PCs, NumPCs)).second)
|
||||
return FullCoverageSets.size();
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t Fuzzer::RunOneMaximizeTotalCoverage(const Unit &U) {
|
||||
size_t OldCoverage = __sanitizer_get_total_unique_coverage();
|
||||
TestOneInput(U.data(), U.size());
|
||||
size_t NewCoverage = __sanitizer_get_total_unique_coverage();
|
||||
|
Reference in New Issue
Block a user