[llvm] r276052 - [libFuzzer] extend the messages printed by afl_driver

Kostya Serebryany via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 19 16:18:28 PDT 2016


Author: kcc
Date: Tue Jul 19 18:18:28 2016
New Revision: 276052

URL: http://llvm.org/viewvc/llvm-project?rev=276052&view=rev
Log:
[libFuzzer] extend the messages printed by afl_driver

Modified:
    llvm/trunk/lib/Fuzzer/afl/afl_driver.cpp

Modified: llvm/trunk/lib/Fuzzer/afl/afl_driver.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/afl/afl_driver.cpp?rev=276052&r1=276051&r2=276052&view=diff
==============================================================================
--- llvm/trunk/lib/Fuzzer/afl/afl_driver.cpp (original)
+++ llvm/trunk/lib/Fuzzer/afl/afl_driver.cpp Tue Jul 19 18:18:28 2016
@@ -239,11 +239,16 @@ static void maybe_duplicate_stderr() {
 }
 
 int main(int argc, char **argv) {
-  fprintf(stderr, "Running in AFl-fuzz mode\nUsage:\n"
-                  "afl-fuzz [afl-flags] %s [N] "
+  fprintf(stderr, "======================= INFO =========================\n"
+                  "This binary is built for AFL-fuzz.\n"
+                  "To run the target function on a single input execute this:\n"
+                  "  %s < INPUT_FILE\n"
+                  "To run the fuzzing execute this:\n"
+                  "  afl-fuzz [afl-flags] %s [N] "
                   "-- run N fuzzing iterations before "
-                  "re-spawning the process (default: 1000)\n",
-          argv[0]);
+                  "re-spawning the process (default: 1000)\n"
+                  "======================================================\n",
+          argv[0], argv[0]);
   if (LLVMFuzzerInitialize)
     LLVMFuzzerInitialize(&argc, &argv);
   // Do any other expensive one-time initialization here.
@@ -258,6 +263,7 @@ int main(int argc, char **argv) {
     N = atoi(argv[1]);
   assert(N > 0);
   time_t unit_time_secs;
+  int num_runs = 0;
   while (__afl_persistent_loop(N)) {
     ssize_t n_read = read(0, AflInputBuf, kMaxAflInputSize);
     if (n_read > 0) {
@@ -270,6 +276,7 @@ int main(int argc, char **argv) {
       CHECK_ERROR(gettimeofday(&unit_start_time, NULL) == 0,
                   "Calling gettimeofday failed");
 
+      num_runs++;
       LLVMFuzzerTestOneInput(copy, n_read);
 
       struct timeval unit_stop_time;
@@ -284,4 +291,5 @@ int main(int argc, char **argv) {
       delete[] copy;
     }
   }
+  fprintf(stderr, "%s: successfully executed %d input(s)\n", argv[0], num_runs);
 }




More information about the llvm-commits mailing list