summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2019-06-06 06:40:01 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2019-06-06 06:40:01 +0000
commit9b887214abde2794e6475284d08ce78b216c4979 (patch)
tree2caae05c541f7d426da27bdb9f674d6467c47dcb
parentad7643b1a8dfe5daa0ed601a6e46e85db0c2caaa (diff)
parentcc1b0fba71b55dabf3a3a5d4d4f6e5c806b7db6c (diff)
downloadextras-9b887214abde2794e6475284d08ce78b216c4979.tar.gz
Snap for 5637155 from cc1b0fba71b55dabf3a3a5d4d4f6e5c806b7db6c to qt-qpr1-release
Change-Id: I583aee87c82ec15034772779f5b58db298936390
-rw-r--r--toolchain-extras/profile-extras-test.cpp2
-rw-r--r--toolchain-extras/profile-extras.cpp18
2 files changed, 18 insertions, 2 deletions
diff --git a/toolchain-extras/profile-extras-test.cpp b/toolchain-extras/profile-extras-test.cpp
index 0cc4cef8..5e48a646 100644
--- a/toolchain-extras/profile-extras-test.cpp
+++ b/toolchain-extras/profile-extras-test.cpp
@@ -28,7 +28,7 @@ void __gcov_flush() {
}
}
-static const char kCoveragePropName[] = "coverage.flush";
+static const char kCoveragePropName[] = "debug.coverage.flush";
TEST(profile_extras, smoke) {
flush_count = 0;
diff --git a/toolchain-extras/profile-extras.cpp b/toolchain-extras/profile-extras.cpp
index 3af46a10..2d685084 100644
--- a/toolchain-extras/profile-extras.cpp
+++ b/toolchain-extras/profile-extras.cpp
@@ -17,7 +17,9 @@
#include <errno.h>
#include <pthread.h>
#include <signal.h>
+#include <stdlib.h>
#include <string.h>
+#include <libgen.h> // For POSIX basename().
// Use _system_properties.h to use __system_property_wait_any()
#define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_
@@ -33,7 +35,7 @@ static void gcov_signal_handler(__unused int signum) {
__gcov_flush();
}
-static const char kCoveragePropName[] = "coverage.flush";
+static const char kCoveragePropName[] = "debug.coverage.flush";
// In a loop, wait for any change to sysprops and trigger a __gcov_flush when
// <kCoveragePropName> sysprop transistions to "1" after a transistion to "0".
@@ -84,6 +86,20 @@ __attribute__((constructor)) int init_profile_extras(void) {
return -1;
}
+ // 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
+ // platform, but can be done on any version after Android L, when
+ // getprogname() was added.
+#if defined(__ANDROID_API__) && __ANDROID_API__ >= __ANDROID_API_L__
+ const char *prog_basename = basename(getprogname());
+ if (strncmp(prog_basename, "zygote", strlen("zygote")) == 0) {
+ return 0;
+ }
+ if (strncmp(prog_basename, "app_process", strlen("app_process")) == 0) {
+ return 0;
+ }
+#endif
+
pthread_t thread;
int error = pthread_create(&thread, nullptr, property_watch_loop, nullptr);
if (error != 0) {