Index: lib/fuzzer/FuzzerMutate.h =================================================================== --- lib/fuzzer/FuzzerMutate.h +++ lib/fuzzer/FuzzerMutate.h @@ -20,22 +20,22 @@ namespace fuzzer { typedef enum { - AddWordFromManualDictionary, - AddWordFromPersistentAutoDictionary, - AddWordFromTORC, - ChangeASCIIInteger, - _ChangeBinaryInteger, // To avoid clash with mutation helper function - ChangeBit, - ChangeByte, - CopyPart, - _CrossOver, // To avoid clash with mutation helper function - CustomCrossOver, - Custom, - EraseBytes, - InsertByte, - InsertRepeatedBytes, - ShuffleBytes, - MaxNumberOfMutationTypes + ADD_WORD_FROM_MANUAL_DICTIONARY, + ADD_WORD_FROM_PERSISTENT_AUTO_DICTIONARY, + ADD_WORD_FROM_TORC, + CHANGE_ASCII_INTEGER, + CHANGE_BINARY_INTEGER, // To avoid clash with mutation helper function + CHANGE_BIT, + CHANGE_BYTE, + COPY_PART, + CROSS_OVER, // To avoid clash with mutation helper function + CUSTOM_CROSS_OVER, + CUSTOM, + ERASE_BYTES, + INSERT_BYTE, + INSERT_REPEATED_BYTES, + SHUFFLE_BYTES, + MAX_NUMBER_OF_MUTATION_TYPES } MutationType; class MutationDispatcher { Index: lib/fuzzer/FuzzerMutate.cpp =================================================================== --- lib/fuzzer/FuzzerMutate.cpp +++ lib/fuzzer/FuzzerMutate.cpp @@ -31,34 +31,34 @@ DefaultMutators.insert( DefaultMutators.begin(), { - {&MutationDispatcher::Mutate_EraseBytes, EraseBytes, "EraseBytes"}, - {&MutationDispatcher::Mutate_InsertByte, InsertByte, "InsertByte"}, + {&MutationDispatcher::Mutate_EraseBytes, ERASE_BYTES, "ERASE_BYTES"}, + {&MutationDispatcher::Mutate_InsertByte, INSERT_BYTE, "INSERT_BYTE"}, {&MutationDispatcher::Mutate_InsertRepeatedBytes, - InsertRepeatedBytes, "InsertRepeatedBytes"}, - {&MutationDispatcher::Mutate_ChangeByte, ChangeByte, "ChangeByte"}, - {&MutationDispatcher::Mutate_ChangeBit, ChangeBit,"ChangeBit"}, - {&MutationDispatcher::Mutate_ShuffleBytes, ShuffleBytes, "ShuffleBytes"}, - {&MutationDispatcher::Mutate_ChangeASCIIInteger, ChangeASCIIInteger, "ChangeASCIIInteger"}, - {&MutationDispatcher::Mutate_ChangeBinaryInteger, _ChangeBinaryInteger, "ChangeBinaryInteger"}, - {&MutationDispatcher::Mutate_CopyPart, CopyPart, "CopyPart"}, - {&MutationDispatcher::Mutate_CrossOver, _CrossOver, "CrossOver"}, + INSERT_REPEATED_BYTES, "INSERT_REPEATED_BYTES"}, + {&MutationDispatcher::Mutate_ChangeByte, CHANGE_BYTE, "CHANGE_BYTE"}, + {&MutationDispatcher::Mutate_ChangeBit, CHANGE_BIT,"CHANGE_BIT"}, + {&MutationDispatcher::Mutate_ShuffleBytes, SHUFFLE_BYTES, "SHUFFLE_BYTES"}, + {&MutationDispatcher::Mutate_ChangeASCIIInteger, CHANGE_ASCII_INTEGER, "CHANGE_ASCII_INTEGER"}, + {&MutationDispatcher::Mutate_ChangeBinaryInteger, CHANGE_BINARY_INTEGER, "ChangeBinaryInteger"}, + {&MutationDispatcher::Mutate_CopyPart, COPY_PART, "COPY_PART"}, + {&MutationDispatcher::Mutate_CrossOver, CROSS_OVER, "CrossOver"}, {&MutationDispatcher::Mutate_AddWordFromManualDictionary, - AddWordFromManualDictionary, "AddWordFromManualDictionary"}, + ADD_WORD_FROM_MANUAL_DICTIONARY, "ADD_WORD_FROM_MANUAL_DICTIONARY"}, {&MutationDispatcher::Mutate_AddWordFromPersistentAutoDictionary, - AddWordFromPersistentAutoDictionary, "AddWordFromPersistentAutoDictionary"}, + ADD_WORD_FROM_PERSISTENT_AUTO_DICTIONARY, "ADD_WORD_FROM_PERSISTENT_AUTO_DICTIONARY"}, }); if(Options.UseCmp) DefaultMutators.push_back( - {&MutationDispatcher::Mutate_AddWordFromTORC, AddWordFromTORC, "AddWordFromTORC"}); + {&MutationDispatcher::Mutate_AddWordFromTORC, ADD_WORD_FROM_TORC, "ADD_WORD_FROM_TORC"}); if (EF->LLVMFuzzerCustomMutator) - Mutators.push_back({&MutationDispatcher::Mutate_Custom, Custom, "Custom"}); + Mutators.push_back({&MutationDispatcher::Mutate_Custom, CUSTOM, "CUSTOM"}); else Mutators = DefaultMutators; if (EF->LLVMFuzzerCustomCrossOver) Mutators.push_back( - {&MutationDispatcher::Mutate_CustomCrossOver, CustomCrossOver, "CustomCrossOver"}); + {&MutationDispatcher::Mutate_CustomCrossOver, CUSTOM_CROSS_OVER, "CUSTOM_CROSS_OVER"}); } static char RandCh(Random &Rand) { Index: lib/fuzzer/FuzzerMutationStats.h =================================================================== --- lib/fuzzer/FuzzerMutationStats.h +++ lib/fuzzer/FuzzerMutationStats.h @@ -23,9 +23,9 @@ private: // A total count of each mutation used in the fuzzing process. - std::array TotalMutations; + std::array TotalMutations; // The number of each mutation that resulted in new coverage. - std::array UsefulMutations; + std::array UsefulMutations; }; extern MutationStats *MStats; Index: lib/fuzzer/FuzzerMutationStats.cpp =================================================================== --- lib/fuzzer/FuzzerMutationStats.cpp +++ lib/fuzzer/FuzzerMutationStats.cpp @@ -22,37 +22,37 @@ Printf("\nstat::total_mutations: "); for (auto& M : TotalMutations) { Printf("%zd", M); - if (&M != &TotalMutations.back()) Printf(", "); + if (&M != &TotalMutations.back()) Printf(","); } Printf("\nstat::useful_mutations: "); for (auto& M : UsefulMutations) { Printf("%zd", M); - if (&M != &UsefulMutations.back()) Printf(", "); + if (&M != &UsefulMutations.back()) Printf(","); } } void MutationStats::PrintMutationUsefulness() { Printf("\nstat::mutation_usefulness: "); - for (int i = 0; i < MaxNumberOfMutationTypes; i++) { + for (int i = 0; i < MAX_NUMBER_OF_MUTATION_TYPES; i++) { double CurrentRatio = (TotalMutations.at(i) != 0) ? (UsefulMutations.at(i) / static_cast(TotalMutations.at(i)) * 100) : 0; Printf("%.3f", CurrentRatio); - if (i < MaxNumberOfMutationTypes-1) Printf(", "); - else if (i == MaxNumberOfMutationTypes-1) Printf("\n\n"); + if (i < MAX_NUMBER_OF_MUTATION_TYPES-1) Printf(","); + else if (i == MAX_NUMBER_OF_MUTATION_TYPES-1) Printf("\n\n"); } } void MutationStats::IncTotalMutationCount(MutationType MType) { - assert(MType >= 0 && MType < MaxNumberOfMutationTypes); + assert(MType >= 0 && MType < MAX_NUMBER_OF_MUTATION_TYPES); TotalMutations[MType]++; } void MutationStats::IncUsefulMutationCount(MutationType MType) { - assert(MType >= 0 && MType < MaxNumberOfMutationTypes); + assert(MType >= 0 && MType < MAX_NUMBER_OF_MUTATION_TYPES); UsefulMutations[MType]++; }