Ion
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
trace.cc
Go to the documentation of this file.
1 
18 #define LOG_TAG "Trace"
19 
20 #include "ion/port/android/trace.h"
21 
22 #include <android/log.h>
23 
25 
26 namespace ion {
27 namespace port {
28 namespace android {
29 
30 volatile int32_t Tracer::sIsReady = 0;
31 int Tracer::sTraceFD = -1;
32 uint64_t Tracer::sEnabledTags = ION_ATRACE_TAG_NOT_READY;
33 
34 void Tracer::changeCallback() {
35  if (sIsReady && sTraceFD >= 0) {
36  loadSystemProperty();
37  }
38 }
39 
40 void Tracer::init() {
41  if (sIsReady) return;
42 
43  const char* const traceFileName =
44  "/sys/kernel/debug/tracing/trace_marker";
45  sTraceFD = open(traceFileName, O_WRONLY);
46  if (sTraceFD == -1) {
47  __android_log_print(ANDROID_LOG_INFO,
48  "TRACE", "error opening trace file: %s (%d)",
49  strerror(errno), errno);
50 
51  sEnabledTags = 0; // no tracing can occur
52  } else {
53  loadSystemProperty();
54  }
55  sIsReady = 1;
56 }
57 
58 void Tracer::loadSystemProperty() {
59  sEnabledTags = (0x400a & ION_ATRACE_TAG_VALID_MASK) | ION_ATRACE_TAG_ALWAYS;
60 }
61 
62 } // namespace android
63 } // namespace port
64 } // namespace ion
#define ION_ATRACE_TAG_NOT_READY
Definition: trace.h:73
#define ION_ATRACE_TAG_VALID_MASK
init
Definition: trace.h:76
#define ION_ATRACE_TAG_ALWAYS
enabled.
Definition: trace.h:50