MCPcopy Create free account
hub / github.com/HexHive/NASS / FunctionWeights

Method FunctionWeights

fuzz/libfuzzer/FuzzerDataFlowTrace.cpp:89–104  ·  view source on GitHub ↗

Assign weights to each function. General principles: any uncovered function gets weight 0. a function with lots of uncovered blocks gets bigger weight. a function with a less frequently executed code gets bigger weight.

Source from the content-addressed store, hash-verified

87// * a function with lots of uncovered blocks gets bigger weight.
88// * a function with a less frequently executed code gets bigger weight.
89std::vector<double> BlockCoverage::FunctionWeights(size_t NumFunctions) const {
90 std::vector<double> Res(NumFunctions);
91 for (const auto &It : Functions) {
92 auto FunctionID = It.first;
93 auto Counters = It.second;
94 assert(FunctionID < NumFunctions);
95 auto &Weight = Res[FunctionID];
96 // Give higher weight if the function has a DFT.
97 Weight = FunctionsWithDFT.count(FunctionID) ? 1000. : 1;
98 // Give higher weight to functions with less frequently seen basic blocks.
99 Weight /= SmallestNonZeroCounter(Counters);
100 // Give higher weight to functions with the most uncovered basic blocks.
101 Weight *= NumberOfUncoveredBlocks(Counters) + 1;
102 }
103 return Res;
104}
105
106void DataFlowTrace::ReadCoverage(const std::string &DirPath) {
107 std::vector<SizedFile> Files;

Callers 2

InitMethod · 0.80
TESTFunction · 0.80

Calls 1

countMethod · 0.45

Tested by 1

TESTFunction · 0.64