[PATCH] D20285: [Coverage] Ensure that coverage mapping data has an expected alignment in 'covmapping' files.
Igor Kudrin via llvm-commits
llvm-commits at lists.llvm.org
Wed May 18 00:49:40 PDT 2016
This revision was automatically updated to reflect the committed changes.
Closed by commit rL269887: [Coverage] Ensure that coverage mapping data has an expected alignment in… (authored by ikudrin).
Changed prior to commit:
http://reviews.llvm.org/D20285?vs=57341&id=57566#toc
Repository:
rL LLVM
http://reviews.llvm.org/D20285
Files:
llvm/trunk/lib/ProfileData/Coverage/CoverageMappingReader.cpp
llvm/trunk/test/tools/llvm-cov/Inputs/combine_expansions.covmapping
llvm/trunk/test/tools/llvm-cov/Inputs/highlightedRanges.covmapping
llvm/trunk/test/tools/llvm-cov/Inputs/lineExecutionCounts.covmapping
llvm/trunk/test/tools/llvm-cov/Inputs/prevent_false_instantiations.covmapping
llvm/trunk/test/tools/llvm-cov/Inputs/regionMarkers.covmapping
llvm/trunk/test/tools/llvm-cov/Inputs/showExpansions.covmapping
llvm/trunk/test/tools/llvm-cov/Inputs/templateInstantiations.covmapping
llvm/trunk/tools/llvm-cov/TestingSupport.cpp
Index: llvm/trunk/lib/ProfileData/Coverage/CoverageMappingReader.cpp
===================================================================
--- llvm/trunk/lib/ProfileData/Coverage/CoverageMappingReader.cpp
+++ llvm/trunk/lib/ProfileData/Coverage/CoverageMappingReader.cpp
@@ -491,6 +491,13 @@
return coveragemap_error::malformed;
ProfileNames.create(Data.substr(0, ProfileNamesSize), Address);
CoverageMapping = Data.substr(ProfileNamesSize);
+ // Skip the padding bytes because coverage map data has an alignment of 8.
+ if (CoverageMapping.size() < 1)
+ return coveragemap_error::truncated;
+ size_t Pad = alignmentAdjustment(CoverageMapping.data(), 8);
+ if (CoverageMapping.size() < Pad)
+ return coveragemap_error::malformed;
+ CoverageMapping = CoverageMapping.substr(Pad);
return std::error_code();
}
Index: llvm/trunk/tools/llvm-cov/TestingSupport.cpp
===================================================================
--- llvm/trunk/tools/llvm-cov/TestingSupport.cpp
+++ llvm/trunk/tools/llvm-cov/TestingSupport.cpp
@@ -88,7 +88,11 @@
OS << "llvmcovmtestdata";
encodeULEB128(ProfileNamesData.size(), OS);
encodeULEB128(ProfileNamesAddress, OS);
- OS << ProfileNamesData << CoverageMappingData;
+ OS << ProfileNamesData;
+ // Coverage mapping data is expected to have an alignment of 8.
+ for (unsigned Pad = OffsetToAlignment(OS.tell(), 8); Pad; --Pad)
+ OS.write(uint8_t(0));
+ OS << CoverageMappingData;
return 0;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D20285.57566.patch
Type: text/x-patch
Size: 1476 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160518/f1e16c37/attachment.bin>
More information about the llvm-commits
mailing list