5#ifndef V8_LIBPLATFORM_V8_TRACING_H_
6#define V8_LIBPLATFORM_V8_TRACING_H_
11#include <unordered_set>
18namespace trace_processor {
19class TraceProcessorStorage;
33class TraceEventListener;
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, int64_t timestamp, int64_t cpu_timestamp);
58 char phase,
const uint8_t* category_enabled_flag,
const char* name,
59 const char* scope, uint64_t
id, uint64_t bind_id,
int num_args,
60 const char** arg_names,
const uint8_t* arg_types,
61 const uint64_t* arg_values,
62 std::unique_ptr<v8::ConvertableToTraceFormat>* arg_convertables,
63 unsigned int flags,
int pid,
int tid, int64_t ts, int64_t tts,
64 uint64_t duration, uint64_t cpu_duration);
66 int pid()
const {
return pid_; }
67 int tid()
const {
return tid_; }
68 char phase()
const {
return phase_; }
70 return category_enabled_flag_;
72 const char*
name()
const {
return name_; }
73 const char*
scope()
const {
return scope_; }
74 uint64_t
id()
const {
return id_; }
75 uint64_t
bind_id()
const {
return bind_id_; }
81 return arg_convertables_;
83 unsigned int flags()
const {
return flags_; }
84 int64_t
ts() {
return ts_; }
85 int64_t
tts() {
return tts_; }
95 const uint8_t* category_enabled_flag_;
102 std::unique_ptr<v8::ConvertableToTraceFormat>
104 char* parameter_copy_storage_ =
nullptr;
109 uint64_t cpu_duration_;
125 const std::string& tag);
140 bool IsFull()
const {
return next_free_ == kChunkSize; }
144 uint32_t
seq()
const {
return seq_; }
145 size_t size()
const {
return next_free_; }
147 static const size_t kChunkSize = 64;
150 size_t next_free_ = 0;
168 static const size_t kRingBufferChunks = 1024;
201 TraceConfig() : enable_systrace_(false), enable_argument_filter_(false) {}
204 return included_categories_;
219 bool enable_systrace_ : 1;
220 bool enable_argument_filter_ : 1;
229#define V8_PLATFORM_NON_EXPORTED_BASE(code) \
230 __pragma(warning(suppress : 4275)) code
232#define V8_PLATFORM_NON_EXPORTED_BASE(code) code
241#if defined(V8_USE_PERFETTO)
244 void InitializeForPerfetto(std::ostream* output_stream);
247 void SetTraceEventListenerForTesting(TraceEventListener* listener);
255 ENABLED_FOR_RECORDING = 1 << 0,
257 ENABLED_FOR_EVENT_CALLBACK = 1 << 2,
259 ENABLED_FOR_ETW_EXPORT = 1 << 3
268 char phase,
const uint8_t* category_enabled_flag,
const char* name,
269 const char* scope, uint64_t
id, uint64_t bind_id, int32_t num_args,
270 const char** arg_names,
const uint8_t* arg_types,
271 const uint64_t* arg_values,
272 std::unique_ptr<v8::ConvertableToTraceFormat>* arg_convertables,
273 unsigned int flags)
override;
275 char phase,
const uint8_t* category_enabled_flag,
const char* name,
276 const char* scope, uint64_t
id, uint64_t bind_id, int32_t num_args,
277 const char** arg_names,
const uint8_t* arg_types,
278 const uint64_t* arg_values,
279 std::unique_ptr<v8::ConvertableToTraceFormat>* arg_convertables,
280 unsigned int flags, int64_t timestamp)
override;
282 const char* name, uint64_t handle)
override;
296#if !defined(V8_USE_PERFETTO)
302#if !defined(V8_USE_PERFETTO)
303 void UpdateCategoryGroupEnabledFlag(
size_t category_index);
304 void UpdateCategoryGroupEnabledFlags();
307 std::unique_ptr<base::Mutex> mutex_;
308 std::unique_ptr<TraceConfig> trace_config_;
309 std::atomic_bool recording_{
false};
311#if defined(V8_USE_PERFETTO)
312 std::ostream* output_stream_ =
nullptr;
313 std::unique_ptr<perfetto::trace_processor::TraceProcessorStorage>
315 TraceEventListener* listener_for_testing_ =
nullptr;
316 std::unique_ptr<perfetto::TracingSession> tracing_session_;
318 std::unordered_set<v8::TracingController::TraceStateObserver*> observers_;
319 std::unique_ptr<TraceBuffer> trace_buffer_;
327#undef V8_PLATFORM_NON_EXPORTED_BASE
#define V8_PLATFORM_NON_EXPORTED_BASE(code)