summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2020-02-05 02:27:35 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2020-02-05 02:27:35 +0000
commitc1b9e77597d1365bf5cba14836bbffdf358296bc (patch)
tree8c64e6ae9306cdbdbda36580bc247a36a051e1fa
parenta328d2156f8b8fdb7ddfac66162ad098e9c8d455 (diff)
parent29e06f5526a2dd48c9f19ef7f238804f84c03c30 (diff)
downloadextras-android10-qpr3-s1-release.tar.gz
Change-Id: I4516db284c43be15bb2ae5ed24a0505024d5a8cc
-rw-r--r--toolchain-extras/profile-extras.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/toolchain-extras/profile-extras.cpp b/toolchain-extras/profile-extras.cpp
index b7a9318a..7d78a0a5 100644
--- a/toolchain-extras/profile-extras.cpp
+++ b/toolchain-extras/profile-extras.cpp
@@ -31,8 +31,16 @@ extern "C" {
void __gcov_flush(void);
-static void gcov_signal_handler(__unused int signum) {
+// storing SIG_ERR helps us detect (unlikely) looping.
+static sighandler_t chained_gcov_signal_handler = SIG_ERR;
+
+static void gcov_signal_handler(int signum) {
__gcov_flush();
+ if (chained_gcov_signal_handler != SIG_ERR &&
+ chained_gcov_signal_handler != SIG_IGN &&
+ chained_gcov_signal_handler != SIG_DFL) {
+ (chained_gcov_signal_handler)(signum);
+ }
}
static const char kCoveragePropName[] = "debug.coverage.flush";
@@ -101,10 +109,15 @@ __attribute__((constructor)) int init_profile_extras(void) {
return 0;
init_profile_extras_once = 1;
+ // is this instance already registered?
+ if (chained_gcov_signal_handler != SIG_ERR) {
+ return -1;
+ }
sighandler_t ret1 = signal(GCOV_FLUSH_SIGNAL, gcov_signal_handler);
if (ret1 == SIG_ERR) {
return -1;
}
+ chained_gcov_signal_handler = ret1;
// Do not create thread running property_watch_loop for zygote (it can get
// invoked as zygote or app_process). This check is only needed for the