mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-25 04:02:41 +01:00
[llvm-cov gcov] Don't suppress .gcov output if .gcda is corrupted
If .gcda is corrupted, gcov continues to produce a .gcov and just assumes execution counts are zeros. This is reasonable, because the program can corrupt its .gcda output. The code path should be similar to the code path without .gcda.
This commit is contained in:
parent
c3ee50d3ed
commit
3ac41a5d21
@ -98,7 +98,6 @@ public:
|
||||
} else if (magic == "adcg") {
|
||||
de = DataExtractor(buf.substr(4), true, 0);
|
||||
} else {
|
||||
errs() << "unexpected file type: " << magic << "\n";
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -742,10 +742,10 @@ void FileInfo::print(raw_ostream &InfoOS, StringRef MainFilename,
|
||||
<< f->Name << '\n';
|
||||
const LineData &line = LineInfo[source.filename];
|
||||
for (uint32_t lineNum = 0; lineNum != line.LastLine; ++lineNum) {
|
||||
BlockLines::const_iterator blocksIt = line.Blocks.find(lineNum);
|
||||
if (blocksIt == line.Blocks.end())
|
||||
BlockLines::const_iterator BlocksIt = line.Blocks.find(lineNum);
|
||||
if (BlocksIt == line.Blocks.end())
|
||||
continue;
|
||||
const BlockVector &blocks = blocksIt->second;
|
||||
const BlockVector &blocks = BlocksIt->second;
|
||||
// GCC 8 (r254259) added third third field for Ada:
|
||||
// lcount:<line>,<count>,<has_unexecuted_blocks>
|
||||
// We don't need the third field.
|
||||
|
@ -169,11 +169,17 @@ NO-GCDA-NEXT: Creating 'test.h.gcov'
|
||||
# Invalid gcno file.
|
||||
RUN: llvm-cov gcov test.c -gcno=test_read_fail.gcno
|
||||
|
||||
# Not a .gcda file. Error but keep the .gcov output.
|
||||
RUN: echo invalid > not.gcda
|
||||
RUN: llvm-cov gcov test.c -gcda=not.gcda 2> %t.err | FileCheck %s --check-prefix=NO-GCDA
|
||||
RUN: FileCheck %s --check-prefix=NOT-GCDA < %t.err
|
||||
NOT-GCDA: not.gcda:not a gcov data file
|
||||
|
||||
# Bad file checksum on gcda.
|
||||
RUN: llvm-cov gcov test.c -gcda=test_file_checksum_fail.gcda
|
||||
RUN: llvm-cov gcov test.c -gcda=test_file_checksum_fail.gcda 2> %t.err | FileCheck %s --check-prefix=NO-GCDA
|
||||
|
||||
# Bad function checksum on gcda
|
||||
RUN: llvm-cov gcov test.c -gcda=test_func_checksum_fail.gcda
|
||||
RUN: llvm-cov gcov test.c -gcda=test_func_checksum_fail.gcda 2> %t.err | FileCheck %s --check-prefix=NO-GCDA
|
||||
|
||||
# Has arcs from exit blocks
|
||||
RUN-DISABLED: llvm-cov gcov test_exit_block_arcs.c 2>&1 | FileCheck %s -check-prefix=EXIT_BLOCK_ARCS
|
||||
|
@ -65,11 +65,11 @@ static void reportCoverage(StringRef SourceFile, StringRef ObjectDir,
|
||||
// Clear the filename to make it clear we didn't read anything.
|
||||
GCDA = "-";
|
||||
} else {
|
||||
GCOVBuffer GCDA_GB(GCDA_Buff.get().get());
|
||||
if (!GF.readGCDA(GCDA_GB)) {
|
||||
GCOVBuffer gcda_buf(GCDA_Buff.get().get());
|
||||
if (!gcda_buf.readGCDAFormat())
|
||||
errs() << GCDA << ":not a gcov data file\n";
|
||||
else if (!GF.readGCDA(gcda_buf))
|
||||
errs() << "Invalid .gcda File!\n";
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (DumpGCOV)
|
||||
|
Loading…
Reference in New Issue
Block a user