summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDianne Hackborn2012-05-08 20:54:22 -0500
committerAlex Ray2013-07-30 15:56:59 -0500
commitc1309d74e8929f73e1b9cdb5dbf70aa8a2b09af3 (patch)
treeae89c82296d03a9192621f82d10584614157f086 /libs/utils/Trace.cpp
parent6c1cf1c8f29263a1374991195ffa98b883f181ed (diff)
downloadplatform-system-core-c1309d74e8929f73e1b9cdb5dbf70aa8a2b09af3.tar.gz
platform-system-core-c1309d74e8929f73e1b9cdb5dbf70aa8a2b09af3.tar.xz
platform-system-core-c1309d74e8929f73e1b9cdb5dbf70aa8a2b09af3.zip
Add callback hack to find out when to reload system properties.
Every IBinder object can accept a new transaction to tell it that it might want to reload system properties, and in the process anyone can register a callback to be executed when this happens. Use this to reload the trace property. This is very much ONLY for debugging. Change-Id: I55c67c46f8f3fa9073bef0dfaab4577ed1d47eb4
Diffstat (limited to 'libs/utils/Trace.cpp')
-rw-r--r--libs/utils/Trace.cpp22
1 files changed, 18 insertions, 4 deletions
diff --git a/libs/utils/Trace.cpp b/libs/utils/Trace.cpp
index f3ec4851a..5cd5731d5 100644
--- a/libs/utils/Trace.cpp
+++ b/libs/utils/Trace.cpp
@@ -19,6 +19,7 @@
19#include <cutils/properties.h> 19#include <cutils/properties.h>
20#include <utils/Log.h> 20#include <utils/Log.h>
21#include <utils/Trace.h> 21#include <utils/Trace.h>
22#include <utils/misc.h>
22 23
23namespace android { 24namespace android {
24 25
@@ -27,10 +28,19 @@ int Tracer::sTraceFD = -1;
27uint64_t Tracer::sEnabledTags = 0; 28uint64_t Tracer::sEnabledTags = 0;
28Mutex Tracer::sMutex; 29Mutex Tracer::sMutex;
29 30
31void Tracer::changeCallback() {
32 Mutex::Autolock lock(sMutex);
33 if (sIsReady && sTraceFD >= 0) {
34 loadSystemProperty();
35 }
36}
37
30void Tracer::init() { 38void Tracer::init() {
31 Mutex::Autolock lock(sMutex); 39 Mutex::Autolock lock(sMutex);
32 40
33 if (!sIsReady) { 41 if (!sIsReady) {
42 add_sysprop_change_callback(changeCallback, 0);
43
34 const char* const traceFileName = 44 const char* const traceFileName =
35 "/sys/kernel/debug/tracing/trace_marker"; 45 "/sys/kernel/debug/tracing/trace_marker";
36 sTraceFD = open(traceFileName, O_WRONLY); 46 sTraceFD = open(traceFileName, O_WRONLY);
@@ -38,14 +48,18 @@ void Tracer::init() {
38 ALOGE("error opening trace file: %s (%d)", strerror(errno), errno); 48 ALOGE("error opening trace file: %s (%d)", strerror(errno), errno);
39 // sEnabledTags remains zero indicating that no tracing can occur 49 // sEnabledTags remains zero indicating that no tracing can occur
40 } else { 50 } else {
41 char value[PROPERTY_VALUE_MAX]; 51 loadSystemProperty();
42 property_get("debug.atrace.tags.enableflags", value, "0");
43 sEnabledTags = (strtoll(value, NULL, 0) & ATRACE_TAG_VALID_MASK)
44 | ATRACE_TAG_ALWAYS;
45 } 52 }
46 53
47 android_atomic_release_store(1, &sIsReady); 54 android_atomic_release_store(1, &sIsReady);
48 } 55 }
49} 56}
50 57
58void Tracer::loadSystemProperty() {
59 char value[PROPERTY_VALUE_MAX];
60 property_get("debug.atrace.tags.enableflags", value, "0");
61 sEnabledTags = (strtoll(value, NULL, 0) & ATRACE_TAG_VALID_MASK)
62 | ATRACE_TAG_ALWAYS;
63}
64
51} // namespace andoid 65} // namespace andoid