diff options
author | Andreas Madsen <amwebdk@gmail.com> | 2017-11-24 18:08:47 +0300 |
---|---|---|
committer | Andreas Madsen <amwebdk@gmail.com> | 2017-11-24 23:52:11 +0300 |
commit | ad80c2120672975018f5d93dad5e5cb9cf900de2 (patch) | |
tree | 132b8ef2283e4120640736a408390b7786b5f7cf /src/node_trace_events.cc | |
parent | dc389bf7cc8b297d4f8dd24603ee1793116f3414 (diff) |
trace_events: add executionAsyncId to init events
async_hooks emits trace_events. This adds the executionAsyncId to the
init events. In theory this could be inferred from the before and after
events but this is much simpler and doesn't require knowledge of all
events.
PR-URL: https://github.com/nodejs/node/pull/17196
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Diffstat (limited to 'src/node_trace_events.cc')
-rw-r--r-- | src/node_trace_events.cc | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/src/node_trace_events.cc b/src/node_trace_events.cc index b0ffe68eae3..f269b32fbef 100644 --- a/src/node_trace_events.cc +++ b/src/node_trace_events.cc @@ -70,20 +70,19 @@ static void Emit(const FunctionCallbackInfo<Value>& args) { id = args[3]->IntegerValue(context).ToChecked(); } - // TODO(AndreasMadsen): Two extra arguments are not supported. // TODO(AndreasMadsen): String values are not supported. int32_t num_args = 0; - const char* arg_names[1]; - uint8_t arg_types[1]; - uint64_t arg_values[1]; + const char* arg_names[2]; + uint8_t arg_types[2]; + uint64_t arg_values[2]; // Create Utf8Value in the function scope to prevent deallocation. // The c-string will be copied by TRACE_EVENT_API_ADD_TRACE_EVENT at the end. Utf8Value arg1NameValue(env->isolate(), args[4]); + Utf8Value arg2NameValue(env->isolate(), args[6]); - if (args.Length() < 6 || (args[4]->IsUndefined() && args[5]->IsUndefined())) { - num_args = 0; - } else { + if (args.Length() >= 6 && + (!args[4]->IsUndefined() || !args[5]->IsUndefined())) { num_args = 1; arg_types[0] = TRACE_VALUE_TYPE_INT; @@ -94,6 +93,18 @@ static void Emit(const FunctionCallbackInfo<Value>& args) { arg_values[0] = args[5]->IntegerValue(context).ToChecked(); } + if (args.Length() >= 8 && + (!args[6]->IsUndefined() || !args[7]->IsUndefined())) { + num_args = 2; + arg_types[1] = TRACE_VALUE_TYPE_INT; + + CHECK(args[6]->IsString()); + arg_names[1] = arg2NameValue.out(); + + CHECK(args[7]->IsNumber()); + arg_values[1] = args[7]->IntegerValue(context).ToChecked(); + } + // The TRACE_EVENT_FLAG_COPY flag indicates that the name and argument // name should be copied thus they don't need to long-lived pointers. // The category name still won't be copied and thus need to be a long-lived |