| 650 | } |
| 651 | |
| 652 | int FuzzerDriver(int *argc, char ***argv, UserCallback Callback) { |
| 653 | using namespace fuzzer; |
| 654 | assert(argc && argv && "Argument pointers cannot be nullptr"); |
| 655 | std::string Argv0((*argv)[0]); |
| 656 | EF = new ExternalFunctions(); |
| 657 | if (EF->LLVMFuzzerInitialize) |
| 658 | EF->LLVMFuzzerInitialize(argc, argv); |
| 659 | if (EF->__msan_scoped_disable_interceptor_checks) |
| 660 | EF->__msan_scoped_disable_interceptor_checks(); |
| 661 | const std::vector<std::string> Args(*argv, *argv + *argc); |
| 662 | assert(!Args.empty()); |
| 663 | ProgName = new std::string(Args[0]); |
| 664 | if (Argv0 != *ProgName) { |
| 665 | Printf("ERROR: argv[0] has been modified in LLVMFuzzerInitialize\n"); |
| 666 | exit(1); |
| 667 | } |
| 668 | ParseFlags(Args, EF); |
| 669 | if (Flags.help) { |
| 670 | PrintHelp(); |
| 671 | return 0; |
| 672 | } |
| 673 | |
| 674 | if (Flags.close_fd_mask & 2) |
| 675 | DupAndCloseStderr(); |
| 676 | if (Flags.close_fd_mask & 1) |
| 677 | CloseStdout(); |
| 678 | |
| 679 | if (Flags.jobs > 0 && Flags.workers == 0) { |
| 680 | Flags.workers = std::min(NumberOfCpuCores() / 2, Flags.jobs); |
| 681 | if (Flags.workers > 1) |
| 682 | Printf("Running %u workers\n", Flags.workers); |
| 683 | } |
| 684 | |
| 685 | if (Flags.workers > 0 && Flags.jobs > 0) |
| 686 | return RunInMultipleProcesses(Args, Flags.workers, Flags.jobs); |
| 687 | |
| 688 | FuzzingOptions Options; |
| 689 | Options.Verbosity = Flags.verbosity; |
| 690 | Options.MaxLen = Flags.max_len; |
| 691 | Options.LenControl = Flags.len_control; |
| 692 | Options.KeepSeed = Flags.keep_seed; |
| 693 | Options.UnitTimeoutSec = Flags.timeout; |
| 694 | Options.ErrorExitCode = Flags.error_exitcode; |
| 695 | Options.TimeoutExitCode = Flags.timeout_exitcode; |
| 696 | Options.IgnoreTimeouts = Flags.ignore_timeouts; |
| 697 | Options.IgnoreOOMs = Flags.ignore_ooms; |
| 698 | Options.IgnoreCrashes = Flags.ignore_crashes; |
| 699 | Options.MaxTotalTimeSec = Flags.max_total_time; |
| 700 | Options.DoCrossOver = Flags.cross_over; |
| 701 | Options.CrossOverUniformDist = Flags.cross_over_uniform_dist; |
| 702 | Options.MutateDepth = Flags.mutate_depth; |
| 703 | Options.ReduceDepth = Flags.reduce_depth; |
| 704 | Options.UseCounters = Flags.use_counters; |
| 705 | Options.UseMemmem = Flags.use_memmem; |
| 706 | Options.UseCmp = Flags.use_cmp; |
| 707 | Options.UseValueProfile = Flags.use_value_profile; |
| 708 | Options.Shrink = Flags.shrink; |
| 709 | Options.ReduceInputs = Flags.reduce_inputs; |
no test coverage detected