Lines Matching +full:- +full:- +full:gcov +full:- +full:options
1 //===- GCOV.cpp - LLVM coverage tool --------------------------------------===//
8 //===----------------------------------------------------------------------===//
10 // GCOV implements the interface to read and write coverage files that use
11 // 'gcov' format.
13 //===----------------------------------------------------------------------===//
15 #include "llvm/Support/GCOV.h"
28 //===----------------------------------------------------------------------===//
31 /// readGCNO - Read GCNO buffer.
44 if (!GFun->readGCNO(Buffer, Version)) in readGCNO()
53 /// readGCDA - Read GCDA buffer. It is required that readGCDA() can only be
59 GCOV::GCOVVersion GCDAVersion; in readGCDA()
63 errs() << "GCOV versions do not match.\n"; in readGCDA()
80 if (!Functions[i]->readGCDA(Buffer, Version)) in readGCDA()
94 Buffer.advanceCursor(Length - 3); in readGCDA()
107 /// dump - Dump GCOVFile content to dbgs() for debugging purposes.
110 FPtr->dump(); in dump()
113 /// collectLineCounts - Collect line counts. This must be used after
117 FPtr->collectLineCounts(FI); in collectLineCounts()
122 //===----------------------------------------------------------------------===//
125 /// readGCNO - Read a function from the GCNO buffer. Return false if an error
127 bool GCOVFunction::readGCNO(GCOVBuffer &Buff, GCOV::GCOVVersion Version) { in readGCNO()
135 if (Version != GCOV::V402) { in readGCNO()
171 EdgeCount = (EdgeCount - 1) / 2; in readGCNO()
186 Blocks[BlockNo]->addDstEdge(Edge); in readGCNO()
187 Blocks[Dst]->addSrcEdge(Edge); in readGCNO()
216 if (Buff.getCursor() != (EndPos - sizeof(uint32_t))) { in readGCNO()
227 while (Buff.getCursor() < (EndPos - 2 * sizeof(uint32_t))) { in readGCNO()
248 /// readGCDA - Read a function from the GCDA buffer. Return false if an error
250 bool GCOVFunction::readGCDA(GCOVBuffer &Buff, GCOV::GCOVVersion Version) { in readGCDA()
276 if (Version != GCOV::V402) { in readGCDA()
315 if (BlockNo == Blocks.size() - 1) in readGCDA()
328 --Count; in readGCDA()
335 /// getEntryCount - Get the number of times the function was called by
338 return Blocks.front()->getCount(); in getEntryCount()
341 /// getExitCount - Get the number of times the function returned by retrieving
344 return Blocks.back()->getCount(); in getExitCount()
347 /// dump - Dump GCOVFunction content to dbgs() for debugging purposes.
352 Block->dump(); in dump()
355 /// collectLineCounts - Collect line counts. This must be used after
364 Block->collectLineCounts(FI); in collectLineCounts()
368 //===----------------------------------------------------------------------===//
371 /// ~GCOVBlock - Delete GCOVBlock and its content.
378 /// addCount - Add to block counter while storing the edge count. If the
382 DstEdges[DstEdgeNo]->Count = N; in addCount()
384 if (!DstEdges[DstEdgeNo]->Dst.getNumDstEdges()) in addCount()
385 DstEdges[DstEdgeNo]->Dst.Counter += N; in addCount()
388 /// sortDstEdges - Sort destination edges by block number, nop if already
397 /// collectLineCounts - Collect line counts. This must be used after
404 /// dump - Dump GCOVBlock content to dbgs() for debugging purposes.
410 dbgs() << Edge->Src.Number << " (" << Edge->Count << "), "; in dump()
416 dbgs() << Edge->Dst.Number << " (" << Edge->Count << "), "; in dump()
427 //===----------------------------------------------------------------------===//
437 // This custom division function mimics gcov's branch ouputs:
438 // - Round to closest whole number
439 // - Only output 0% or 100% if it's exactly that value
456 formatBranchInfo(const GCOV::Options &Options, uint64_t Count, uint64_t Total) in formatBranchInfo()
457 : Options(Options), Count(Count), Total(Total) {} in formatBranchInfo()
462 else if (Options.BranchCount) in print()
468 const GCOV::Options &Options; member
491 Remaining = Buffer->getBuffer(); in LineConsumer()
506 /// Convert a path to a gcov filename. If PreservePaths is true, this
507 /// translates "/" to "#", ".." to "^", and drops ".", to match gcov.
512 // This behaviour is defined by gcov in terms of text replacements, so it's in mangleCoveragePath()
521 if (I - S == 1 && *S == '.') { in mangleCoveragePath()
523 } else if (I - S == 2 && *S == '.' && *(S + 1) == '.') { in mangleCoveragePath()
543 if (Options.NoOutput) in getCoveragePath()
544 // This is probably a bug in gcov, but when -n is specified, paths aren't in getCoveragePath()
545 // mangled at all, and the -l and -p options are ignored. Here, we do the in getCoveragePath()
550 if (Options.LongFileNames && !Filename.equals(MainFilename)) in getCoveragePath()
552 mangleCoveragePath(MainFilename, Options.PreservePaths) + "##"; in getCoveragePath()
553 CoveragePath += mangleCoveragePath(Filename, Options.PreservePaths) + ".gcov"; in getCoveragePath()
559 if (Options.NoOutput) in openCoveragePath()
572 /// print - Print source files with collected line count information.
583 CovOS << " -: 0:Source:" << Filename << "\n"; in print()
584 CovOS << " -: 0:Graph:" << GCNOFile << "\n"; in print()
585 CovOS << " -: 0:Data:" << GCDAFile << "\n"; in print()
586 CovOS << " -: 0:Runs:" << RunCount << "\n"; in print()
587 CovOS << " -: 0:Programs:" << ProgramCount << "\n"; in print()
593 if (Options.BranchInfo) { in print()
596 printFunctionSummary(CovOS, FuncsIt->second); in print()
602 CovOS << " -:"; in print()
605 const BlockVector &Blocks = BlocksIt->second; in print()
611 if (Options.AllBlocks) { in print()
613 uint64_t BlockCount = Block->getCount(); in print()
617 LineCount += Block->getCount(); in print()
620 if (Options.FuncCoverage) { in print()
632 const GCOVFunction *Function = &Block->getParent(); in print()
635 Function, GCOVCoverage(Function->getName())); in print()
638 GCOVCoverage &FuncCoverage = FuncCoverages.find(Function)->second; in print()
641 if (Block->getCount()) { in print()
648 } else if (!LineExecs[Function] && Block->getCount()) { in print()
669 if (Block->getLastLine() != LineIndex + 1) in print()
671 if (Options.AllBlocks) in print()
673 if (Options.BranchInfo) { in print()
674 size_t NumEdges = Block->getNumDstEdges(); in print()
677 else if (Options.UncondBranch && NumEdges == 1) in print()
679 (*Block->dst_begin())->Count); in print()
688 if (Options.FuncCoverage) in print()
693 /// printFunctionSummary - Print function and block summary.
697 uint64_t EntryCount = Func->getEntryCount(); in printFunctionSummary()
699 for (const GCOVBlock &Block : Func->blocks()) in printFunctionSummary()
703 OS << "function " << Func->getName() << " called " << EntryCount in printFunctionSummary()
704 << " returned " << safeDiv(Func->getExitCount() * 100, EntryCount) in printFunctionSummary()
706 << safeDiv(BlocksExec * 100, Func->getNumBlocks() - 1) << "%\n"; in printFunctionSummary()
710 /// printBlockInfo - Output counts for each block.
717 OS << format("%5u-block %2u\n", LineIndex + 1, BlockNo++); in printBlockInfo()
720 /// printBranchInfo - Print conditional branch probabilities.
726 BranchCounts.push_back(Edge->Count); in printBranchInfo()
727 TotalCounts += Edge->Count; in printBranchInfo()
730 if (Edge->Count) in printBranchInfo()
734 if (Options.FuncCoverage) { in printBranchInfo()
736 GCOVCoverage &FuncCoverage = FuncCoverages.find(Function)->second; in printBranchInfo()
739 if (Edge->Count) in printBranchInfo()
747 << formatBranchInfo(Options, N, TotalCounts) << "\n"; in printBranchInfo()
750 /// printUncondBranchInfo - Print unconditional branch probabilities.
754 << formatBranchInfo(Options, Count, Count) << "\n"; in printUncondBranchInfo()
757 // printCoverage - Print generic coverage info used by both printFuncCoverage
764 if (Options.BranchInfo) { in printCoverage()
775 OS << "No calls\n"; // to be consistent with gcov in printCoverage()
779 // printFuncCoverage - Print per-function coverage info.
789 // printFileCoverage - Print per-file coverage info.
796 if (!Options.NoOutput) in printFileCoverage()