OSDN Git Service

[sancov] Ignore PC samples with value 0
authorPetr Hosek <phosek@chromium.org>
Thu, 11 Jul 2019 22:59:23 +0000 (22:59 +0000)
committerPetr Hosek <phosek@chromium.org>
Thu, 11 Jul 2019 22:59:23 +0000 (22:59 +0000)
The sancov runtime for the (Fuchsia) Zircon kernel delivers results
in the standard format, but as the full array of possible samples
with 0 in uncovered slots. That runtime delivers "live" data and
has no final "export" pass to compactify out the uncovered slots,
and it seems silly to require another offline tool just for that.

Patch By: mcgrathr
Differential Revision: https://reviews.llvm.org/D63695

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@365839 91177308-0d34-0410-b5e6-96231b3b80d8

tools/sancov/sancov.cpp

index dd2b2dd..acf47b9 100644 (file)
@@ -259,6 +259,10 @@ RawCoverage::read(const std::string &FileName) {
     return make_error_code(errc::illegal_byte_sequence);
   }
 
+  // Ignore slots that are zero, so a runtime implementation is not required
+  // to compactify the data.
+  Addrs->erase(0);
+
   return std::unique_ptr<RawCoverage>(new RawCoverage(std::move(Addrs)));
 }
 
@@ -1229,7 +1233,7 @@ int main(int Argc, char **Argv) {
   llvm::InitializeAllTargetMCs();
   llvm::InitializeAllDisassemblers();
 
-  cl::ParseCommandLineOptions(Argc, Argv, 
+  cl::ParseCommandLineOptions(Argc, Argv,
       "Sanitizer Coverage Processing Tool (sancov)\n\n"
       "  This tool can extract various coverage-related information from: \n"
       "  coverage-instrumented binary files, raw .sancov files and their "