From 5b7352b9bb07247e0c8575bb72fd043322c87449 Mon Sep 17 00:00:00 2001 From: Kostya Serebryany Date: Wed, 15 Mar 2017 00:34:25 +0000 Subject: [PATCH] [libFuzzer] simplify code a bit llvm-svn: 297796 --- lib/Fuzzer/FuzzerInternal.h | 1 - lib/Fuzzer/FuzzerLoop.cpp | 21 ++------------------- 2 files changed, 2 insertions(+), 20 deletions(-) diff --git a/lib/Fuzzer/FuzzerInternal.h b/lib/Fuzzer/FuzzerInternal.h index 347228ebc42..3a3889723f7 100644 --- a/lib/Fuzzer/FuzzerInternal.h +++ b/lib/Fuzzer/FuzzerInternal.h @@ -110,7 +110,6 @@ private: // Stop tracing. void StopTraceRecording(); - void SetDeathCallback(); static void StaticDeathCallback(); void DumpCurrentUnit(const char *Prefix); void DeathCallback(); diff --git a/lib/Fuzzer/FuzzerLoop.cpp b/lib/Fuzzer/FuzzerLoop.cpp index bed28d84e6a..4f1755055c0 100644 --- a/lib/Fuzzer/FuzzerLoop.cpp +++ b/lib/Fuzzer/FuzzerLoop.cpp @@ -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();