@@ -52,6 +52,66 @@ class ConvertableToTraceFormat {
52
52
virtual void AppendAsTraceFormat (std::string* out) const = 0;
53
53
};
54
54
55
+ /* *
56
+ * V8 Tracing controller.
57
+ *
58
+ * Can be implemented by an embedder to record trace events from V8.
59
+ */
60
+ class TracingController {
61
+ public:
62
+ virtual ~TracingController () = default ;
63
+
64
+ /* *
65
+ * Called by TRACE_EVENT* macros, don't call this directly.
66
+ * The name parameter is a category group for example:
67
+ * TRACE_EVENT0("v8,parse", "V8.Parse")
68
+ * The pointer returned points to a value with zero or more of the bits
69
+ * defined in CategoryGroupEnabledFlags.
70
+ **/
71
+ virtual const uint8_t * GetCategoryGroupEnabled (const char * name) {
72
+ static uint8_t no = 0 ;
73
+ return &no;
74
+ }
75
+
76
+ /* *
77
+ * Adds a trace event to the platform tracing system. This function call is
78
+ * usually the result of a TRACE_* macro from trace_event_common.h when
79
+ * tracing and the category of the particular trace are enabled. It is not
80
+ * advisable to call this function on its own; it is really only meant to be
81
+ * used by the trace macros. The returned handle can be used by
82
+ * UpdateTraceEventDuration to update the duration of COMPLETE events.
83
+ */
84
+ virtual uint64_t AddTraceEvent (
85
+ char phase, const uint8_t * category_enabled_flag, const char * name,
86
+ const char * scope, uint64_t id, uint64_t bind_id, int32_t num_args,
87
+ const char ** arg_names, const uint8_t * arg_types,
88
+ const uint64_t * arg_values,
89
+ std::unique_ptr<ConvertableToTraceFormat>* arg_convertables,
90
+ unsigned int flags) {
91
+ return 0 ;
92
+ }
93
+
94
+ /* *
95
+ * Sets the duration field of a COMPLETE trace event. It must be called with
96
+ * the handle returned from AddTraceEvent().
97
+ **/
98
+ virtual void UpdateTraceEventDuration (const uint8_t * category_enabled_flag,
99
+ const char * name, uint64_t handle) {}
100
+
101
+ class TraceStateObserver {
102
+ public:
103
+ virtual ~TraceStateObserver () = default ;
104
+ virtual void OnTraceEnabled () = 0;
105
+ virtual void OnTraceDisabled () = 0;
106
+ };
107
+
108
+ /* * Adds tracing state change observer. */
109
+ virtual void AddTraceStateObserver (TraceStateObserver*) {}
110
+
111
+ /* * Removes tracing state change observer. */
112
+ virtual void RemoveTraceStateObserver (TraceStateObserver*) {}
113
+ };
114
+
55
115
/* *
56
116
* V8 Platform abstraction layer.
57
117
*
@@ -135,6 +195,20 @@ class Platform {
135
195
* the epoch.
136
196
**/
137
197
virtual double MonotonicallyIncreasingTime () = 0;
198
+ typedef void (*StackTracePrinter)();
199
+
200
+ /* *
201
+ * Returns a function pointer that print a stack trace of the current stack
202
+ * on invocation. Disables printing of the stack trace if nullptr.
203
+ */
204
+ virtual StackTracePrinter GetStackTracePrinter () { return nullptr ; }
205
+
206
+ /* *
207
+ * Returns an instance of a v8::TracingController. This must be non-nullptr.
208
+ */
209
+ virtual TracingController* GetTracingController () { return nullptr ; }
210
+
211
+ // DEPRECATED methods, use TracingController interface instead.
138
212
139
213
/* *
140
214
* Called by TRACE_EVENT* macros, don't call this directly.
@@ -200,26 +274,13 @@ class Platform {
200
274
virtual void UpdateTraceEventDuration (const uint8_t * category_enabled_flag,
201
275
const char * name, uint64_t handle) {}
202
276
203
- class TraceStateObserver {
204
- public:
205
- virtual ~TraceStateObserver () = default ;
206
- virtual void OnTraceEnabled () = 0;
207
- virtual void OnTraceDisabled () = 0;
208
- };
277
+ typedef v8::TracingController::TraceStateObserver TraceStateObserver;
209
278
210
279
/* * Adds tracing state change observer. */
211
280
virtual void AddTraceStateObserver (TraceStateObserver*) {}
212
281
213
282
/* * Removes tracing state change observer. */
214
283
virtual void RemoveTraceStateObserver (TraceStateObserver*) {}
215
-
216
- typedef void (*StackTracePrinter)();
217
-
218
- /* *
219
- * Returns a function pointer that print a stack trace of the current stack
220
- * on invocation. Disables printing of the stack trace if nullptr.
221
- */
222
- virtual StackTracePrinter GetStackTracePrinter () { return nullptr ; }
223
284
};
224
285
225
286
} // namespace v8
0 commit comments