diff --git a/include/android_stub/cutils/trace.h b/include/android_stub/cutils/trace.h index 24c6ae62905..7f57637ec11 100644 --- a/include/android_stub/cutils/trace.h +++ b/include/android_stub/cutils/trace.h @@ -75,7 +75,8 @@ __BEGIN_DECLS #define ATRACE_TAG_AIDL (1<<24) #define ATRACE_TAG_NNAPI (1<<25) #define ATRACE_TAG_RRO (1<<26) -#define ATRACE_TAG_LAST ATRACE_TAG_RRO +#define ATRACE_TAG_THERMAL (1 << 27) +#define ATRACE_TAG_LAST ATRACE_TAG_THERMAL // Reserved for initialization. #define ATRACE_TAG_NOT_READY (1ULL<<63) @@ -88,6 +89,36 @@ __BEGIN_DECLS #error ATRACE_TAG must be defined to be one of the tags defined in cutils/trace.h #endif +/** Internal implementation detail. Do not use. */ +void atrace_begin_body(const char*); + +/** Internal implementation detail. Do not use. */ +void atrace_end_body(); + +/** Internal implementation detail. Do not use. */ +void atrace_async_begin_body(const char*, int32_t); + +/** Internal implementation detail. Do not use. */ +void atrace_async_end_body(const char*, int32_t); + +/** Internal implementation detail. Do not use. */ +void atrace_async_for_track_begin_body(const char*, const char*, int32_t); + +/** Internal implementation detail. Do not use. */ +void atrace_async_for_track_end_body(const char*, int32_t); + +/** Internal implementation detail. Do not use. */ +void atrace_instant_body(const char*); + +/** Internal implementation detail. Do not use. */ +void atrace_instant_for_track_body(const char*, const char*); + +/** Internal implementation detail. Do not use. */ +void atrace_int_body(const char*, int32_t); + +/** Internal implementation detail. Do not use. */ +void atrace_int64_body(const char*, int64_t); + /** * Opens the trace file for writing and reads the property for initial tags. * The atrace.tags.enableflags property sets the tags to trace. @@ -158,7 +189,6 @@ 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))) { - void atrace_begin_body(const char*); atrace_begin_body(name); } } @@ -171,7 +201,6 @@ static inline void atrace_begin(uint64_t tag, const char* name) static inline void atrace_end(uint64_t tag) { if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) { - void atrace_end_body(); atrace_end_body(); } } @@ -189,7 +218,6 @@ static inline void atrace_async_begin(uint64_t tag, const char* name, int32_t cookie) { if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) { - void atrace_async_begin_body(const char*, int32_t); atrace_async_begin_body(name, cookie); } } @@ -202,11 +230,72 @@ static inline void atrace_async_begin(uint64_t tag, const char* name, static inline void atrace_async_end(uint64_t tag, const char* name, int32_t cookie) { if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) { - void atrace_async_end_body(const char*, int32_t); atrace_async_end_body(name, cookie); } } +/** + * Trace the beginning of an asynchronous event. In addition to the name and a + * cookie as in ATRACE_ASYNC_BEGIN/ATRACE_ASYNC_END, a track name argument is + * provided, which is the name of the row where this async event should be + * recorded. The track name, name, and cookie used to begin an event must be + * used to end it. + * The cookie here must be unique on the track_name level, not the name level. + */ +#define ATRACE_ASYNC_FOR_TRACK_BEGIN(track_name, name, cookie) \ + atrace_async_for_track_begin(ATRACE_TAG, track_name, name, cookie) +static inline void atrace_async_for_track_begin(uint64_t tag, const char* track_name, + const char* name, int32_t cookie) { + if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) { + atrace_async_for_track_begin_body(track_name, name, cookie); + } +} + +/** + * Trace the end of an asynchronous event. + * This should correspond to a previous ATRACE_ASYNC_FOR_TRACK_BEGIN. + */ +#define ATRACE_ASYNC_FOR_TRACK_END(track_name, cookie) \ + atrace_async_for_track_end(ATRACE_TAG, track_name, cookie) +static inline void atrace_async_for_track_end(uint64_t tag, const char* track_name, + int32_t cookie) { + if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) { + atrace_async_for_track_end_body(track_name, cookie); + } +} + +/** + * Trace an instantaneous context. name is used to identify the context. + * + * An "instant" is an event with no defined duration. Visually is displayed like a single marker + * in the timeline (rather than a span, in the case of begin/end events). + * + * By default, instant events are added into a dedicated track that has the same name of the event. + * Use atrace_instant_for_track to put different instant events into the same timeline track/row. + */ +#define ATRACE_INSTANT(name) atrace_instant(ATRACE_TAG, name) +static inline void atrace_instant(uint64_t tag, const char* name) { + if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) { + atrace_instant_body(name); + } +} + +/** + * Trace an instantaneous context. name is used to identify the context. + * track_name is the name of the row where the event should be recorded. + * + * An "instant" is an event with no defined duration. Visually is displayed like a single marker + * in the timeline (rather than a span, in the case of begin/end events). + */ +#define ATRACE_INSTANT_FOR_TRACK(trackName, name) \ + atrace_instant_for_track(ATRACE_TAG, trackName, name) +static inline void atrace_instant_for_track(uint64_t tag, const char* track_name, + const char* name) { + if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) { + atrace_instant_for_track_body(track_name, name); + } +} + /** * Traces an integer counter value. name is used to identify the counter. * This can be used to track how a value changes over time. @@ -215,7 +304,6 @@ static inline void atrace_async_end(uint64_t tag, const char* name, int32_t cook static inline void atrace_int(uint64_t tag, const char* name, int32_t value) { if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) { - void atrace_int_body(const char*, int32_t); atrace_int_body(name, value); } } @@ -228,7 +316,6 @@ 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))) { - void atrace_int64_body(const char*, int64_t); atrace_int64_body(name, value); } } diff --git a/src/android_stub/nativewindow_stub.cpp b/src/android_stub/nativewindow_stub.cpp index 9276a9c3d2e..277b5d54f77 100644 --- a/src/android_stub/nativewindow_stub.cpp +++ b/src/android_stub/nativewindow_stub.cpp @@ -1,4 +1,5 @@ #include +#include extern "C" {