summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2020-02-03 22:48:42 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2020-02-03 22:48:42 +0000
commit29e06f5526a2dd48c9f19ef7f238804f84c03c30 (patch)
tree8c64e6ae9306cdbdbda36580bc247a36a051e1fa
parentb47555debc7373287ee2ae960df2a3e55579c52b (diff)
parent572460c417e6e0fd9337e5ef6507335d6d40d42b (diff)
downloadextras-29e06f5526a2dd48c9f19ef7f238804f84c03c30.tar.gz
Dump coverage for all objects (a.out + dlopen()'d .so's) am: 572460c417
Change-Id: Id9f3f01cb03f89a300ccb680559db59c47bd13d4
-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