llvm/compiler-rt/lib/fuzzer/FuzzerDriver.cpp

//===- FuzzerDriver.cpp - FuzzerDriver function and flags -----------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// FuzzerDriver and flag parsing.
//===----------------------------------------------------------------------===//

#include "FuzzerCommand.h"
#include "FuzzerCorpus.h"
#include "FuzzerFork.h"
#include "FuzzerIO.h"
#include "FuzzerInterface.h"
#include "FuzzerInternal.h"
#include "FuzzerMerge.h"
#include "FuzzerMutate.h"
#include "FuzzerPlatform.h"
#include "FuzzerRandom.h"
#include "FuzzerTracePC.h"
#include <algorithm>
#include <atomic>
#include <chrono>
#include <cstdlib>
#include <cstring>
#include <mutex>
#include <string>
#include <thread>
#include <fstream>

// This function should be present in the libFuzzer so that the client
// binary can test for its existence.
#if LIBFUZZER_MSVC
extern "C" void __libfuzzer_is_present() {}
#if defined(_M_IX86) || defined(__i386__)
#pragma comment(linker, "/include:___libfuzzer_is_present")
#else
#pragma comment(linker, "/include:__libfuzzer_is_present")
#endif
#else
extern "C" __attribute__((used)) void __libfuzzer_is_present() {}
#endif  // LIBFUZZER_MSVC

namespace fuzzer {

// Program arguments.
struct FlagDescription {};

struct {} Flags;

static const FlagDescription FlagDescriptions [] {};

static const size_t kNumFlags =;

static std::vector<std::string> *Inputs;
static std::string *ProgName;

static void PrintHelp() {}

static const char *FlagValue(const char *Param, const char *Name) {}

// Avoid calling stol as it triggers a bug in clang/glibc build.
static long MyStol(const char *Str) {}

static bool ParseOneFlag(const char *Param) {}

// We don't use any library to minimize dependencies.
static void ParseFlags(const std::vector<std::string> &Args,
                       const ExternalFunctions *EF) {}

static std::mutex Mu;

static void PulseThread() {}

static void WorkerThread(const Command &BaseCmd, std::atomic<unsigned> *Counter,
                         unsigned NumJobs, std::atomic<bool> *HasErrors) {}

static void ValidateDirectoryExists(const std::string &Path,
                                    bool CreateDirectory) {}

std::string CloneArgsWithoutX(const std::vector<std::string> &Args,
                              const char *X1, const char *X2) {}

static int RunInMultipleProcesses(const std::vector<std::string> &Args,
                                  unsigned NumWorkers, unsigned NumJobs) {}

static void RssThread(Fuzzer *F, size_t RssLimitMb) {}

static void StartRssThread(Fuzzer *F, size_t RssLimitMb) {}

int RunOneTest(Fuzzer *F, const char *InputFilePath, size_t MaxLen) {}

static bool AllInputsAreFiles() {}

static std::string GetDedupTokenFromCmdOutput(const std::string &S) {}

int CleanseCrashInput(const std::vector<std::string> &Args,
                      const FuzzingOptions &Options) {}

int MinimizeCrashInput(const std::vector<std::string> &Args,
                       const FuzzingOptions &Options) {}

int MinimizeCrashInputInternalStep(Fuzzer *F, InputCorpus *Corpus) {}

void Merge(Fuzzer *F, FuzzingOptions &Options,
           const std::vector<std::string> &Args,
           const std::vector<std::string> &Corpora, const char *CFPathOrNull) {}

int AnalyzeDictionary(Fuzzer *F, const std::vector<Unit> &Dict,
                      UnitVector &Corpus) {}

std::vector<std::string> ParseSeedInuts(const char *seed_inputs) {}

static std::vector<SizedFile>
ReadCorpora(const std::vector<std::string> &CorpusDirs,
            const std::vector<std::string> &ExtraSeedFiles) {}

int FuzzerDriver(int *argc, char ***argv, UserCallback Callback) {}

extern "C" ATTRIBUTE_INTERFACE int
LLVMFuzzerRunDriver(int *argc, char ***argv,
                    int (*UserCb)(const uint8_t *Data, size_t Size)) {}

// Storage for global ExternalFunctions object.
ExternalFunctions *EF =;

}  // namespace fuzzer