Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
SkATrace Class Reference

#include <SkATrace.h>

Inheritance diagram for SkATrace:
SkEventTracer

Public Member Functions

 SkATrace ()
 
SkEventTracer::Handle addTraceEvent (char phase, const uint8_t *categoryEnabledFlag, const char *name, uint64_t id, int numArgs, const char **argNames, const uint8_t *argTypes, const uint64_t *argValues, uint8_t flags) override
 
void updateTraceEventDuration (const uint8_t *categoryEnabledFlag, const char *name, SkEventTracer::Handle handle) override
 
const uint8_t * getCategoryGroupEnabled (const char *name) override
 
const char * getCategoryGroupName (const uint8_t *categoryEnabledFlag) override
 
void newTracingSection (const char *name) override
 
- Public Member Functions inherited from SkEventTracer
virtual ~SkEventTracer ()=default
 
virtual const uint8_t * getCategoryGroupEnabled (const char *name)=0
 
virtual const char * getCategoryGroupName (const uint8_t *categoryEnabledFlag)=0
 
virtual SkEventTracer::Handle addTraceEvent (char phase, const uint8_t *categoryEnabledFlag, const char *name, uint64_t id, int32_t numArgs, const char **argNames, const uint8_t *argTypes, const uint64_t *argValues, uint8_t flags)=0
 
virtual void updateTraceEventDuration (const uint8_t *categoryEnabledFlag, const char *name, SkEventTracer::Handle handle)=0
 
virtual void newTracingSection (const char *)
 

Additional Inherited Members

- Public Types inherited from SkEventTracer
enum  CategoryGroupEnabledFlags { kEnabledForRecording_CategoryGroupEnabledFlags = 1 << 0 , kEnabledForMonitoring_CategoryGroupEnabledFlags = 1 << 1 , kEnabledForEventCallback_CategoryGroupEnabledFlags = 1 << 2 }
 
typedef uint64_t Handle
 
- Static Public Member Functions inherited from SkEventTracer
static bool SetInstance (SkEventTracer *, bool leakTracer=false)
 
static SkEventTracerGetInstance ()
 
- Protected Member Functions inherited from SkEventTracer
 SkEventTracer ()=default
 
 SkEventTracer (const SkEventTracer &)=delete
 
SkEventTraceroperator= (const SkEventTracer &)=delete
 

Detailed Description

This class is used to support ATrace in android apps. It hooks into the SkEventTracer system. It currently supports the macros TRACE_EVENT*, TRACE_EVENT_INSTANT*, and TRACE_EVENT_BEGIN/END*. For versions of these calls that take additoinal args and value pairs we currently just drop them and report only the name. Since ATrace is a simple push and pop system (all traces are fully nested), if using BEGIN and END you should also make sure your calls are properly nested (i.e. if startA is before startB, then endB is before endA).

Definition at line 23 of file SkATrace.h.

Constructor & Destructor Documentation

◆ SkATrace()

SkATrace::SkATrace ( )

Definition at line 21 of file SkATrace.cpp.

21 : fBeginSection(nullptr), fEndSection(nullptr), fIsEnabled(nullptr) {
22#if defined(SK_BUILD_FOR_ANDROID_FRAMEWORK)
23 fIsEnabled = []{ return static_cast<bool>(CC_UNLIKELY(ATRACE_ENABLED())); };
24 fBeginSection = [](const char* name){ ATRACE_BEGIN(name); };
25 fEndSection = []{ ATRACE_END(); };
26#elif defined(SK_BUILD_FOR_ANDROID)
27 if (void* lib = dlopen("libandroid.so", RTLD_NOW | RTLD_LOCAL)) {
28 fBeginSection = (decltype(fBeginSection))dlsym(lib, "ATrace_beginSection");
29 fEndSection = (decltype(fEndSection))dlsym(lib, "ATrace_endSection");
30 fIsEnabled = (decltype(fIsEnabled))dlsym(lib, "ATrace_isEnabled");
31 }
32#endif
33
34 if (!fIsEnabled) {
35 fIsEnabled = []{ return false; };
36 }
37}
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32

Member Function Documentation

◆ addTraceEvent()

SkEventTracer::Handle SkATrace::addTraceEvent ( char  phase,
const uint8_t *  categoryEnabledFlag,
const char *  name,
uint64_t  id,
int  numArgs,
const char **  argNames,
const uint8_t *  argTypes,
const uint64_t *  argValues,
uint8_t  flags 
)
override

Definition at line 39 of file SkATrace.cpp.

47 {
48 if (fIsEnabled()) {
49 if (TRACE_EVENT_PHASE_COMPLETE == phase ||
51 fBeginSection(name);
52 }
53
54 if (TRACE_EVENT_PHASE_INSTANT == phase) {
55 fEndSection();
56 }
57 }
58 return 0;
59}
#define TRACE_EVENT_PHASE_INSTANT
#define TRACE_EVENT_PHASE_COMPLETE

◆ getCategoryGroupEnabled()

const uint8_t * SkATrace::getCategoryGroupEnabled ( const char *  name)
overridevirtual

Implements SkEventTracer.

Definition at line 70 of file SkATrace.cpp.

70 {
71 // Chrome tracing is setup to not repeatly call this function once it has been initialized. So
72 // we can't use this to do a check for ATrace isEnabled(). Thus we will always return yes here
73 // and then check to see if ATrace is enabled when beginning and ending a section.
75 return &yes;
76}
@ kEnabledForRecording_CategoryGroupEnabledFlags
Definition: SkEventTracer.h:55

◆ getCategoryGroupName()

const char * SkATrace::getCategoryGroupName ( const uint8_t *  categoryEnabledFlag)
inlineoverridevirtual

Implements SkEventTracer.

Definition at line 44 of file SkATrace.h.

44 {
45 static const char* category = "skiaATrace";
46 return category;
47 }

◆ newTracingSection()

void SkATrace::newTracingSection ( const char *  name)
inlineoverridevirtual

Reimplemented from SkEventTracer.

Definition at line 50 of file SkATrace.h.

50{}

◆ updateTraceEventDuration()

void SkATrace::updateTraceEventDuration ( const uint8_t *  categoryEnabledFlag,
const char *  name,
SkEventTracer::Handle  handle 
)
overridevirtual

Implements SkEventTracer.

Definition at line 61 of file SkATrace.cpp.

63 {
64 // This is only ever called from a scoped trace event so we will just end the ATrace section.
65 if (fIsEnabled()) {
66 fEndSection();
67 }
68}

The documentation for this class was generated from the following files: