Bug 1397505 - Only support dumping/resetting coverage counters with GCC builds. r=froydnj
authorMarco Castelluccio <mcastelluccio@mozilla.com>
Thu, 07 Sep 2017 00:31:03 +0200
changeset 429018 a899f7d9b30d1cdbc8374f02518efc70230c6d4f
parent 429017 6affb3d1572d94b77dc117e1a7dda7f0fc7c105c
child 429019 01d736f31b392d254f8e94abeaed56abbf621249
push id7761
push userjlund@mozilla.com
push dateFri, 15 Sep 2017 00:19:52 +0000
treeherdermozilla-beta@c38455951db4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1397505
milestone57.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1397505 - Only support dumping/resetting coverage counters with GCC builds. r=froydnj
tools/code-coverage/CodeCoverageHandler.cpp
--- a/tools/code-coverage/CodeCoverageHandler.cpp
+++ b/tools/code-coverage/CodeCoverageHandler.cpp
@@ -11,40 +11,58 @@
 #include "mozilla/DebugOnly.h"
 #include "nsAppRunner.h"
 
 using namespace mozilla;
 using namespace mozilla::ipc;
 
 // The __gcov_dump function writes the coverage counters to gcda files.
 // The __gcov_reset function resets the coverage counters to zero.
-// They are defined at https://github.com/gcc-mirror/gcc/blob/aad93da1a579b9ae23ede6b9cf8523360f0a08b4/libgcc/libgcov-interface.c
+// They are defined at https://github.com/gcc-mirror/gcc/blob/aad93da1a579b9ae23ede6b9cf8523360f0a08b4/libgcc/libgcov-interface.c.
 // __gcov_flush is protected by a mutex, __gcov_dump and __gcov_reset aren't.
 // So we are using a CrossProcessMutex to protect them.
 
+#if defined(__GNUC__) && !defined(__clang__)
 extern "C" void __gcov_dump();
 extern "C" void __gcov_reset();
 
+void counters_dump() {
+  __gcov_dump();
+}
+
+void counters_reset() {
+  __gcov_reset();
+}
+#else
+void counters_dump() {
+  /* Do nothing */
+}
+
+void counters_reset() {
+  /* Do nothing */
+}
+#endif
+
 StaticAutoPtr<CodeCoverageHandler> CodeCoverageHandler::instance;
 
 void CodeCoverageHandler::DumpCounters(int)
 {
   CrossProcessMutexAutoLock lock(*CodeCoverageHandler::Get()->GetMutex());
 
   printf_stderr("[CodeCoverage] Requested dump.\n");
-  __gcov_dump();
+  counters_dump();
   printf_stderr("[CodeCoverage] Dump completed.\n");
 }
 
 void CodeCoverageHandler::ResetCounters(int)
 {
   CrossProcessMutexAutoLock lock(*CodeCoverageHandler::Get()->GetMutex());
 
   printf_stderr("[CodeCoverage] Requested reset.\n");
-  __gcov_reset();
+  counters_reset();
   printf_stderr("[CodeCoverage] Reset completed.\n");
 }
 
 void CodeCoverageHandler::SetSignalHandlers()
 {
   printf_stderr("[CodeCoverage] Setting handlers for process %d.\n", getpid());
 
   struct sigaction dump_sa;