[PATCH] D17670: [sancov] print_coverage_points command.

Mike Aizatsky via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 26 18:26:24 PST 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL262104: [sancov] print_coverage_points command. (authored by aizatsky).

Changed prior to commit:
  http://reviews.llvm.org/D17670?vs=49278&id=49279#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D17670

Files:
  llvm/trunk/test/tools/sancov/print_coverage_pcs.test
  llvm/trunk/tools/sancov/sancov.cc

Index: llvm/trunk/test/tools/sancov/print_coverage_pcs.test
===================================================================
--- llvm/trunk/test/tools/sancov/print_coverage_pcs.test
+++ llvm/trunk/test/tools/sancov/print_coverage_pcs.test
@@ -0,0 +1,20 @@
+REQUIRES: x86_64-linux
+RUN: sancov -print-coverage-pcs %p/Inputs/test-linux_x86_64 | FileCheck %s
+
+CHECK: 0x4cced1
+CHECK: 0x4ccf01
+CHECK: 0x4dbe2b
+CHECK: 0x4dbf72
+CHECK: 0x4dbfc2
+CHECK: 0x4dbfec
+CHECK: 0x4dc033
+CHECK: 0x4dc06a
+CHECK: 0x4dc09d
+CHECK: 0x4dc0d0
+CHECK: 0x4dc17f
+CHECK: 0x4dc1c6
+CHECK: 0x4dc20d
+CHECK: 0x4dc237
+CHECK: 0x4dc265
+CHECK: 0x4dc34c
+
Index: llvm/trunk/tools/sancov/sancov.cc
===================================================================
--- llvm/trunk/tools/sancov/sancov.cc
+++ llvm/trunk/tools/sancov/sancov.cc
@@ -59,14 +59,17 @@
 
 enum ActionType {
   PrintAction,
+  PrintCovPointsAction,
   CoveredFunctionsAction,
   NotCoveredFunctionsAction,
   HtmlReportAction
 };
 
 cl::opt<ActionType> Action(
     cl::desc("Action (required)"), cl::Required,
     cl::values(clEnumValN(PrintAction, "print", "Print coverage addresses"),
+               clEnumValN(PrintCovPointsAction, "print-coverage-pcs",
+                          "Print coverage instrumentation points addresses."),
                clEnumValN(CoveredFunctionsAction, "covered-functions",
                           "Print all covered funcions."),
                clEnumValN(NotCoveredFunctionsAction, "not-covered-functions",
@@ -449,6 +452,14 @@
   return Result;
 }
 
+static void printCovPoints(std::string ObjFile, raw_ostream &OS) {
+  for (uint64_t Addr : getCoveragePoints(ObjFile)) {
+    OS << "0x";
+    OS.write_hex(Addr);
+    OS << "\n";
+  }
+}
+
 static std::string escapeHtml(const std::string &S) {
   std::string Result;
   Result.reserve(S.size());
@@ -1092,6 +1103,12 @@
     FailIfError(CovData);
     CovData.get()->printAddrs(outs());
     return 0;
+  } else if (Action == PrintCovPointsAction) {
+    // -print-coverage-points doesn't need coverage files.
+    for (std::string ObjFile : ClInputFiles) {
+      printCovPoints(ObjFile, outs());
+    }
+    return 0;
   }
 
   auto CovDataSet = CoverageDataSet::readCmdArguments(ClInputFiles);
@@ -1115,6 +1132,7 @@
     return 0;
   }
   case PrintAction:
+  case PrintCovPointsAction:
     llvm_unreachable("unsupported action");
   }
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D17670.49279.patch
Type: text/x-patch
Size: 2391 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160227/09952c91/attachment.bin>


More information about the llvm-commits mailing list