#include "./fuzztest/internal/coverage.h"
#include <algorithm>
#include <cstddef>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <memory>
#include <type_traits>
#include "absl/base/attributes.h"
#include "absl/strings/str_format.h"
#include "absl/types/span.h"
#include "./fuzztest/internal/flag_name.h"
#include "./fuzztest/internal/logging.h"
#include "./fuzztest/internal/table_of_recent_compares.h"
namespace fuzztest::internal {
namespace {
constexpr uint8_t BitWidth(uint8_t x) { … }
}
#define FUZZTEST_INTERNAL_NOSANITIZE …
#ifdef FUZZTEST_USE_CENTIPEDE
thread_local ExecutionCoverage *execution_coverage_instance = nullptr;
#else
ExecutionCoverage *execution_coverage_instance = …;
#endif
void SetExecutionCoverage(ExecutionCoverage *value) { … }
ExecutionCoverage* GetExecutionCoverage() { … }
FUZZTEST_INTERNAL_NOSANITIZE void ExecutionCoverage::UpdateCmpMap(
size_t index, uint8_t hamming_dist, uint8_t absolute_dist) { … }
void ExecutionCoverage::UpdateMaxStack(uintptr_t PC) { … }
#if defined(__clang__) && defined(__linux__) && !defined(__ANDROID__)
namespace {
Vector __attribute__((vector_size(64)));
constexpr size_t kVectorSize = …;
FUZZTEST_INTERNAL_NOSANITIZE bool UpdateVectorized(
const uint8_t *execution_data, uint8_t *corpus_data, size_t size,
size_t offset_to_align) { … }
}
CorpusCoverage::CorpusCoverage(size_t map_size) { … }
CorpusCoverage::~CorpusCoverage() { … }
bool CorpusCoverage::Update(ExecutionCoverage* execution_coverage) { … }
#else
CorpusCoverage::CorpusCoverage(size_t map_size)
: corpus_map_size_(0), corpus_map_(nullptr) {}
CorpusCoverage::~CorpusCoverage() {}
bool CorpusCoverage::Update(ExecutionCoverage* execution_coverage) {
return false;
}
#endif
}
#if !defined(FUZZTEST_COMPATIBILITY_MODE) && !defined(FUZZTEST_USE_CENTIPEDE)
extern "C" void __sanitizer_cov_8bit_counters_init(uint8_t* start,
uint8_t* stop) { … }
template <int data_size>
ABSL_ATTRIBUTE_ALWAYS_INLINE
FUZZTEST_INTERNAL_NOSANITIZE
void
TraceCmp(uint64_t arg1, uint64_t arg2, uint8_t argsize_bit,
uintptr_t PC =
reinterpret_cast<uintptr_t>(__builtin_return_address(0))) { … }
FUZZTEST_INTERNAL_NOSANITIZE
static size_t InternalStrnlen(const char *s, size_t n) { … }
FUZZTEST_INTERNAL_NOSANITIZE
static size_t InternalStrlen(const char *s1, const char *s2) { … }
FUZZTEST_INTERNAL_NOSANITIZE
static void TraceMemCmp(const uint8_t *s1, const uint8_t *s2, size_t n,
int result) { … }
extern "C" {
void __sanitizer_cov_trace_const_cmp1(uint8_t Arg1, uint8_t Arg2) { … }
void __sanitizer_cov_trace_const_cmp2(uint16_t Arg1, uint16_t Arg2) { … }
void __sanitizer_cov_trace_const_cmp4(uint32_t Arg1, uint32_t Arg2) { … }
void __sanitizer_cov_trace_const_cmp8(uint64_t Arg1, uint64_t Arg2) { … }
void __sanitizer_cov_trace_cmp1(uint8_t Arg1, uint8_t Arg2) { … }
void __sanitizer_cov_trace_cmp2(uint16_t Arg1, uint16_t Arg2) { … }
void __sanitizer_cov_trace_cmp4(uint32_t Arg1, uint32_t Arg2) { … }
void __sanitizer_cov_trace_cmp8(uint64_t Arg1, uint64_t Arg2) { … }
FUZZTEST_INTERNAL_NOSANITIZE
void __sanitizer_cov_trace_switch(uint64_t Val, uint64_t *Cases) { … }
FUZZTEST_INTERNAL_NOSANITIZE
void __sanitizer_weak_hook_strcasecmp(void *, const char *s1, const char *s2,
int result) { … }
FUZZTEST_INTERNAL_NOSANITIZE
void __sanitizer_weak_hook_memcmp(void *, const void *s1, const void *s2,
size_t n, int result) { … }
FUZZTEST_INTERNAL_NOSANITIZE
void __sanitizer_weak_hook_strncmp(void *, const char *s1, const char *s2,
size_t n, int result) { … }
FUZZTEST_INTERNAL_NOSANITIZE
void __sanitizer_weak_hook_strcmp(void *, const char *s1, const char *s2,
int result) { … }
FUZZTEST_INTERNAL_NOSANITIZE
void __sanitizer_weak_hook_strncasecmp(void *caller_pc, const char *s1,
const char *s2, size_t n, int result) { … }
}
#endif