diff options
author | Alex Ray <aray@google.com> | 2012-11-20 01:39:09 -0800 |
---|---|---|
committer | Alex Ray <aray@google.com> | 2012-11-28 13:56:49 -0800 |
commit | e7bb7bca4f4036c213763673627e1eb6c2c2fdd6 (patch) | |
tree | 742342c4c357732db81ac8a061658c265975f97a /libcutils/trace.c | |
parent | 0a34643160890eb50f7d8e016b4ec93d9db2aa27 (diff) | |
download | system_core-e7bb7bca4f4036c213763673627e1eb6c2c2fdd6.zip system_core-e7bb7bca4f4036c213763673627e1eb6c2c2fdd6.tar.gz system_core-e7bb7bca4f4036c213763673627e1eb6c2c2fdd6.tar.bz2 |
cutils: trace: add atrace_update_tags()
Adds a function to read the current trace system property value, and
sets the trace tags to it, do be used as a sysprop change callback.
Change-Id: Ia6336652173aa5b07188898736c2c795a69fe79a
Diffstat (limited to 'libcutils/trace.c')
-rw-r--r-- | libcutils/trace.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/libcutils/trace.c b/libcutils/trace.c index 15c8a98..152ea61 100644 --- a/libcutils/trace.c +++ b/libcutils/trace.c @@ -33,6 +33,7 @@ int32_t atrace_is_ready = 0; int atrace_marker_fd = -1; uint64_t atrace_enabled_tags = ATRACE_TAG_NOT_READY; static pthread_once_t atrace_once_control = PTHREAD_ONCE_INIT; +static pthread_mutex_t atrace_tags_mutex = PTHREAD_MUTEX_INITIALIZER; // Read the sysprop and return the value tags should be set to static uint64_t atrace_get_property() @@ -54,6 +55,18 @@ static uint64_t atrace_get_property() return (tags | ATRACE_TAG_ALWAYS) & ATRACE_TAG_VALID_MASK; } +// Update tags if tracing is ready. Useful as a sysprop change callback. +void atrace_update_tags() +{ + uint64_t tags; + if (CC_UNLIKELY(android_atomic_acquire_load(&atrace_is_ready))) { + tags = atrace_get_property(); + pthread_mutex_lock(&atrace_tags_mutex); + atrace_enabled_tags = tags; + pthread_mutex_unlock(&atrace_tags_mutex); + } +} + static void atrace_init_once() { atrace_marker_fd = open("/sys/kernel/debug/tracing/trace_marker", O_WRONLY); |