@@ -228,6 +228,16 @@ static struct {
228228 }
229229#endif // HAVE_INSPECTOR
230230
231+ void StartTracingAgent () {
232+ tracing_agent = new tracing::Agent ();
233+ tracing_agent->Start (platform_, trace_enabled_categories);
234+ }
235+
236+ void StopTracingAgent () {
237+ tracing_agent->Stop ();
238+ }
239+
240+ v8::Platform* platform_;
231241#else // !NODE_USE_V8_PLATFORM
232242 void Initialize (int thread_pool_size) {}
233243 void PumpMessageLoop (Isolate* isolate) {}
@@ -237,9 +247,13 @@ static struct {
237247 env->ThrowError (" Node compiled with NODE_USE_V8_PLATFORM=0" );
238248 return false ; // make compiler happy
239249 }
240- #endif // !NODE_USE_V8_PLATFORM
241250
242- v8::Platform* platform_;
251+ void StartTracingAgent () {
252+ fprintf (stderr, " Node compiled with NODE_USE_V8_PLATFORM=0, "
253+ " so event tracing is not available.\n " );
254+ }
255+ void StopTracingAgent () {}
256+ #endif // !NODE_USE_V8_PLATFORM
243257} v8_platform;
244258
245259#ifdef __POSIX__
@@ -4534,15 +4548,14 @@ int Start(int argc, char** argv) {
45344548 if (trace_enabled) {
45354549 fprintf (stderr, " Warning: Trace event is an experimental feature "
45364550 " and could change at any time.\n " );
4537- tracing_agent = new tracing::Agent ();
4538- tracing_agent->Start (v8_platform.platform_ , trace_enabled_categories);
4551+ v8_platform.StartTracingAgent ();
45394552 }
45404553 V8::Initialize ();
45414554 v8_initialized = true ;
45424555 const int exit_code =
45434556 Start (uv_default_loop (), argc, argv, exec_argc, exec_argv);
45444557 if (trace_enabled) {
4545- tracing_agent-> Stop ();
4558+ v8_platform. StopTracingAgent ();
45464559 }
45474560 v8_initialized = false ;
45484561 V8::Dispose ();
0 commit comments