52 if (!GFun->
read(Buffer, Format))
54 Functions.push_back(GFun);
58 for (
size_t i = 0, e = Functions.size(); i < e; ++i) {
60 errs() <<
"Unexpected number of functions.\n";
63 if (!Functions[i]->
read(Buffer, Format))
69 if (!Buffer.
readInt(Length))
return false;
70 if (!Buffer.
readInt(Dummy))
return false;
71 if (!Buffer.
readInt(Dummy))
return false;
72 if (!Buffer.
readInt(RunCount))
return false;;
77 if (!Buffer.
readInt(Length))
return false;
89 E = Functions.end();
I != E; ++
I)
97 E = Functions.end();
I != E; ++
I)
98 (*I)->collectLineCounts(FI);
115 if (!Buff.
readInt(Dummy))
return false;
116 if (!Buff.
readInt(Ident))
return false;
117 if (!Buff.
readInt(Dummy))
return false;
119 if (!Buff.
readInt(Dummy))
return false;
128 errs() <<
"Arc tag not found.\n";
132 if (!Buff.
readInt(Count))
return false;
137 for (uint32_t Line = 0; Count > 0; ++Line) {
138 if (Line >= Blocks.size()) {
139 errs() <<
"Unexpected number of edges.\n";
143 for (
size_t Edge = 0, End = Block.
getNumEdges(); Edge < End; ++Edge) {
145 errs() <<
"Unexpected number of edges.\n";
149 if (!Buff.
readInt64(ArcCount))
return false;
157 if (!Buff.
readInt(LineNumber))
return false;
161 errs() <<
"Block tag not found.\n";
165 if (!Buff.
readInt(BlockCount))
return false;
166 for (uint32_t i = 0, e = BlockCount; i != e; ++i) {
167 if (!Buff.
readInt(Dummy))
return false;
168 Blocks.push_back(
new GCOVBlock(*
this, i));
174 if (!Buff.
readInt(EdgeCount))
return false;
175 EdgeCount = (EdgeCount - 1) / 2;
177 if (!Buff.
readInt(BlockNo))
return false;
178 if (BlockNo >= BlockCount) {
179 errs() <<
"Unexpected block number.\n";
182 for (uint32_t i = 0, e = EdgeCount; i != e; ++i) {
184 if (!Buff.
readInt(Dst))
return false;
185 Blocks[BlockNo]->addEdge(Dst);
186 if (!Buff.
readInt(Dummy))
return false;
192 uint32_t LineTableLength;
193 if (!Buff.
readInt(LineTableLength))
return false;
194 uint32_t EndPos = Buff.
getCursor() + LineTableLength*4;
196 if (!Buff.
readInt(BlockNo))
return false;
197 if (BlockNo >= BlockCount) {
198 errs() <<
"Unexpected block number.\n";
202 if (!Buff.
readInt(Dummy))
return false;
203 while (Buff.
getCursor() != (EndPos - 4)) {
207 errs() <<
"Multiple sources for a single basic block.\n";
210 if (Buff.
getCursor() == (EndPos - 4))
break;
213 if (!Buff.
readInt(Line))
return false;
218 if (!Buff.
readInt(Dummy))
return false;
225 dbgs() <<
"===== " <<
Name <<
" @ " << Filename <<
":" << LineNumber <<
"\n";
227 E = Blocks.end();
I != E; ++
I)
235 E = Blocks.end();
I != E; ++
I)
236 (*I)->collectLineCounts(FI);
252 E = Lines.
end();
I != E; ++
I)
258 dbgs() <<
"Block : " << Number <<
" Counter : " << Counter <<
"\n";
259 if (!Edges.
empty()) {
260 dbgs() <<
"\tEdges : ";
263 dbgs() << (*I) <<
",";
266 if (!Lines.
empty()) {
267 dbgs() <<
"\tLines : ";
269 E = Lines.
end();
I != E; ++
I)
270 dbgs() << (*I) <<
",";
284 OS <<
" -: 0:Source:" << Filename <<
"\n";
285 OS <<
" -: 0:Graph:" << gcnoFile <<
"\n";
286 OS <<
" -: 0:Data:" << gcdaFile <<
"\n";
287 OS <<
" -: 0:Runs:" << RunCount <<
"\n";
288 OS <<
" -: 0:Programs:" << ProgramCount <<
"\n";
292 errs() << Filename <<
": " << ec.message() <<
"\n";
297 while (!AllLines.
empty()) {
302 OS <<
format(
"%9" PRIu64
":", L[i]);
306 std::pair<StringRef, StringRef>
P = AllLines.
split(
'\n');
307 if (AllLines != P.first)
308 OS <<
format(
"%5u:", i+1) << P.first;
void DeleteContainerPointers(Container &C)
bool readInt(uint32_t &Val)
void dump()
dump - Dump GCOVBlock content to dbgs() for debugging purposes.
static bool isGCDAFile(GCOV::GCOVFormat Format)
isGCDAFile - Return true if Format identifies a .gcda file.
bool read(GCOVBuffer &Buffer)
read - Read GCOV buffer.
void setProgramCount(uint32_t Programs)
bool readString(StringRef &Str)
std::pair< StringRef, StringRef > split(char Separator) const
StringRef getBuffer() const
static bool isGCNOFile(GCOV::GCOVFormat Format)
isGCNOFile - Return true if Format identifies a .gcno file.
void collectLineCounts(FileInfo &FI)
format_object1< T > format(const char *Fmt, const T &Val)
bool LLVM_ATTRIBUTE_UNUSED_RESULT empty() const
GCOVBlock - Collects block information.
bool readInt64(uint64_t &Val)
void collectLineCounts(FileInfo &FI)
static error_code getFileOrSTDIN(StringRef Filename, OwningPtr< MemoryBuffer > &result, int64_t FileSize=-1)
void dump()
dump - Dump GCOVFunction content to dbgs() for debugging purposes.
void advanceCursor(uint32_t n)
~GCOVFunction()
~GCOVFunction - Delete GCOVFunction and its content.
GCOV::GCOVFormat readGCOVFormat()
readGCOVFormat - Read GCOV signature at the beginning of buffer.
void addCount(uint64_t N)
raw_ostream & dbgs()
dbgs - Return a circular-buffered debug stream.
void dump()
dump - Dump GCOVFile content to dbgs() for debugging purposes.
StringRef getFilename() const
void collectLineCounts(FileInfo &FI)
GCOVFunction - Collects function information.
uint64_t getCursor() const
~GCOVBlock()
~GCOVBlock - Delete GCOVBlock and its content.
void setRunCount(uint32_t Runs)
iterator find(const KeyT &Val)
~GCOVFile()
~GCOVFile - Delete GCOVFile and its content.
bool read(GCOVBuffer &Buffer, GCOV::GCOVFormat Format)
void addLineCount(StringRef Filename, uint32_t Line, uint64_t Count)
void print(raw_fd_ostream &OS, StringRef gcnoFile, StringRef gcdaFile)
print - Print source files with collected line count information.
bool empty() const
empty - Check if the string is empty.