diff options
Diffstat (limited to 'include/cutils/trace.h')
-rw-r--r-- | include/cutils/trace.h | 61 |
1 files changed, 16 insertions, 45 deletions
diff --git a/include/cutils/trace.h b/include/cutils/trace.h index dbd5e25..59ff6c1 100644 --- a/include/cutils/trace.h +++ b/include/cutils/trace.h @@ -20,16 +20,13 @@ #include <inttypes.h> #include <stdbool.h> #include <stdint.h> +#include <stdio.h> #include <sys/cdefs.h> #include <sys/types.h> #include <unistd.h> -#include <cutils/compiler.h> -#ifdef ANDROID_SMP -#include <cutils/atomic-inline.h> -#else #include <cutils/atomic.h> -#endif +#include <cutils/compiler.h> __BEGIN_DECLS @@ -68,7 +65,9 @@ __BEGIN_DECLS #define ATRACE_TAG_RESOURCES (1<<13) #define ATRACE_TAG_DALVIK (1<<14) #define ATRACE_TAG_RS (1<<15) -#define ATRACE_TAG_LAST ATRACE_TAG_RS +#define ATRACE_TAG_BIONIC (1<<16) +#define ATRACE_TAG_POWER (1<<17) +#define ATRACE_TAG_LAST ATRACE_TAG_POWER // Reserved for initialization. #define ATRACE_TAG_NOT_READY (1LL<<63) @@ -83,13 +82,6 @@ __BEGIN_DECLS #ifdef HAVE_ANDROID_OS /** - * Maximum size of a message that can be logged to the trace buffer. - * Note this message includes a tag, the pid, and the string given as the name. - * Names should be kept short to get the most use of the trace buffer. - */ -#define ATRACE_MESSAGE_LENGTH 1024 - -/** * Opens the trace file for writing and reads the property for initial tags. * The atrace.tags.enableflags property sets the tags to trace. * This function should not be explicitly called, the first call to any normal @@ -181,11 +173,8 @@ static inline uint64_t atrace_is_tag_enabled(uint64_t tag) static inline void atrace_begin(uint64_t tag, const char* name) { if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) { - char buf[ATRACE_MESSAGE_LENGTH]; - size_t len; - - len = snprintf(buf, ATRACE_MESSAGE_LENGTH, "B|%d|%s", getpid(), name); - write(atrace_marker_fd, buf, len); + void atrace_begin_body(const char*); + atrace_begin_body(name); } } @@ -215,12 +204,8 @@ static inline void atrace_async_begin(uint64_t tag, const char* name, int32_t cookie) { if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) { - char buf[ATRACE_MESSAGE_LENGTH]; - size_t len; - - len = snprintf(buf, ATRACE_MESSAGE_LENGTH, "S|%d|%s|%" PRId32, - getpid(), name, cookie); - write(atrace_marker_fd, buf, len); + void atrace_async_begin_body(const char*, int32_t); + atrace_async_begin_body(name, cookie); } } @@ -229,20 +214,14 @@ static inline void atrace_async_begin(uint64_t tag, const char* name, * This should have a corresponding ATRACE_ASYNC_BEGIN. */ #define ATRACE_ASYNC_END(name, cookie) atrace_async_end(ATRACE_TAG, name, cookie) -static inline void atrace_async_end(uint64_t tag, const char* name, - int32_t cookie) +static inline void atrace_async_end(uint64_t tag, const char* name, int32_t cookie) { if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) { - char buf[ATRACE_MESSAGE_LENGTH]; - size_t len; - - len = snprintf(buf, ATRACE_MESSAGE_LENGTH, "F|%d|%s|%" PRId32, - getpid(), name, cookie); - write(atrace_marker_fd, buf, len); + void atrace_async_end_body(const char*, int32_t); + atrace_async_end_body(name, cookie); } } - /** * Traces an integer counter value. name is used to identify the counter. * This can be used to track how a value changes over time. @@ -251,12 +230,8 @@ static inline void atrace_async_end(uint64_t tag, const char* name, static inline void atrace_int(uint64_t tag, const char* name, int32_t value) { if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) { - char buf[ATRACE_MESSAGE_LENGTH]; - size_t len; - - len = snprintf(buf, ATRACE_MESSAGE_LENGTH, "C|%d|%s|%" PRId32, - getpid(), name, value); - write(atrace_marker_fd, buf, len); + void atrace_int_body(const char*, int32_t); + atrace_int_body(name, value); } } @@ -268,12 +243,8 @@ static inline void atrace_int(uint64_t tag, const char* name, int32_t value) static inline void atrace_int64(uint64_t tag, const char* name, int64_t value) { if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) { - char buf[ATRACE_MESSAGE_LENGTH]; - size_t len; - - len = snprintf(buf, ATRACE_MESSAGE_LENGTH, "C|%d|%s|%" PRId64, - getpid(), name, value); - write(atrace_marker_fd, buf, len); + void atrace_int64_body(const char*, int64_t); + atrace_int64_body(name, value); } } |