5 #ifndef V8_LIBPLATFORM_V8_TRACING_H_ 6 #define V8_LIBPLATFORM_V8_TRACING_H_ 11 #include <unordered_set> 42 char phase,
const uint8_t* category_enabled_flag,
const char* name,
43 const char* scope, uint64_t
id, uint64_t bind_id,
int num_args,
44 const char** arg_names,
const uint8_t* arg_types,
45 const uint64_t* arg_values,
46 std::unique_ptr<v8::ConvertableToTraceFormat>* arg_convertables,
47 unsigned int flags, int64_t timestamp, int64_t cpu_timestamp);
48 void UpdateDuration(int64_t timestamp, int64_t cpu_timestamp);
49 void InitializeForTesting(
50 char phase,
const uint8_t* category_enabled_flag,
const char* name,
51 const char* scope, uint64_t
id, uint64_t bind_id,
int num_args,
52 const char** arg_names,
const uint8_t* arg_types,
53 const uint64_t* arg_values,
54 std::unique_ptr<v8::ConvertableToTraceFormat>* arg_convertables,
55 unsigned int flags,
int pid,
int tid, int64_t ts, int64_t tts,
56 uint64_t duration, uint64_t cpu_duration);
58 int pid()
const {
return pid_; }
59 int tid()
const {
return tid_; }
60 char phase()
const {
return phase_; }
62 return category_enabled_flag_;
64 const char*
name()
const {
return name_; }
65 const char*
scope()
const {
return scope_; }
66 uint64_t
id()
const {
return id_; }
67 uint64_t
bind_id()
const {
return bind_id_; }
73 return arg_convertables_;
75 unsigned int flags()
const {
return flags_; }
76 int64_t
ts() {
return ts_; }
77 int64_t
tts() {
return tts_; }
87 const uint8_t* category_enabled_flag_;
94 std::unique_ptr<v8::ConvertableToTraceFormat>
96 char* parameter_copy_storage_ =
nullptr;
101 uint64_t cpu_duration_;
112 virtual void AppendTraceEvent(
TraceObject* trace_event) = 0;
113 virtual void Flush() = 0;
115 static TraceWriter* CreateJSONTraceWriter(std::ostream& stream);
116 static TraceWriter* CreateJSONTraceWriter(std::ostream& stream,
117 const std::string& tag);
129 void Reset(uint32_t new_seq);
130 bool IsFull()
const {
return next_free_ == kChunkSize; }
134 uint32_t
seq()
const {
return seq_; }
135 size_t size()
const {
return next_free_; }
137 static const size_t kChunkSize = 64;
140 size_t next_free_ = 0;
154 virtual TraceObject* AddTraceEvent(uint64_t* handle) = 0;
155 virtual TraceObject* GetEventByHandle(uint64_t handle) = 0;
156 virtual bool Flush() = 0;
158 static const size_t kRingBufferChunks = 1024;
160 static TraceBuffer* CreateTraceBufferRingBuffer(
size_t max_chunks,
191 TraceConfig() : enable_systrace_(false), enable_argument_filter_(false) {}
200 void AddIncludedCategory(
const char* included_category);
202 bool IsCategoryGroupEnabled(
const char* category_group)
const;
206 bool enable_systrace_ : 1;
207 bool enable_argument_filter_ : 1;
208 StringList included_categories_;
215 #if defined(_MSC_VER) 216 #define V8_PLATFORM_NON_EXPORTED_BASE(code) \ 217 __pragma(warning(suppress : 4275)) code 219 #define V8_PLATFORM_NON_EXPORTED_BASE(code) code 220 #endif // defined(_MSC_VER) 231 ENABLED_FOR_RECORDING = 1 << 0,
233 ENABLED_FOR_EVENT_CALLBACK = 1 << 2,
235 ENABLED_FOR_ETW_EXPORT = 1 << 3
243 const uint8_t* GetCategoryGroupEnabled(
const char* category_group)
override;
244 uint64_t AddTraceEvent(
245 char phase,
const uint8_t* category_enabled_flag,
const char* name,
246 const char* scope, uint64_t
id, uint64_t bind_id, int32_t num_args,
247 const char** arg_names,
const uint8_t* arg_types,
248 const uint64_t* arg_values,
249 std::unique_ptr<v8::ConvertableToTraceFormat>* arg_convertables,
250 unsigned int flags)
override;
251 uint64_t AddTraceEventWithTimestamp(
252 char phase,
const uint8_t* category_enabled_flag,
const char* name,
253 const char* scope, uint64_t
id, uint64_t bind_id, int32_t num_args,
254 const char** arg_names,
const uint8_t* arg_types,
255 const uint64_t* arg_values,
256 std::unique_ptr<v8::ConvertableToTraceFormat>* arg_convertables,
257 unsigned int flags, int64_t timestamp)
override;
258 void UpdateTraceEventDuration(
const uint8_t* category_enabled_flag,
259 const char* name, uint64_t handle)
override;
260 void AddTraceStateObserver(
262 void RemoveTraceStateObserver(
268 static const char* GetCategoryGroupName(
const uint8_t* category_enabled_flag);
271 virtual int64_t CurrentTimestampMicroseconds();
272 virtual int64_t CurrentCpuTimestampMicroseconds();
275 void UpdateCategoryGroupEnabledFlag(
size_t category_index);
276 void UpdateCategoryGroupEnabledFlags();
278 std::unique_ptr<TraceBuffer> trace_buffer_;
279 std::unique_ptr<TraceConfig> trace_config_;
280 std::unique_ptr<base::Mutex> mutex_;
281 std::unordered_set<v8::TracingController::TraceStateObserver*> observers_;
282 std::atomic_bool recording_{
false};
289 #undef V8_PLATFORM_NON_EXPORTED_BASE 295 #endif // V8_LIBPLATFORM_V8_TRACING_H_
#define V8_PLATFORM_NON_EXPORTED_BASE(code)