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"
27 //===----------------------------------------------------------------------===//
30 /// readGCNO - Read GCNO buffer.
43 if (!GFun->readGCNO(Buffer, Version)) in readGCNO()
52 /// readGCDA - Read GCDA buffer. It is required that readGCDA() can only be
58 GCOV::GCOVVersion GCDAVersion; in readGCDA()
62 errs() << "GCOV versions do not match.\n"; in readGCDA()
79 if (!Functions[i]->readGCDA(Buffer, Version)) in readGCDA()
93 Buffer.advanceCursor(Length - 3); in readGCDA()
106 /// dump - Dump GCOVFile content to dbgs() for debugging purposes.
109 FPtr->dump(); in dump()
112 /// collectLineCounts - Collect line counts. This must be used after
116 FPtr->collectLineCounts(FI); in collectLineCounts()
121 //===----------------------------------------------------------------------===//
124 /// readGCNO - Read a function from the GCNO buffer. Return false if an error
126 bool GCOVFunction::readGCNO(GCOVBuffer &Buff, GCOV::GCOVVersion Version) { in readGCNO()
134 if (Version != GCOV::V402) { in readGCNO()
170 EdgeCount = (EdgeCount - 1) / 2; in readGCNO()
185 Blocks[BlockNo]->addDstEdge(Edge); in readGCNO()
186 Blocks[Dst]->addSrcEdge(Edge); in readGCNO()
215 if (Buff.getCursor() != (EndPos - sizeof(uint32_t))) { in readGCNO()
226 while (Buff.getCursor() < (EndPos - 2 * sizeof(uint32_t))) { in readGCNO()
247 /// readGCDA - Read a function from the GCDA buffer. Return false if an error
249 bool GCOVFunction::readGCDA(GCOVBuffer &Buff, GCOV::GCOVVersion Version) { in readGCDA()
273 if (Version != GCOV::V402) { in readGCDA()
310 if (BlockNo == Blocks.size() - 1) in readGCDA()
323 --Count; in readGCDA()
330 /// getEntryCount - Get the number of times the function was called by
333 return Blocks.front()->getCount(); in getEntryCount()
336 /// getExitCount - Get the number of times the function returned by retrieving
339 return Blocks.back()->getCount(); in getExitCount()
342 /// dump - Dump GCOVFunction content to dbgs() for debugging purposes.
347 Block->dump(); in dump()
350 /// collectLineCounts - Collect line counts. This must be used after
359 Block->collectLineCounts(FI); in collectLineCounts()
363 //===----------------------------------------------------------------------===//
366 /// ~GCOVBlock - Delete GCOVBlock and its content.
373 /// addCount - Add to block counter while storing the edge count. If the
377 DstEdges[DstEdgeNo]->Count = N; in addCount()
379 if (!DstEdges[DstEdgeNo]->Dst.getNumDstEdges()) in addCount()
380 DstEdges[DstEdgeNo]->Dst.Counter += N; in addCount()
383 /// sortDstEdges - Sort destination edges by block number, nop if already
392 /// collectLineCounts - Collect line counts. This must be used after
399 /// dump - Dump GCOVBlock content to dbgs() for debugging purposes.
405 dbgs() << Edge->Src.Number << " (" << Edge->Count << "), "; in dump()
411 dbgs() << Edge->Dst.Number << " (" << Edge->Count << "), "; in dump()
422 //===----------------------------------------------------------------------===//
432 // This custom division function mimics gcov's branch ouputs:
433 // - Round to closest whole number
434 // - Only output 0% or 100% if it's exactly that value
451 formatBranchInfo(const GCOV::Options &Options, uint64_t Count, uint64_t Total) in formatBranchInfo()
452 : Options(Options), Count(Count), Total(Total) {} in formatBranchInfo()
457 else if (Options.BranchCount) in print()
463 const GCOV::Options &Options; member
486 Remaining = Buffer->getBuffer(); in LineConsumer()
501 /// Convert a path to a gcov filename. If PreservePaths is true, this
502 /// translates "/" to "#", ".." to "^", and drops ".", to match gcov.
507 // This behaviour is defined by gcov in terms of text replacements, so it's in mangleCoveragePath()
516 if (I - S == 1 && *S == '.') { in mangleCoveragePath()
518 } else if (I - S == 2 && *S == '.' && *(S + 1) == '.') { in mangleCoveragePath()
538 if (Options.NoOutput) in getCoveragePath()
539 // This is probably a bug in gcov, but when -n is specified, paths aren't in getCoveragePath()
540 // mangled at all, and the -l and -p options are ignored. Here, we do the in getCoveragePath()
545 if (Options.LongFileNames && !Filename.equals(MainFilename)) in getCoveragePath()
547 mangleCoveragePath(MainFilename, Options.PreservePaths) + "##"; in getCoveragePath()
548 CoveragePath += mangleCoveragePath(Filename, Options.PreservePaths) + ".gcov"; in getCoveragePath()
554 if (Options.NoOutput) in openCoveragePath()
567 /// print - Print source files with collected line count information.
578 CovOS << " -: 0:Source:" << Filename << "\n"; in print()
579 CovOS << " -: 0:Graph:" << GCNOFile << "\n"; in print()
580 CovOS << " -: 0:Data:" << GCDAFile << "\n"; in print()
581 CovOS << " -: 0:Runs:" << RunCount << "\n"; in print()
582 CovOS << " -: 0:Programs:" << ProgramCount << "\n"; in print()
588 if (Options.BranchInfo) { in print()
591 printFunctionSummary(CovOS, FuncsIt->second); in print()
597 CovOS << " -:"; in print()
600 const BlockVector &Blocks = BlocksIt->second; in print()
606 if (Options.AllBlocks) { in print()
608 uint64_t BlockCount = Block->getCount(); in print()
612 LineCount += Block->getCount(); in print()
615 if (Options.FuncCoverage) { in print()
627 const GCOVFunction *Function = &Block->getParent(); in print()
630 Function, GCOVCoverage(Function->getName())); in print()
633 GCOVCoverage &FuncCoverage = FuncCoverages.find(Function)->second; in print()
636 if (Block->getCount()) { in print()
643 } else if (!LineExecs[Function] && Block->getCount()) { in print()
664 if (Block->getLastLine() != LineIndex + 1) in print()
666 if (Options.AllBlocks) in print()
668 if (Options.BranchInfo) { in print()
669 size_t NumEdges = Block->getNumDstEdges(); in print()
672 else if (Options.UncondBranch && NumEdges == 1) in print()
674 (*Block->dst_begin())->Count); in print()
683 if (Options.FuncCoverage) in print()
689 /// printFunctionSummary - Print function and block summary.
693 uint64_t EntryCount = Func->getEntryCount(); in printFunctionSummary()
695 for (const GCOVBlock &Block : Func->blocks()) in printFunctionSummary()
699 OS << "function " << Func->getName() << " called " << EntryCount in printFunctionSummary()
700 << " returned " << safeDiv(Func->getExitCount() * 100, EntryCount) in printFunctionSummary()
702 << safeDiv(BlocksExec * 100, Func->getNumBlocks() - 1) << "%\n"; in printFunctionSummary()
706 /// printBlockInfo - Output counts for each block.
713 OS << format("%5u-block %2u\n", LineIndex + 1, BlockNo++); in printBlockInfo()
716 /// printBranchInfo - Print conditional branch probabilities.
722 BranchCounts.push_back(Edge->Count); in printBranchInfo()
723 TotalCounts += Edge->Count; in printBranchInfo()
726 if (Edge->Count) in printBranchInfo()
730 if (Options.FuncCoverage) { in printBranchInfo()
732 GCOVCoverage &FuncCoverage = FuncCoverages.find(Function)->second; in printBranchInfo()
735 if (Edge->Count) in printBranchInfo()
743 << formatBranchInfo(Options, N, TotalCounts) << "\n"; in printBranchInfo()
746 /// printUncondBranchInfo - Print unconditional branch probabilities.
750 << formatBranchInfo(Options, Count, Count) << "\n"; in printUncondBranchInfo()
753 // printCoverage - Print generic coverage info used by both printFuncCoverage
760 if (Options.BranchInfo) { in printCoverage()
771 OS << "No calls\n"; // to be consistent with gcov in printCoverage()
775 // printFuncCoverage - Print per-function coverage info.
785 // printFileCoverage - Print per-file coverage info.
792 if (!Options.NoOutput) in printFileCoverage()