Commit 2363cdfe authored by Ali Ijaz Sheikh's avatar Ali Ijaz Sheikh Committed by Commit Bot

[tracing] do not add traces when disabled

https://github.com/nodejs/node/issues/21038

Change-Id: Ic4c9f403b5e54a97d3170b2311dd5aab8c8357c8
Reviewed-on: https://chromium-review.googlesource.com/1217726
Commit-Queue: Ali Ijaz Sheikh <ofrobots@google.com>
Reviewed-by: 's avatarYang Guo <yangguo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#55809}
parent d28286f2
...@@ -78,13 +78,15 @@ uint64_t TracingController::AddTraceEvent( ...@@ -78,13 +78,15 @@ uint64_t TracingController::AddTraceEvent(
const uint64_t* arg_values, const uint64_t* arg_values,
std::unique_ptr<v8::ConvertableToTraceFormat>* arg_convertables, std::unique_ptr<v8::ConvertableToTraceFormat>* arg_convertables,
unsigned int flags) { unsigned int flags) {
uint64_t handle; uint64_t handle = 0;
TraceObject* trace_object = trace_buffer_->AddTraceEvent(&handle); if (mode_ != DISABLED) {
if (trace_object) { TraceObject* trace_object = trace_buffer_->AddTraceEvent(&handle);
trace_object->Initialize( if (trace_object) {
phase, category_enabled_flag, name, scope, id, bind_id, num_args, trace_object->Initialize(
arg_names, arg_types, arg_values, arg_convertables, flags, phase, category_enabled_flag, name, scope, id, bind_id, num_args,
CurrentTimestampMicroseconds(), CurrentCpuTimestampMicroseconds()); arg_names, arg_types, arg_values, arg_convertables, flags,
CurrentTimestampMicroseconds(), CurrentCpuTimestampMicroseconds());
}
} }
return handle; return handle;
} }
...@@ -96,13 +98,15 @@ uint64_t TracingController::AddTraceEventWithTimestamp( ...@@ -96,13 +98,15 @@ uint64_t TracingController::AddTraceEventWithTimestamp(
const uint64_t* arg_values, const uint64_t* arg_values,
std::unique_ptr<v8::ConvertableToTraceFormat>* arg_convertables, std::unique_ptr<v8::ConvertableToTraceFormat>* arg_convertables,
unsigned int flags, int64_t timestamp) { unsigned int flags, int64_t timestamp) {
uint64_t handle; uint64_t handle = 0;
TraceObject* trace_object = trace_buffer_->AddTraceEvent(&handle); if (mode_ != DISABLED) {
if (trace_object) { TraceObject* trace_object = trace_buffer_->AddTraceEvent(&handle);
trace_object->Initialize(phase, category_enabled_flag, name, scope, id, if (trace_object) {
bind_id, num_args, arg_names, arg_types, trace_object->Initialize(phase, category_enabled_flag, name, scope, id,
arg_values, arg_convertables, flags, timestamp, bind_id, num_args, arg_names, arg_types,
CurrentCpuTimestampMicroseconds()); arg_values, arg_convertables, flags, timestamp,
CurrentCpuTimestampMicroseconds());
}
} }
return handle; return handle;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment