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

Method PrintCoverage

fuzz/libfuzzer/FuzzerTracePC.cpp:282–335  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

280}
281
282void TracePC::PrintCoverage(bool PrintAllCounters) {
283 if (!EF->__sanitizer_symbolize_pc ||
284 !EF->__sanitizer_get_module_and_offset_for_pc) {
285 Printf("INFO: __sanitizer_symbolize_pc or "
286 "__sanitizer_get_module_and_offset_for_pc is not available,"
287 " not printing coverage\n");
288 return;
289 }
290 Printf(PrintAllCounters ? "FULL COVERAGE:\n" : "COVERAGE:\n");
291 auto CoveredFunctionCallback = [&](const PCTableEntry *First,
292 const PCTableEntry *Last,
293 uintptr_t Counter) {
294 assert(First < Last);
295 auto VisualizePC = GetNextInstructionPc(First->PC);
296 std::string FileStr = DescribePC("%s", VisualizePC);
297 if (!IsInterestingCoverageFile(FileStr))
298 return;
299 std::string FunctionStr = DescribePC("%F", VisualizePC);
300 if (FunctionStr.find("in ") == 0)
301 FunctionStr = FunctionStr.substr(3);
302 std::string LineStr = DescribePC("%l", VisualizePC);
303 size_t NumEdges = Last - First;
304 std::vector<uintptr_t> UncoveredPCs;
305 std::vector<uintptr_t> CoveredPCs;
306 for (auto TE = First; TE < Last; TE++)
307 if (!ObservedPCs.count(TE))
308 UncoveredPCs.push_back(TE->PC);
309 else
310 CoveredPCs.push_back(TE->PC);
311
312 if (PrintAllCounters) {
313 Printf("U");
314 for (auto PC : UncoveredPCs)
315 Printf(DescribePC(" %l", GetNextInstructionPc(PC)).c_str());
316 Printf("\n");
317
318 Printf("C");
319 for (auto PC : CoveredPCs)
320 Printf(DescribePC(" %l", GetNextInstructionPc(PC)).c_str());
321 Printf("\n");
322 } else {
323 Printf("%sCOVERED_FUNC: hits: %zd", Counter ? "" : "UN", Counter);
324 Printf(" edges: %zd/%zd", NumEdges - UncoveredPCs.size(), NumEdges);
325 Printf(" %s %s:%s\n", FunctionStr.c_str(), FileStr.c_str(),
326 LineStr.c_str());
327 if (Counter)
328 for (auto PC : UncoveredPCs)
329 Printf(" UNCOVERED_PC: %s\n",
330 DescribePC("%s:%l", GetNextInstructionPc(PC)).c_str());
331 }
332 };
333
334 IterateCoveredFunctions(CoveredFunctionCallback);
335}
336
337// Value profile.
338// We keep track of various values that affect control flow.

Callers 1

PrintFinalStatsMethod · 0.80

Calls 8

DescribePCFunction · 0.85
PrintfFunction · 0.70
findMethod · 0.45
countMethod · 0.45
push_backMethod · 0.45
c_strMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected