summaryrefslogtreecommitdiff
path: root/libartbase/base/systrace.h
diff options
context:
space:
mode:
Diffstat (limited to 'libartbase/base/systrace.h')
-rw-r--r--libartbase/base/systrace.h39
1 files changed, 29 insertions, 10 deletions
diff --git a/libartbase/base/systrace.h b/libartbase/base/systrace.h
index d995dce285..30bba49f11 100644
--- a/libartbase/base/systrace.h
+++ b/libartbase/base/systrace.h
@@ -17,33 +17,52 @@
#ifndef ART_LIBARTBASE_BASE_SYSTRACE_H_
#define ART_LIBARTBASE_BASE_SYSTRACE_H_
-#define ATRACE_TAG ATRACE_TAG_DALVIK
-#include <cutils/trace.h>
-
#include <sstream>
#include <string>
#include "android-base/stringprintf.h"
#include "macros.h"
+#include "palette/palette.h"
namespace art {
+inline bool ATraceEnabled() {
+ int enabled = 0;
+ if (UNLIKELY(PaletteTraceEnabled(&enabled) == PaletteStatus::kOkay && enabled != 0)) {
+ return true;
+ } else {
+ return false;
+ }
+}
+
+inline void ATraceBegin(const char* name) {
+ PaletteTraceBegin(name);
+}
+
+inline void ATraceEnd() {
+ PaletteTraceEnd();
+}
+
+inline void ATraceIntegerValue(const char* name, int32_t value) {
+ PaletteTraceIntegerValue(name, value);
+}
+
class ScopedTrace {
public:
explicit ScopedTrace(const char* name) {
- ATRACE_BEGIN(name);
+ ATraceBegin(name);
}
template <typename Fn>
explicit ScopedTrace(Fn fn) {
- if (ATRACE_ENABLED()) {
- ATRACE_BEGIN(fn().c_str());
+ if (UNLIKELY(ATraceEnabled())) {
+ ATraceBegin(fn().c_str());
}
}
explicit ScopedTrace(const std::string& name) : ScopedTrace(name.c_str()) {}
~ScopedTrace() {
- ATRACE_END();
+ ATraceEnd();
}
};
@@ -54,7 +73,7 @@ class ScopedTraceNoStart {
}
~ScopedTraceNoStart() {
- ATRACE_END();
+ ATraceEnd();
}
// Message helper for the macro. Do not use directly.
@@ -63,7 +82,7 @@ class ScopedTraceNoStart {
ScopedTraceMessageHelper() {
}
~ScopedTraceMessageHelper() {
- ATRACE_BEGIN(buffer_.str().c_str());
+ ATraceBegin(buffer_.str().c_str());
}
std::ostream& stream() {
@@ -77,7 +96,7 @@ class ScopedTraceNoStart {
#define SCOPED_TRACE \
::art::ScopedTraceNoStart APPEND_TOKENS_AFTER_EVAL(trace, __LINE__) ; \
- (ATRACE_ENABLED()) && ::art::ScopedTraceNoStart::ScopedTraceMessageHelper().stream()
+ (ATraceEnabled()) && ::art::ScopedTraceNoStart::ScopedTraceMessageHelper().stream()
} // namespace art