18 #ifndef ION_PORT_ANDROID_TRACE_H_
19 #define ION_PORT_ANDROID_TRACE_H_
27 #include <sys/types.h>
30 #include <android/log.h>
48 #define ION_ATRACE_TAG_NEVER 0 // The "never" tag is never
49 #define ION_ATRACE_TAG_ALWAYS (1<<0) // The "always" tag is always
51 #define ION_ATRACE_TAG_GRAPHICS (1<<1)
53 #define ION_ATRACE_TAG_INPUT (1<<2)
54 #define ION_ATRACE_TAG_VIEW (1<<3)
55 #define ION_ATRACE_TAG_WEBVIEW (1<<4)
56 #define ION_ATRACE_TAG_WINDOW_MANAGER (1<<5)
57 #define ION_ATRACE_TAG_ACTIVITY_MANAGER (1<<6)
58 #define ION_ATRACE_TAG_SYNC_MANAGER (1<<7)
59 #define ION_ATRACE_TAG_AUDIO (1<<8)
60 #define ION_ATRACE_TAG_VIDEO (1<<9)
61 #define ION_ATRACE_TAG_CAMERA (1<<10)
62 #define ION_ATRACE_TAG_HAL (1<<11)
63 #define ION_ATRACE_TAG_APP (1<<12)
64 #define ION_ATRACE_TAG_RESOURCES (1<<13)
65 #define ION_ATRACE_TAG_DALVIK (1<<14)
66 #define ION_ATRACE_TAG_RS (1<<15)
67 #define ION_ATRACE_TAG_BIONIC (1<<16)
68 #define ION_ATRACE_TAG_POWER (1<<17)
69 #define ION_ATRACE_TAG_PACKAGE_MANAGER (1<<18)
70 #define ION_ATRACE_TAG_SYSTEM_SERVER (1<<19)
71 #define ION_ATRACE_TAG_LAST ION_ATRACE_TAG_SYSTEM_SERVER
73 #define ION_ATRACE_TAG_NOT_READY (1LL << 63) // Reserved for use during
76 #define ION_ATRACE_TAG_VALID_MASK \
77 ((ION_ATRACE_TAG_LAST - 1) | ION_ATRACE_TAG_LAST)
79 #ifndef ION_ATRACE_TAG
80 #define ION_ATRACE_TAG ION_ATRACE_TAG_NEVER
81 #elif ION_ATRACE_TAG > ION_ATRACE_TAG_LAST
82 #error ION_ATRACE_TAG must be defined to be one of the tags defined in \
89 #define ION_ATRACE_CALL() \
90 ion::port::android::ScopedTrace ___tracer(ION_ATRACE_TAG, __FUNCTION__)
95 #define ION_ATRACE_NAME(name) \
96 ion::port::android::ScopedTrace ___tracer(ION_ATRACE_TAG, name)
100 #define ION_ATRACE_INT(name, value) \
101 ion::port::android::Tracer::traceCounter(ION_ATRACE_TAG, name, value)
105 #define ION_ATRACE_ENABLED() \
106 ion::port::android::Tracer::isTagEnabled(ION_ATRACE_TAG)
128 snprintf(buf, 1024,
"C|%d|%s|%d", getpid(), name, value);
129 write(sTraceFD, buf, strlen(buf));
136 size_t len = snprintf(buf, 1024,
"B|%d|%s", getpid(), name);
137 write(sTraceFD, buf, len);
144 write(sTraceFD, &buf, 1);
149 static inline void initIfNeeded() {
153 static void changeCallback();
161 static void loadSystemProperty();
171 static volatile int32_t sIsReady;
191 static uint64_t sEnabledTags;
213 #endif // ION_PORT_ANDROID_TRACE_H_
static void traceCounter(uint64_t tag, const char *name, int32_t value)
ScopedTrace(uint64_t tag, const char *name)
static bool isTagEnabled(uint64_t tag)
static void traceEnd(uint64_t tag)
static uint64_t getEnabledTags()
static void traceBegin(uint64_t tag, const char *name)