From 3d95dd9149286b37aa97a0d9fab7e72ebb3f4059 Mon Sep 17 00:00:00 2001 From: Kostya Serebryany Date: Tue, 1 Mar 2016 22:33:14 +0000 Subject: [PATCH] [libFuzzer] deprecate exit_on_first flag llvm-svn: 262417 --- llvm/lib/Fuzzer/FuzzerDriver.cpp | 14 ++++++++------ llvm/lib/Fuzzer/FuzzerFlags.def | 5 ++--- llvm/lib/Fuzzer/FuzzerInternal.h | 1 - llvm/lib/Fuzzer/FuzzerLoop.cpp | 2 -- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/llvm/lib/Fuzzer/FuzzerDriver.cpp b/llvm/lib/Fuzzer/FuzzerDriver.cpp index c72b60a..098a06e 100644 --- a/llvm/lib/Fuzzer/FuzzerDriver.cpp +++ b/llvm/lib/Fuzzer/FuzzerDriver.cpp @@ -40,16 +40,20 @@ struct FlagDescription { }; struct { +#define FUZZER_DEPRECATED_FLAG(Name) #define FUZZER_FLAG_INT(Name, Default, Description) int Name; #define FUZZER_FLAG_UNSIGNED(Name, Default, Description) unsigned int Name; #define FUZZER_FLAG_STRING(Name, Description) const char *Name; #include "FuzzerFlags.def" +#undef FUZZER_DEPRECATED_FLAG #undef FUZZER_FLAG_INT #undef FUZZER_FLAG_UNSIGNED #undef FUZZER_FLAG_STRING } Flags; static const FlagDescription FlagDescriptions [] { +#define FUZZER_DEPRECATED_FLAG(Name) \ + {#Name, "Deprecated; don't use", 0, nullptr, nullptr, nullptr}, #define FUZZER_FLAG_INT(Name, Default, Description) \ {#Name, Description, Default, &Flags.Name, nullptr, nullptr}, #define FUZZER_FLAG_UNSIGNED(Name, Default, Description) \ @@ -58,6 +62,7 @@ static const FlagDescription FlagDescriptions [] { #define FUZZER_FLAG_STRING(Name, Description) \ {#Name, Description, 0, nullptr, &Flags.Name, nullptr}, #include "FuzzerFlags.def" +#undef FUZZER_DEPRECATED_FLAG #undef FUZZER_FLAG_INT #undef FUZZER_FLAG_UNSIGNED #undef FUZZER_FLAG_STRING @@ -151,6 +156,9 @@ static bool ParseOneFlag(const char *Param) { if (Flags.verbosity >= 2) Printf("Flag: %s %s\n", Name, Str); return true; + } else { // Deprecated flag. + Printf("Flag: %s: deprecated, don't use\n", Name); + return true; } } } @@ -269,7 +277,6 @@ static int FuzzerDriver(const std::vector &Args, Options.MaxTotalTimeSec = Flags.max_total_time; Options.DoCrossOver = Flags.cross_over; Options.MutateDepth = Flags.mutate_depth; - Options.ExitOnFirst = Flags.exit_on_first; Options.UseCounters = Flags.use_counters; Options.UseIndirCalls = Flags.use_indir_calls; Options.UseTraces = Flags.use_traces; @@ -348,11 +355,6 @@ static int FuzzerDriver(const std::vector &Args, exit(0); } - if (Flags.save_minimized_corpus) { - Printf("The flag -save_minimized_corpus is deprecated; use -merge=1\n"); - exit(1); - } - if (Flags.merge) { F.Merge(*Inputs); exit(0); diff --git a/llvm/lib/Fuzzer/FuzzerFlags.def b/llvm/lib/Fuzzer/FuzzerFlags.def index 81dad2b..eddd604 100644 --- a/llvm/lib/Fuzzer/FuzzerFlags.def +++ b/llvm/lib/Fuzzer/FuzzerFlags.def @@ -23,8 +23,6 @@ FUZZER_FLAG_INT( prefer_small_during_initial_shuffle, -1, "If 1, always prefer smaller inputs during the initial corpus shuffle." " If 0, never do that. If -1, do it sometimes.") -FUZZER_FLAG_INT(exit_on_first, 0, - "If 1, exit after the first new interesting input is found.") FUZZER_FLAG_INT( timeout, 1200, "Timeout in seconds (if positive). " @@ -36,7 +34,6 @@ FUZZER_FLAG_INT(error_exit_code, 77, "When libFuzzer's signal handlers are in " FUZZER_FLAG_INT(max_total_time, 0, "If positive, indicates the maximal total " "time in seconds to run the fuzzer.") FUZZER_FLAG_INT(help, 0, "Print help.") -FUZZER_FLAG_INT(save_minimized_corpus, 0, "Deprecated. Use -merge=1") FUZZER_FLAG_INT(merge, 0, "If 1, the 2-nd, 3-rd, etc corpora will be " "merged into the 1-st corpus. Only interesting units will be taken.") FUZZER_FLAG_INT(use_counters, 1, "Use coverage counters") @@ -83,3 +80,5 @@ FUZZER_FLAG_INT(handle_abrt, 1, "If 1, try to intercept SIGABRT.") FUZZER_FLAG_INT(handle_ill, 1, "If 1, try to intercept SIGILL.") FUZZER_FLAG_INT(handle_fpe, 1, "If 1, try to intercept SIGFPE.") FUZZER_FLAG_INT(handle_int, 1, "If 1, try to intercept SIGINT.") +FUZZER_DEPRECATED_FLAG(exit_on_first) +FUZZER_DEPRECATED_FLAG(save_minimized_corpus) diff --git a/llvm/lib/Fuzzer/FuzzerInternal.h b/llvm/lib/Fuzzer/FuzzerInternal.h index 9b9a554..5d66040 100644 --- a/llvm/lib/Fuzzer/FuzzerInternal.h +++ b/llvm/lib/Fuzzer/FuzzerInternal.h @@ -281,7 +281,6 @@ public: int MaxTotalTimeSec = 0; bool DoCrossOver = true; int MutateDepth = 5; - bool ExitOnFirst = false; bool UseCounters = false; bool UseIndirCalls = true; bool UseTraces = false; diff --git a/llvm/lib/Fuzzer/FuzzerLoop.cpp b/llvm/lib/Fuzzer/FuzzerLoop.cpp index 732cd02..e182da4 100644 --- a/llvm/lib/Fuzzer/FuzzerLoop.cpp +++ b/llvm/lib/Fuzzer/FuzzerLoop.cpp @@ -419,8 +419,6 @@ void Fuzzer::ReportNewCoverage(const Unit &U) { PrintStatusForNewUnit(U); WriteToOutputCorpus(U); NumberOfNewUnitsAdded++; - if (Options.ExitOnFirst) - exit(0); } void Fuzzer::Merge(const std::vector &Corpora) { -- 2.7.4