<div dir="ltr">Hi Reid, Zach, <div><br></div><div>I've introduced yet another kind of coverage instrumentation, which doesn't work on windows out of the box. </div><div>Could you please help? </div><div>This is again something about section naming. </div><div><br></div><div>--kcc</div><div><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Aug 1, 2017 at 1:27 AM, Vitaly Buka <span dir="ltr"><<a href="mailto:vitalybuka@google.com" target="_blank">vitalybuka@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Broken by this patch <div><a href="http://lab.llvm.org:8011/builders/sanitizer-windows/builds/14792" target="_blank">http://lab.llvm.org:8011/build<wbr>ers/sanitizer-windows/builds/<wbr>14792</a><br></div></div><div class="m_2989289892906394904HOEnZb"><div class="m_2989289892906394904h5"><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jul 31, 2017 at 5:48 PM, Kostya Serebryany via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: kcc<br>
Date: Mon Jul 31 17:48:44 2017<br>
New Revision: 309646<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=309646&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject?rev=309646&view=rev</a><br>
Log:<br>
[libFuzzer] enable -fsanitize-coverage=pc-table for all tests<br>
<br>
Modified:<br>
    llvm/trunk/lib/Fuzzer/FuzzerTr<wbr>acePC.cpp<br>
    llvm/trunk/lib/Fuzzer/FuzzerTr<wbr>acePC.h<br>
    llvm/trunk/lib/Fuzzer/test/CMa<wbr>keLists.txt<br>
    llvm/trunk/lib/Fuzzer/test/inl<wbr>ine-8bit-counters.test<br>
<br>
Modified: llvm/trunk/lib/Fuzzer/FuzzerTr<wbr>acePC.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/FuzzerTracePC.cpp?rev=309646&r1=309645&r2=309646&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/llvm/trunk/lib/Fuzzer/Fu<wbr>zzerTracePC.cpp?rev=309646&r1=<wbr>309645&r2=309646&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/lib/Fuzzer/FuzzerTr<wbr>acePC.cpp (original)<br>
+++ llvm/trunk/lib/Fuzzer/FuzzerTr<wbr>acePC.cpp Mon Jul 31 17:48:44 2017<br>
@@ -72,7 +72,7 @@ void TracePC::HandlePCsInit(const uint8_<br>
   if (NumPCTables && ModulePCTable[NumPCTables - 1].Start == B) return;<br>
   assert(NumPCTables < sizeof(ModulePCTable) / sizeof(ModulePCTable[0]));<br>
   ModulePCTable[NumPCTables++] = {B, E};<br>
-  NumPCsInPCTables = E - B;<br>
+  NumPCsInPCTables += E - B;<br>
 }<br>
<br>
 void TracePC::HandleInit(uint32_t *Start, uint32_t *Stop) {<br>
@@ -95,26 +95,36 @@ void TracePC::HandleInit(uint32_t *Start<br>
<br>
 void TracePC::PrintModuleInfo() {<br>
   if (NumGuards) {<br>
-    Printf("INFO: Loaded %zd modules (%zd guards): ", NumModules, NumGuards);<br>
+    Printf("INFO: Loaded %zd modules   (%zd guards): ", NumModules, NumGuards);<br>
     for (size_t i = 0; i < NumModules; i++)<br>
-      Printf("[%p, %p), ", Modules[i].Start, Modules[i].Stop);<br>
+      Printf("%zd [%p, %p), ", Modules[i].Stop - Modules[i].Start,<br>
+             Modules[i].Start, Modules[i].Stop);<br>
     Printf("\n");<br>
   }<br>
   if (NumModulesWithInline8bitCount<wbr>ers) {<br>
-    Printf("INFO: Loaded %zd modules with %zd inline 8-bit counters: ",<br>
+    Printf("INFO: Loaded %zd modules   (%zd inline 8-bit counters): ",<br>
            NumModulesWithInline8bitCounte<wbr>rs, NumInline8bitCounters);<br>
     for (size_t i = 0; i < NumModulesWithInline8bitCounte<wbr>rs; i++)<br>
-      Printf("[%p, %p), ", ModuleCounters[i].Start, ModuleCounters[i].Stop);<br>
+      Printf("%zd [%p, %p), ", ModuleCounters[i].Stop - ModuleCounters[i].Start,<br>
+             ModuleCounters[i].Start, ModuleCounters[i].Stop);<br>
     Printf("\n");<br>
   }<br>
   if (NumPCTables) {<br>
-    Printf("INFO: Loaded %zd PC tables,   %zd PCs: ", NumPCTables,<br>
+    Printf("INFO: Loaded %zd PC tables (%zd PCs): ", NumPCTables,<br>
            NumPCsInPCTables);<br>
     for (size_t i = 0; i < NumPCTables; i++) {<br>
-      Printf("[%p,%p), ", ModulePCTable[i].Start, ModulePCTable[i].Stop,<br>
-             ModulePCTable[i].Stop - ModulePCTable[i].Start);<br>
+      Printf("%zd [%p,%p), ", ModulePCTable[i].Stop - ModulePCTable[i].Start,<br>
+             ModulePCTable[i].Start, ModulePCTable[i].Stop);<br>
     }<br>
     Printf("\n");<br>
+<br>
+    if ((NumGuards && NumGuards != NumPCsInPCTables) ||<br>
+        (NumInline8bitCounters && NumInline8bitCounters != NumPCsInPCTables)) {<br>
+      Printf("ERROR: The size of coverage PC tables does not match the"<br>
+             " number of instrumented PCs. This might be a bug in the compiler,"<br>
+             " please contact the libFuzzer developers.\n");<br>
+      _Exit(1);<br>
+    }<br>
   }<br>
 }<br>
<br>
<br>
Modified: llvm/trunk/lib/Fuzzer/FuzzerTr<wbr>acePC.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/FuzzerTracePC.h?rev=309646&r1=309645&r2=309646&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/llvm/trunk/lib/Fuzzer/Fu<wbr>zzerTracePC.h?rev=309646&r1=30<wbr>9645&r2=309646&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/lib/Fuzzer/FuzzerTr<wbr>acePC.h (original)<br>
+++ llvm/trunk/lib/Fuzzer/FuzzerTr<wbr>acePC.h Mon Jul 31 17:48:44 2017<br>
@@ -86,7 +86,8 @@ class TracePC {<br>
<br>
   void ResetMaps() {<br>
     ValueProfileMap.Reset();<br>
-    memset(Counters(), 0, GetNumPCs());<br>
+    if (NumModules)<br>
+      memset(Counters(), 0, GetNumPCs());<br>
     ClearExtraCounters();<br>
     ClearInlineCounters();<br>
   }<br>
<br>
Modified: llvm/trunk/lib/Fuzzer/test/CMa<wbr>keLists.txt<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/test/CMakeLists.txt?rev=309646&r1=309645&r2=309646&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/llvm/trunk/lib/Fuzzer/te<wbr>st/CMakeLists.txt?rev=309646&r<wbr>1=309645&r2=309646&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/lib/Fuzzer/test/CMa<wbr>keLists.txt (original)<br>
+++ llvm/trunk/lib/Fuzzer/test/CMa<wbr>keLists.txt Mon Jul 31 17:48:44 2017<br>
@@ -15,7 +15,7 @@ foreach (VARNAME ${variables_to_filter})<br>
 endforeach()<br>
<br>
 # Enable the coverage instrumentation (it is disabled for the Fuzzer lib).<br>
-set(CMAKE_CXX_FLAGS "${LIBFUZZER_FLAGS_BASE} -fsanitize-coverage=trace-pc-g<wbr>uard,indirect-calls,trace-cmp,<wbr>trace-div,trace-gep -gline-tables-only")<br>
+set(CMAKE_CXX_FLAGS "${LIBFUZZER_FLAGS_BASE} -fsanitize-coverage=trace-pc-g<wbr>uard,indirect-calls,trace-cmp,<wbr>trace-div,trace-gep,pc-table -gline-tables-only")<br>
<br>
 if(MSVC)<br>
   # For tests use the CRT specified for release build<br>
<br>
Modified: llvm/trunk/lib/Fuzzer/test/inl<wbr>ine-8bit-counters.test<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/test/inline-8bit-counters.test?rev=309646&r1=309645&r2=309646&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/llvm/trunk/lib/Fuzzer/te<wbr>st/inline-8bit-counters.test?r<wbr>ev=309646&r1=309645&r2=309646&<wbr>view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/lib/Fuzzer/test/inl<wbr>ine-8bit-counters.test (original)<br>
+++ llvm/trunk/lib/Fuzzer/test/inl<wbr>ine-8bit-counters.test Mon Jul 31 17:48:44 2017<br>
@@ -1,4 +1,4 @@<br>
 REQUIRES: linux<br>
-CHECK: INFO: Loaded 1 modules with {{.*}} inline 8-bit counters<br>
+CHECK: INFO: Loaded 1 modules ({{.*}} inline 8-bit counters)<br>
 CHECK: BINGO<br>
 RUN: not LLVMFuzzer-SimpleTest-Inline8b<wbr>itCounters -runs=1000000 -seed=1 2>&1 | FileCheck %s<br>
<br>
<br>
______________________________<wbr>_________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div></div></div>