Bug 1390945 - Make GCOV signal handlers work in --disable-debug mode. r?froydnj draft
authorChristian Holler <choller@mozilla.com>
Wed, 16 Aug 2017 20:39:26 +0200
changeset 647682 b8746336c3c8fcbbf1f7071cae6978553416418b
parent 647681 85d411f74b4966bea18f6b75d25dbe64bc8cc746
child 726596 e5a08a743e3b5f0d117169bb5e381bd0a936b912
push id74502
push usercholler@mozilla.com
push dateWed, 16 Aug 2017 18:40:01 +0000
reviewersfroydnj
bugs1390945
milestone57.0a1
Bug 1390945 - Make GCOV signal handlers work in --disable-debug mode. r?froydnj MozReview-Commit-ID: Lm8IhokH3ns
tools/code-coverage/CodeCoverageHandler.cpp
--- a/tools/code-coverage/CodeCoverageHandler.cpp
+++ b/tools/code-coverage/CodeCoverageHandler.cpp
@@ -3,16 +3,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include <signal.h>
 #include <stdio.h>
 #include <unistd.h>
 #include "mozilla/CodeCoverageHandler.h"
 #include "mozilla/ClearOnShutdown.h"
+#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
@@ -45,23 +46,25 @@ void CodeCoverageHandler::ResetCounters(
 void CodeCoverageHandler::SetSignalHandlers()
 {
   printf_stderr("[CodeCoverage] Setting handlers for process %d.\n", getpid());
 
   struct sigaction dump_sa;
   dump_sa.sa_handler = CodeCoverageHandler::DumpCounters;
   dump_sa.sa_flags = SA_RESTART;
   sigemptyset(&dump_sa.sa_mask);
-  MOZ_ASSERT(sigaction(SIGUSR1, &dump_sa, nullptr) == 0);
+  DebugOnly<int> r1 = sigaction(SIGUSR1, &dump_sa, nullptr);
+  MOZ_ASSERT(r1 == 0, "Failed to install GCOV SIGUSR1 handler");
 
   struct sigaction reset_sa;
   reset_sa.sa_handler = CodeCoverageHandler::ResetCounters;
   reset_sa.sa_flags = SA_RESTART;
   sigemptyset(&reset_sa.sa_mask);
-  MOZ_ASSERT(sigaction(SIGUSR2, &reset_sa, nullptr) == 0);
+  DebugOnly<int> r2 = sigaction(SIGUSR2, &reset_sa, nullptr);
+  MOZ_ASSERT(r2 == 0, "Failed to install GCOV SIGUSR2 handler");
 }
 
 CodeCoverageHandler::CodeCoverageHandler()
   : mGcovLock("GcovLock")
 {
   SetSignalHandlers();
 }