Merge "Do not inline rarely used trace function bodies."
This commit is contained in:
commit
7979f1ce5f
2 changed files with 68 additions and 39 deletions
|
|
@ -84,13 +84,6 @@ __BEGIN_DECLS
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_ANDROID_OS
|
#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.
|
* Opens the trace file for writing and reads the property for initial tags.
|
||||||
* The atrace.tags.enableflags property sets the tags to trace.
|
* The atrace.tags.enableflags property sets the tags to trace.
|
||||||
|
|
@ -183,11 +176,8 @@ static inline uint64_t atrace_is_tag_enabled(uint64_t tag)
|
||||||
static inline void atrace_begin(uint64_t tag, const char* name)
|
static inline void atrace_begin(uint64_t tag, const char* name)
|
||||||
{
|
{
|
||||||
if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) {
|
if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) {
|
||||||
char buf[ATRACE_MESSAGE_LENGTH];
|
void atrace_begin_body(const char*);
|
||||||
size_t len;
|
atrace_begin_body(name);
|
||||||
|
|
||||||
len = snprintf(buf, ATRACE_MESSAGE_LENGTH, "B|%d|%s", getpid(), name);
|
|
||||||
write(atrace_marker_fd, buf, len);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -217,12 +207,8 @@ static inline void atrace_async_begin(uint64_t tag, const char* name,
|
||||||
int32_t cookie)
|
int32_t cookie)
|
||||||
{
|
{
|
||||||
if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) {
|
if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) {
|
||||||
char buf[ATRACE_MESSAGE_LENGTH];
|
void atrace_async_begin_body(const char*, int32_t);
|
||||||
size_t len;
|
atrace_async_begin_body(name, cookie);
|
||||||
|
|
||||||
len = snprintf(buf, ATRACE_MESSAGE_LENGTH, "S|%d|%s|%" PRId32,
|
|
||||||
getpid(), name, cookie);
|
|
||||||
write(atrace_marker_fd, buf, len);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -231,20 +217,14 @@ static inline void atrace_async_begin(uint64_t tag, const char* name,
|
||||||
* This should have a corresponding ATRACE_ASYNC_BEGIN.
|
* This should have a corresponding ATRACE_ASYNC_BEGIN.
|
||||||
*/
|
*/
|
||||||
#define ATRACE_ASYNC_END(name, cookie) atrace_async_end(ATRACE_TAG, name, cookie)
|
#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,
|
static inline void atrace_async_end(uint64_t tag, const char* name, int32_t cookie)
|
||||||
int32_t cookie)
|
|
||||||
{
|
{
|
||||||
if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) {
|
if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) {
|
||||||
char buf[ATRACE_MESSAGE_LENGTH];
|
void atrace_async_end_body(const char*, int32_t);
|
||||||
size_t len;
|
atrace_async_end_body(name, cookie);
|
||||||
|
|
||||||
len = snprintf(buf, ATRACE_MESSAGE_LENGTH, "F|%d|%s|%" PRId32,
|
|
||||||
getpid(), name, cookie);
|
|
||||||
write(atrace_marker_fd, buf, len);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Traces an integer counter value. name is used to identify the counter.
|
* Traces an integer counter value. name is used to identify the counter.
|
||||||
* This can be used to track how a value changes over time.
|
* This can be used to track how a value changes over time.
|
||||||
|
|
@ -253,12 +233,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)
|
static inline void atrace_int(uint64_t tag, const char* name, int32_t value)
|
||||||
{
|
{
|
||||||
if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) {
|
if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) {
|
||||||
char buf[ATRACE_MESSAGE_LENGTH];
|
void atrace_int_body(const char*, int32_t);
|
||||||
size_t len;
|
atrace_int_body(name, value);
|
||||||
|
|
||||||
len = snprintf(buf, ATRACE_MESSAGE_LENGTH, "C|%d|%s|%" PRId32,
|
|
||||||
getpid(), name, value);
|
|
||||||
write(atrace_marker_fd, buf, len);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -270,12 +246,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)
|
static inline void atrace_int64(uint64_t tag, const char* name, int64_t value)
|
||||||
{
|
{
|
||||||
if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) {
|
if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) {
|
||||||
char buf[ATRACE_MESSAGE_LENGTH];
|
void atrace_int64_body(const char*, int64_t);
|
||||||
size_t len;
|
atrace_int64_body(name, value);
|
||||||
|
|
||||||
len = snprintf(buf, ATRACE_MESSAGE_LENGTH, "C|%d|%s|%" PRId64,
|
|
||||||
getpid(), name, value);
|
|
||||||
write(atrace_marker_fd, buf, len);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,13 @@
|
||||||
#define LOG_TAG "cutils-trace"
|
#define LOG_TAG "cutils-trace"
|
||||||
#include <log/log.h>
|
#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;
|
volatile int32_t atrace_is_ready = 0;
|
||||||
int atrace_marker_fd = -1;
|
int atrace_marker_fd = -1;
|
||||||
uint64_t atrace_enabled_tags = ATRACE_TAG_NOT_READY;
|
uint64_t atrace_enabled_tags = ATRACE_TAG_NOT_READY;
|
||||||
|
|
@ -183,3 +190,53 @@ void atrace_setup()
|
||||||
{
|
{
|
||||||
pthread_once(&atrace_once_control, atrace_init_once);
|
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);
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue