llvm-cov: Added file checksum to gcno and gcda files.

Instead of permanently outputting "MVLL" as the file checksum, clang
will create gcno and gcda checksums by hashing the destination block
numbers of every arc. This allows for llvm-cov to check if the two gcov
files are synchronized.

Regenerated the test files so they contain the checksum. Also added
negative test to ensure error when the checksums don't match.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195191 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Yuchen Wu
2013-11-20 04:15:05 +00:00
parent 523d929368
commit d23c759c0f
9 changed files with 102 additions and 50 deletions

View File

@@ -45,15 +45,15 @@ public:
/// readGCOVFormat - Read GCOV signature at the beginning of buffer.
GCOV::GCOVFormat readGCOVFormat() {
StringRef Magic = Buffer->getBuffer().slice(0, 12);
Cursor = 12;
if (Magic == "oncg*404MVLL")
StringRef Magic = Buffer->getBuffer().slice(0, 8);
Cursor = 8;
if (Magic == "oncg*404")
return GCOV::GCNO_404;
else if (Magic == "oncg*204MVLL")
else if (Magic == "oncg*204")
return GCOV::GCNO_402;
else if (Magic == "adcg*404MVLL")
else if (Magic == "adcg*404")
return GCOV::GCDA_404;
else if (Magic == "adcg*204MVLL")
else if (Magic == "adcg*204")
return GCOV::GCDA_402;
Cursor = 0;
@@ -193,12 +193,13 @@ private:
/// (.gcno and .gcda).
class GCOVFile {
public:
GCOVFile() : Functions(), RunCount(0), ProgramCount(0) {}
GCOVFile() : Checksum(0), Functions(), RunCount(0), ProgramCount(0) {}
~GCOVFile();
bool read(GCOVBuffer &Buffer);
void dump() const;
void collectLineCounts(FileInfo &FI);
private:
uint32_t Checksum;
SmallVector<GCOVFunction *, 16> Functions;
uint32_t RunCount;
uint32_t ProgramCount;