diff options
author | Oliver Nguyen <olivernguyen@google.com> | 2020-01-31 14:44:58 -0800 |
---|---|---|
committer | Oliver Nguyen <olivernguyen@google.com> | 2020-01-31 14:44:58 -0800 |
commit | 2a83bc465731af59389afe0de6defc5102ebdd07 (patch) | |
tree | a7009aab2af36672fc7c6c6e863189bada32f535 /toolchain-extras | |
parent | 18f8a1a981a5aeac889b80f52e83e171d9db3781 (diff) | |
download | extras-2a83bc465731af59389afe0de6defc5102ebdd07.tar.gz |
Remove unused property-watcher thread for native coverage flushing.
Test: Unit tests
Bug: 148406394
Change-Id: Ice8f6d59f48a489fe07c89f7f9b16428de3922ed
Diffstat (limited to 'toolchain-extras')
-rw-r--r-- | toolchain-extras/profile-extras-test.cpp | 21 | ||||
-rw-r--r-- | toolchain-extras/profile-extras.cpp | 66 |
2 files changed, 0 insertions, 87 deletions
diff --git a/toolchain-extras/profile-extras-test.cpp b/toolchain-extras/profile-extras-test.cpp index 0e52f15c..38acf734 100644 --- a/toolchain-extras/profile-extras-test.cpp +++ b/toolchain-extras/profile-extras-test.cpp @@ -28,8 +28,6 @@ void __gcov_flush() { } } -static const char kCoveragePropName[] = "debug.coverage.flush"; - TEST(profile_extras, smoke) { flush_count = 0; @@ -37,23 +35,4 @@ TEST(profile_extras, smoke) { kill(getpid(), COVERAGE_FLUSH_SIGNAL); sleep(2); ASSERT_EQ(1, flush_count); - - // kCoveragePropName from "0" -> "1" -> "0" -> "1" should trigger two flushes. - // transition 1 - __system_property_set(kCoveragePropName, "0"); - sleep(2); - ASSERT_EQ(1, flush_count); - - __system_property_set(kCoveragePropName, "1"); - sleep(2); - ASSERT_EQ(2, flush_count); - - // transition 2 - __system_property_set(kCoveragePropName, "0"); - sleep(2); - ASSERT_EQ(2, flush_count); - - __system_property_set(kCoveragePropName, "1"); - sleep(2); - ASSERT_EQ(3, flush_count); } diff --git a/toolchain-extras/profile-extras.cpp b/toolchain-extras/profile-extras.cpp index d2a541cd..93f7f8f1 100644 --- a/toolchain-extras/profile-extras.cpp +++ b/toolchain-extras/profile-extras.cpp @@ -43,58 +43,10 @@ static void gcov_signal_handler(int signum) { } } -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". -void *property_watch_loop(__unused void *arg) { - uint32_t serial = 0; - - // __gcov_flush is called on a state transition from 0 to 1. Initialize state - // to 1 so a process spinning up when the sysprop is already set does not - // immediately dump its coverage. - int previous_state = 1; - - while (true) { - // Use deprecated __system_property_wait_any for backward compatibility. - serial = __system_property_wait_any(serial); - const struct prop_info *pi = __system_property_find(kCoveragePropName); - if (!pi) - continue; - - char value[PROP_VALUE_MAX]; - __system_property_read(pi, nullptr, value); - if (strcmp(value, "0") == 0) { - previous_state = 0; - } else if (strcmp(value, "1") == 0) { - if (previous_state == 0) { - __gcov_flush(); - } - previous_state = 1; - } - } -} - -#if defined(__ANDROID_API__) && __ANDROID_API__ >= __ANDROID_API_L__ -static char prop_watch_disabled_procs[][128] = { - "zygote", - "zygote32", - "app_process", - "app_process32", - "adbd", - "init", -}; - -static size_t prop_watch_num_disabled_procs = \ - sizeof(prop_watch_disabled_procs) / sizeof(prop_watch_disabled_procs[0]); -#endif - __attribute__((weak)) int init_profile_extras_once = 0; // Initialize libprofile-extras: // - Install a signal handler that triggers __gcov_flush on <COVERAGE_FLUSH_SIGNAL>. -// - Create a thread that calls __gcov_flush when <kCoveragePropName> sysprop -// transistions to "1" after a transistion to "0". // // We want this initiazlier to run during load time. // @@ -119,24 +71,6 @@ __attribute__((constructor)) int init_profile_extras(void) { } 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 - // 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()); - for (size_t i = 0; i < prop_watch_num_disabled_procs; i ++) { - if (strcmp(prog_basename, prop_watch_disabled_procs[i]) == 0) { - return 0; - } - } -#endif - - pthread_t thread; - int error = pthread_create(&thread, nullptr, property_watch_loop, nullptr); - if (error != 0) { - return -1; - } return 0; } } |