summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorAlex Ray <aray@google.com>2013-03-19 00:29:05 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2013-03-19 00:29:05 +0000
commitee2dccf21b61094a0fd782d32f221804b0a7d3fa (patch)
tree236c250a2c0c76cce5b8a8881fc76a11c97db123 /include
parentc99742b54e483ce0806ef1f1d3580b50d8e2d166 (diff)
parent66317770d37c012b12609defdc750304c97bd8d3 (diff)
downloadsystem_core-ee2dccf21b61094a0fd782d32f221804b0a7d3fa.zip
system_core-ee2dccf21b61094a0fd782d32f221804b0a7d3fa.tar.gz
system_core-ee2dccf21b61094a0fd782d32f221804b0a7d3fa.tar.bz2
am 66317770: cutils: trace: add asynchronous events
* commit '66317770d37c012b12609defdc750304c97bd8d3': cutils: trace: add asynchronous events
Diffstat (limited to 'include')
-rw-r--r--include/cutils/trace.h41
1 files changed, 41 insertions, 0 deletions
diff --git a/include/cutils/trace.h b/include/cutils/trace.h
index 1db3903..ad65dfb 100644
--- a/include/cutils/trace.h
+++ b/include/cutils/trace.h
@@ -182,6 +182,47 @@ static inline void atrace_end(uint64_t tag)
}
/**
+ * Trace the beginning of an asynchronous event. Unlike ATRACE_BEGIN/ATRACE_END
+ * contexts, asynchronous events do not need to be nested. The name describes
+ * the event, and the cookie provides a unique identifier for distinguishing
+ * simultaneous events. The name and cookie used to begin an event must be
+ * used to end it.
+ */
+#define ATRACE_ASYNC_BEGIN(name, cookie) \
+ atrace_async_begin(ATRACE_TAG, name, cookie)
+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|%d", getpid(),
+ name, cookie);
+ write(atrace_marker_fd, buf, len);
+ }
+}
+
+/**
+ * Trace the end of an asynchronous event.
+ * 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)
+{
+ 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|%d", getpid(),
+ name, cookie);
+ write(atrace_marker_fd, buf, len);
+ }
+}
+
+
+/**
* Traces an integer counter value. name is used to identify the counter.
* This can be used to track how a value changes over time.
*/