summaryrefslogtreecommitdiffstats
path: root/libcutils
diff options
context:
space:
mode:
authorChih-Hung Hsieh <chh@google.com>2014-10-15 17:57:07 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-10-15 17:57:07 +0000
commit6ea35520fd03473e1aac176ecd47d81c673691a7 (patch)
tree0a5766a55e1220b1f7ad8bb39a414520e7e1f38c /libcutils
parent1d6e7336b5f11dde61a48bf0d0c88f5fd590370b (diff)
parent07f1300c4c4f7d3c0df540bf8df3443c3f4539cd (diff)
downloadsystem_core-6ea35520fd03473e1aac176ecd47d81c673691a7.zip
system_core-6ea35520fd03473e1aac176ecd47d81c673691a7.tar.gz
system_core-6ea35520fd03473e1aac176ecd47d81c673691a7.tar.bz2
am 07f1300c: am 7979f1ce: Merge "Do not inline rarely used trace function bodies."
* commit '07f1300c4c4f7d3c0df540bf8df3443c3f4539cd': Do not inline rarely used trace function bodies.
Diffstat (limited to 'libcutils')
-rw-r--r--libcutils/trace.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/libcutils/trace.c b/libcutils/trace.c
index f57aac2..4396625 100644
--- a/libcutils/trace.c
+++ b/libcutils/trace.c
@@ -30,6 +30,13 @@
#define LOG_TAG "cutils-trace"
#include <log/log.h>
+/**
+ * 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
+
volatile int32_t atrace_is_ready = 0;
int atrace_marker_fd = -1;
uint64_t atrace_enabled_tags = ATRACE_TAG_NOT_READY;
@@ -183,3 +190,53 @@ void atrace_setup()
{
pthread_once(&atrace_once_control, atrace_init_once);
}
+
+void atrace_begin_body(const char* name)
+{
+ 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_async_begin_body(const char* name, int32_t cookie)
+{
+ 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_end_body(const char* name, int32_t cookie)
+{
+ 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_int_body(const char* name, int32_t value)
+{
+ 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_int64_body(const char* name, int64_t value)
+{
+ 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);
+}