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

#include <ChromeTracingTracer.h>

Inheritance diagram for ChromeTracingTracer:
SkEventTracer

Public Member Functions

 ChromeTracingTracer (const char *filename)
 
 ~ChromeTracingTracer () override
 
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

A SkEventTracer implementation that logs events to JSON for viewing with chrome://tracing.

Definition at line 22 of file ChromeTracingTracer.h.

Constructor & Destructor Documentation

◆ ChromeTracingTracer()

ChromeTracingTracer::ChromeTracingTracer ( const char *  filename)

Definition at line 55 of file ChromeTracingTracer.cpp.

55 : fFilename(filename) {
56 this->createBlock();
57}

◆ ~ChromeTracingTracer()

ChromeTracingTracer::~ChromeTracingTracer ( )
override

Definition at line 59 of file ChromeTracingTracer.cpp.

59{ this->flush(); }

Member Function Documentation

◆ addTraceEvent()

SkEventTracer::Handle ChromeTracingTracer::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 82 of file ChromeTracingTracer.cpp.

90 {
91 // TODO: Respect flags (or assert). INSTANT events encode scope in flags, should be stored
92 // using "s" key in JSON. COPY flag should be supported or rejected.
93
94 // Figure out how much extra storage we need for copied strings
95 int size = static_cast<int>(sizeof(TraceEvent) + numArgs * sizeof(TraceEventArg));
96 for (int i = 0; i < numArgs; ++i) {
97 if (TRACE_VALUE_TYPE_COPY_STRING == argTypes[i]) {
98 size += strlen(skia_private::TraceValueAsString(argValues[i])) + 1;
99 }
100 }
101
102 size = SkAlign8(size);
103
105 uint8_t* storagePtr = storage.push_back_n(size);
106
107 TraceEvent* traceEvent = reinterpret_cast<TraceEvent*>(storagePtr);
108 traceEvent->fPhase = phase;
109 traceEvent->fNumArgs = numArgs;
110 traceEvent->fSize = size;
111 traceEvent->fName = name;
112 traceEvent->fID = id;
113 traceEvent->fClockBegin = std::chrono::steady_clock::now().time_since_epoch().count();
114 traceEvent->fClockEnd = 0;
115 traceEvent->fThreadID = SkGetThreadID();
116
117 TraceEventArg* traceEventArgs = traceEvent->args();
118 char* stringTableBase = traceEvent->stringTable();
119 char* stringTable = stringTableBase;
120 for (int i = 0; i < numArgs; ++i) {
121 traceEventArgs[i].fArgName = argNames[i];
122 traceEventArgs[i].fArgType = argTypes[i];
123 if (TRACE_VALUE_TYPE_COPY_STRING == argTypes[i]) {
124 // Just write an offset into the arguments array
125 traceEventArgs[i].fArgValue = stringTable - stringTableBase;
126
127 // Copy string into our buffer (and advance)
128 const char* valueStr = skia_private::TraceValueAsString(argValues[i]);
129 while (*valueStr) {
130 *stringTable++ = *valueStr++;
131 }
132 *stringTable++ = 0;
133 } else {
134 traceEventArgs[i].fArgValue = argValues[i];
135 }
136 }
137
138 return this->appendEvent(storagePtr, size);
139}
static constexpr T SkAlign8(T x)
Definition: SkAlign.h:17
SkThreadID SkGetThreadID()
Definition: SkThreadID.cpp:15
#define TRACE_VALUE_TYPE_COPY_STRING
T * push_back_n(int n)
Definition: SkTArray.h:267
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259
void TraceEvent(TraceArg category, TraceArg name, size_t flow_id_count, const uint64_t *flow_ids, Args... args)
Definition: trace_event.h:325
static const char * TraceValueAsString(uint64_t value)
Definition: SkTraceEvent.h:296
const uintptr_t id

◆ getCategoryGroupEnabled()

const uint8_t * ChromeTracingTracer::getCategoryGroupEnabled ( const char *  name)
inlineoverridevirtual

Implements SkEventTracer.

Definition at line 41 of file ChromeTracingTracer.h.

41 {
42 return fCategories.getCategoryGroupEnabled(name);
43 }
uint8_t * getCategoryGroupEnabled(const char *name)

◆ getCategoryGroupName()

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

Implements SkEventTracer.

Definition at line 45 of file ChromeTracingTracer.h.

45 {
46 return fCategories.getCategoryGroupName(categoryEnabledFlag);
47 }
const char * getCategoryGroupName(const uint8_t *categoryEnabledFlag)

◆ newTracingSection()

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

Reimplemented from SkEventTracer.

Definition at line 50 of file ChromeTracingTracer.h.

50{}

◆ updateTraceEventDuration()

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

Implements SkEventTracer.

Definition at line 141 of file ChromeTracingTracer.cpp.

143 {
144 // We could probably get away with not locking here, but let's be totally safe.
145 SkAutoSpinlock lock(fMutex);
146 TraceEvent* traceEvent = reinterpret_cast<TraceEvent*>(handle);
147 traceEvent->fClockEnd = std::chrono::steady_clock::now().time_since_epoch().count();
148}

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