mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-26 04:32:44 +01:00
[libFuzzer] simplify code a bit
llvm-svn: 297796
This commit is contained in:
parent
3f5b505ccb
commit
5b7352b9bb
@ -110,7 +110,6 @@ private:
|
||||
// Stop tracing.
|
||||
void StopTraceRecording();
|
||||
|
||||
void SetDeathCallback();
|
||||
static void StaticDeathCallback();
|
||||
void DumpCurrentUnit(const char *Prefix);
|
||||
void DeathCallback();
|
||||
|
@ -45,19 +45,6 @@ thread_local bool Fuzzer::IsMyThread;
|
||||
|
||||
SharedMemoryRegion SMR;
|
||||
|
||||
static void MissingExternalApiFunction(const char *FnName) {
|
||||
Printf("ERROR: %s is not defined. Exiting.\n"
|
||||
"Did you use -fsanitize-coverage=... to build your code?\n",
|
||||
FnName);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
#define CHECK_EXTERNAL_FUNCTION(fn) \
|
||||
do { \
|
||||
if (!(EF->fn)) \
|
||||
MissingExternalApiFunction(#fn); \
|
||||
} while (false)
|
||||
|
||||
// Only one Fuzzer per process.
|
||||
static Fuzzer *F;
|
||||
|
||||
@ -128,7 +115,8 @@ void Fuzzer::HandleMalloc(size_t Size) {
|
||||
Fuzzer::Fuzzer(UserCallback CB, InputCorpus &Corpus, MutationDispatcher &MD,
|
||||
FuzzingOptions Options)
|
||||
: CB(CB), Corpus(Corpus), MD(MD), Options(Options) {
|
||||
SetDeathCallback();
|
||||
if (EF->__sanitizer_set_death_callback)
|
||||
EF->__sanitizer_set_death_callback(StaticDeathCallback);
|
||||
InitializeTraceState();
|
||||
assert(!F);
|
||||
F = this;
|
||||
@ -157,11 +145,6 @@ void Fuzzer::AllocateCurrentUnitData() {
|
||||
CurrentUnitData = new uint8_t[MaxInputLen];
|
||||
}
|
||||
|
||||
void Fuzzer::SetDeathCallback() {
|
||||
CHECK_EXTERNAL_FUNCTION(__sanitizer_set_death_callback);
|
||||
EF->__sanitizer_set_death_callback(StaticDeathCallback);
|
||||
}
|
||||
|
||||
void Fuzzer::StaticDeathCallback() {
|
||||
assert(F);
|
||||
F->DeathCallback();
|
||||
|
Loading…
Reference in New Issue
Block a user