@@ -70,8 +70,7 @@ enum CategoryGroupEnabledFlags {
70
70
// const uint8_t*
71
71
// TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED(const char* category_group)
72
72
#define TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED \
73
- node::tracing::TraceEventHelper::GetTracingController () \
74
- ->GetCategoryGroupEnabled
73
+ node::tracing::TraceEventHelper::GetCategoryGroupEnabled
75
74
76
75
// Get the number of times traces have been recorded. This is used to implement
77
76
// the TRACE_EVENT_IS_NEW_TRACE facility.
@@ -115,9 +114,10 @@ enum CategoryGroupEnabledFlags {
115
114
// const uint8_t* category_group_enabled,
116
115
// const char* name,
117
116
// uint64_t id)
118
- #define TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION \
119
- node::tracing::TraceEventHelper::GetTracingController () \
120
- ->UpdateTraceEventDuration
117
+ #define TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION \
118
+ if (auto controller = \
119
+ node::tracing::TraceEventHelper::GetTracingController ()) \
120
+ controller->UpdateTraceEventDuration
121
121
122
122
// Adds a metadata event to the trace log. The |AppendValueAsTraceFormat| method
123
123
// on the convertable value will be called at flush time.
@@ -317,6 +317,13 @@ class NODE_EXTERN TraceEventHelper {
317
317
static TracingController* GetTracingController ();
318
318
static Agent* GetAgent ();
319
319
static void SetAgent (Agent* agent);
320
+
321
+ static inline const uint8_t * GetCategoryGroupEnabled (const char * group) {
322
+ v8::TracingController* controller = GetTracingController ();
323
+ static const uint8_t disabled = 0 ;
324
+ if (UNLIKELY (controller == nullptr )) return &disabled;
325
+ return controller->GetCategoryGroupEnabled (group);
326
+ }
320
327
};
321
328
322
329
// TraceID encapsulates an ID that can either be an integer or pointer. Pointers
@@ -465,6 +472,7 @@ static inline uint64_t AddTraceEventImpl(
465
472
// DCHECK(num_args, 2);
466
473
v8::TracingController* controller =
467
474
node::tracing::TraceEventHelper::GetTracingController ();
475
+ if (controller == nullptr ) return 0 ;
468
476
return controller->AddTraceEvent (phase, category_group_enabled, name, scope, id,
469
477
bind_id, num_args, arg_names, arg_types,
470
478
arg_values, arg_convertibles, flags);
@@ -487,6 +495,7 @@ static V8_INLINE uint64_t AddTraceEventWithTimestampImpl(
487
495
// DCHECK_LE(num_args, 2);
488
496
v8::TracingController* controller =
489
497
node::tracing::TraceEventHelper::GetTracingController ();
498
+ if (controller == nullptr ) return 0 ;
490
499
return controller->AddTraceEventWithTimestamp (
491
500
phase, category_group_enabled, name, scope, id, bind_id, num_args,
492
501
arg_names, arg_types, arg_values, arg_convertables, flags, timestamp);
0 commit comments