11cb0ef41Sopenharmony_ci// Copyright Joyent, Inc. and other Node contributors.
21cb0ef41Sopenharmony_ci//
31cb0ef41Sopenharmony_ci// Permission is hereby granted, free of charge, to any person obtaining a
41cb0ef41Sopenharmony_ci// copy of this software and associated documentation files (the
51cb0ef41Sopenharmony_ci// "Software"), to deal in the Software without restriction, including
61cb0ef41Sopenharmony_ci// without limitation the rights to use, copy, modify, merge, publish,
71cb0ef41Sopenharmony_ci// distribute, sublicense, and/or sell copies of the Software, and to permit
81cb0ef41Sopenharmony_ci// persons to whom the Software is furnished to do so, subject to the
91cb0ef41Sopenharmony_ci// following conditions:
101cb0ef41Sopenharmony_ci//
111cb0ef41Sopenharmony_ci// The above copyright notice and this permission notice shall be included
121cb0ef41Sopenharmony_ci// in all copies or substantial portions of the Software.
131cb0ef41Sopenharmony_ci//
141cb0ef41Sopenharmony_ci// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
151cb0ef41Sopenharmony_ci// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
161cb0ef41Sopenharmony_ci// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
171cb0ef41Sopenharmony_ci// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
181cb0ef41Sopenharmony_ci// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
191cb0ef41Sopenharmony_ci// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
201cb0ef41Sopenharmony_ci// USE OR OTHER DEALINGS IN THE SOFTWARE.
211cb0ef41Sopenharmony_ci
221cb0ef41Sopenharmony_ci#include "node_dtrace.h"
231cb0ef41Sopenharmony_ci
241cb0ef41Sopenharmony_ci#ifdef HAVE_DTRACE
251cb0ef41Sopenharmony_ci#include "node_provider.h"
261cb0ef41Sopenharmony_ci#elif HAVE_ETW
271cb0ef41Sopenharmony_ci#include "node_win32_etw_provider-inl.h"
281cb0ef41Sopenharmony_ci#else
291cb0ef41Sopenharmony_ci#define NODE_HTTP_SERVER_REQUEST(arg0, arg1)
301cb0ef41Sopenharmony_ci#define NODE_HTTP_SERVER_REQUEST_ENABLED() (0)
311cb0ef41Sopenharmony_ci#define NODE_HTTP_SERVER_RESPONSE(arg0)
321cb0ef41Sopenharmony_ci#define NODE_HTTP_SERVER_RESPONSE_ENABLED() (0)
331cb0ef41Sopenharmony_ci#define NODE_HTTP_CLIENT_REQUEST(arg0, arg1)
341cb0ef41Sopenharmony_ci#define NODE_HTTP_CLIENT_REQUEST_ENABLED() (0)
351cb0ef41Sopenharmony_ci#define NODE_HTTP_CLIENT_RESPONSE(arg0)
361cb0ef41Sopenharmony_ci#define NODE_HTTP_CLIENT_RESPONSE_ENABLED() (0)
371cb0ef41Sopenharmony_ci#define NODE_NET_SERVER_CONNECTION(arg0)
381cb0ef41Sopenharmony_ci#define NODE_NET_SERVER_CONNECTION_ENABLED() (0)
391cb0ef41Sopenharmony_ci#define NODE_NET_STREAM_END(arg0)
401cb0ef41Sopenharmony_ci#define NODE_NET_STREAM_END_ENABLED() (0)
411cb0ef41Sopenharmony_ci#define NODE_GC_START(arg0, arg1, arg2)
421cb0ef41Sopenharmony_ci#define NODE_GC_DONE(arg0, arg1, arg2)
431cb0ef41Sopenharmony_ci#endif
441cb0ef41Sopenharmony_ci
451cb0ef41Sopenharmony_ci#include "env-inl.h"
461cb0ef41Sopenharmony_ci#include "node_errors.h"
471cb0ef41Sopenharmony_ci#include "node_external_reference.h"
481cb0ef41Sopenharmony_ci
491cb0ef41Sopenharmony_ci#include <cstring>
501cb0ef41Sopenharmony_ci
511cb0ef41Sopenharmony_cinamespace node {
521cb0ef41Sopenharmony_ci
531cb0ef41Sopenharmony_ciusing v8::Context;
541cb0ef41Sopenharmony_ciusing v8::FunctionCallbackInfo;
551cb0ef41Sopenharmony_ciusing v8::GCCallbackFlags;
561cb0ef41Sopenharmony_ciusing v8::GCType;
571cb0ef41Sopenharmony_ciusing v8::HandleScope;
581cb0ef41Sopenharmony_ciusing v8::Isolate;
591cb0ef41Sopenharmony_ciusing v8::Local;
601cb0ef41Sopenharmony_ciusing v8::Object;
611cb0ef41Sopenharmony_ciusing v8::Value;
621cb0ef41Sopenharmony_ci
631cb0ef41Sopenharmony_ci#define SLURP_STRING(obj, member, valp)                                    \
641cb0ef41Sopenharmony_ci  if (!(obj)->IsObject()) {                                                \
651cb0ef41Sopenharmony_ci    return node::THROW_ERR_INVALID_ARG_TYPE(env,                           \
661cb0ef41Sopenharmony_ci        "expected object for " #obj " to contain string member " #member); \
671cb0ef41Sopenharmony_ci  }                                                                        \
681cb0ef41Sopenharmony_ci  node::Utf8Value _##member(env->isolate(),                                \
691cb0ef41Sopenharmony_ci      obj->Get(env->context(),                                             \
701cb0ef41Sopenharmony_ci               OneByteString(env->isolate(), #member)).ToLocalChecked());  \
711cb0ef41Sopenharmony_ci  if ((*(const char **)valp = *_##member) == nullptr)                      \
721cb0ef41Sopenharmony_ci    *(const char **)valp = "<unknown>";
731cb0ef41Sopenharmony_ci
741cb0ef41Sopenharmony_ci#define SLURP_INT(obj, member, valp)                                           \
751cb0ef41Sopenharmony_ci  if (!(obj)->IsObject()) {                                                    \
761cb0ef41Sopenharmony_ci    return node::THROW_ERR_INVALID_ARG_TYPE(                                   \
771cb0ef41Sopenharmony_ci        env,                                                                   \
781cb0ef41Sopenharmony_ci        "expected object for " #obj " to contain integer member " #member);    \
791cb0ef41Sopenharmony_ci  }                                                                            \
801cb0ef41Sopenharmony_ci  *valp = obj->Get(env->context(),                                             \
811cb0ef41Sopenharmony_ci                   OneByteString(env->isolate(), #member)).ToLocalChecked()    \
821cb0ef41Sopenharmony_ci              ->Int32Value(env->context())                                     \
831cb0ef41Sopenharmony_ci              .FromJust();
841cb0ef41Sopenharmony_ci
851cb0ef41Sopenharmony_ci#define SLURP_OBJECT(obj, member, valp)                                    \
861cb0ef41Sopenharmony_ci  if (!(obj)->IsObject()) {                                                \
871cb0ef41Sopenharmony_ci    return node::THROW_ERR_INVALID_ARG_TYPE(env,                           \
881cb0ef41Sopenharmony_ci        "expected object for " #obj " to contain object member " #member); \
891cb0ef41Sopenharmony_ci  }                                                                        \
901cb0ef41Sopenharmony_ci  *valp = obj->Get(env->context(),                                         \
911cb0ef41Sopenharmony_ci      OneByteString(env->isolate(), #member)).ToLocalChecked().As<Object>();
921cb0ef41Sopenharmony_ci
931cb0ef41Sopenharmony_ci#define SLURP_CONNECTION(arg, conn)                                        \
941cb0ef41Sopenharmony_ci  if (!(arg)->IsObject()) {                                                \
951cb0ef41Sopenharmony_ci    return node::THROW_ERR_INVALID_ARG_TYPE(env,                           \
961cb0ef41Sopenharmony_ci        "expected argument " #arg " to be a connection object");           \
971cb0ef41Sopenharmony_ci  }                                                                        \
981cb0ef41Sopenharmony_ci  node_dtrace_connection_t conn;                                           \
991cb0ef41Sopenharmony_ci  Local<Object> _##conn = arg.As<Object>();                                \
1001cb0ef41Sopenharmony_ci  Local<Value> _handle =                                                   \
1011cb0ef41Sopenharmony_ci      (_##conn)->Get(env->context(),                                       \
1021cb0ef41Sopenharmony_ci                     FIXED_ONE_BYTE_STRING(env->isolate(), "_handle"))     \
1031cb0ef41Sopenharmony_ci                     .ToLocalChecked();                                    \
1041cb0ef41Sopenharmony_ci  if (_handle->IsObject()) {                                               \
1051cb0ef41Sopenharmony_ci    SLURP_INT(_handle.As<Object>(), fd, &conn.fd);                         \
1061cb0ef41Sopenharmony_ci  } else {                                                                 \
1071cb0ef41Sopenharmony_ci    conn.fd = -1;                                                          \
1081cb0ef41Sopenharmony_ci  }                                                                        \
1091cb0ef41Sopenharmony_ci  SLURP_STRING(_##conn, remoteAddress, &conn.remote);                      \
1101cb0ef41Sopenharmony_ci  SLURP_INT(_##conn, remotePort, &conn.port);                              \
1111cb0ef41Sopenharmony_ci  SLURP_INT(_##conn, bufferSize, &conn.buffered);
1121cb0ef41Sopenharmony_ci
1131cb0ef41Sopenharmony_ci#define SLURP_CONNECTION_HTTP_CLIENT(arg, conn)                            \
1141cb0ef41Sopenharmony_ci  if (!(arg)->IsObject()) {                                                \
1151cb0ef41Sopenharmony_ci    return node::THROW_ERR_INVALID_ARG_TYPE(env,                           \
1161cb0ef41Sopenharmony_ci        "expected argument " #arg " to be a connection object");           \
1171cb0ef41Sopenharmony_ci  }                                                                        \
1181cb0ef41Sopenharmony_ci  node_dtrace_connection_t conn;                                           \
1191cb0ef41Sopenharmony_ci  Local<Object> _##conn = arg.As<Object>();                                \
1201cb0ef41Sopenharmony_ci  SLURP_INT(_##conn, fd, &conn.fd);                                        \
1211cb0ef41Sopenharmony_ci  SLURP_STRING(_##conn, host, &conn.remote);                               \
1221cb0ef41Sopenharmony_ci  SLURP_INT(_##conn, port, &conn.port);                                    \
1231cb0ef41Sopenharmony_ci  SLURP_INT(_##conn, bufferSize, &conn.buffered);
1241cb0ef41Sopenharmony_ci
1251cb0ef41Sopenharmony_ci#define SLURP_CONNECTION_HTTP_CLIENT_RESPONSE(arg0, arg1, conn)            \
1261cb0ef41Sopenharmony_ci  if (!(arg0)->IsObject()) {                                               \
1271cb0ef41Sopenharmony_ci    return node::THROW_ERR_INVALID_ARG_TYPE(env,                           \
1281cb0ef41Sopenharmony_ci        "expected argument " #arg0 " to be a connection object");          \
1291cb0ef41Sopenharmony_ci  }                                                                        \
1301cb0ef41Sopenharmony_ci  if (!(arg1)->IsObject()) {                                               \
1311cb0ef41Sopenharmony_ci    return node::THROW_ERR_INVALID_ARG_TYPE(env,                           \
1321cb0ef41Sopenharmony_ci        "expected argument " #arg1 " to be a connection object");          \
1331cb0ef41Sopenharmony_ci  }                                                                        \
1341cb0ef41Sopenharmony_ci  node_dtrace_connection_t conn;                                           \
1351cb0ef41Sopenharmony_ci  Local<Object> _##conn = arg0.As<Object>();                               \
1361cb0ef41Sopenharmony_ci  SLURP_INT(_##conn, fd, &conn.fd);                                        \
1371cb0ef41Sopenharmony_ci  SLURP_INT(_##conn, bufferSize, &conn.buffered);                          \
1381cb0ef41Sopenharmony_ci  _##conn = arg1.As<Object>();                                             \
1391cb0ef41Sopenharmony_ci  SLURP_STRING(_##conn, host, &conn.remote);                               \
1401cb0ef41Sopenharmony_ci  SLURP_INT(_##conn, port, &conn.port);
1411cb0ef41Sopenharmony_ci
1421cb0ef41Sopenharmony_ci
1431cb0ef41Sopenharmony_civoid DTRACE_NET_SERVER_CONNECTION(const FunctionCallbackInfo<Value>& args) {
1441cb0ef41Sopenharmony_ci  if (!NODE_NET_SERVER_CONNECTION_ENABLED())
1451cb0ef41Sopenharmony_ci    return;
1461cb0ef41Sopenharmony_ci  Environment* env = Environment::GetCurrent(args);
1471cb0ef41Sopenharmony_ci  SLURP_CONNECTION(args[0], conn);
1481cb0ef41Sopenharmony_ci  NODE_NET_SERVER_CONNECTION(&conn, conn.remote, conn.port, conn.fd);
1491cb0ef41Sopenharmony_ci}
1501cb0ef41Sopenharmony_ci
1511cb0ef41Sopenharmony_ci
1521cb0ef41Sopenharmony_civoid DTRACE_NET_STREAM_END(const FunctionCallbackInfo<Value>& args) {
1531cb0ef41Sopenharmony_ci  if (!NODE_NET_STREAM_END_ENABLED())
1541cb0ef41Sopenharmony_ci    return;
1551cb0ef41Sopenharmony_ci  Environment* env = Environment::GetCurrent(args);
1561cb0ef41Sopenharmony_ci  SLURP_CONNECTION(args[0], conn);
1571cb0ef41Sopenharmony_ci  NODE_NET_STREAM_END(&conn, conn.remote, conn.port, conn.fd);
1581cb0ef41Sopenharmony_ci}
1591cb0ef41Sopenharmony_ci
1601cb0ef41Sopenharmony_civoid DTRACE_HTTP_SERVER_REQUEST(const FunctionCallbackInfo<Value>& args) {
1611cb0ef41Sopenharmony_ci  node_dtrace_http_server_request_t req;
1621cb0ef41Sopenharmony_ci
1631cb0ef41Sopenharmony_ci  if (!NODE_HTTP_SERVER_REQUEST_ENABLED())
1641cb0ef41Sopenharmony_ci    return;
1651cb0ef41Sopenharmony_ci
1661cb0ef41Sopenharmony_ci  Environment* env = Environment::GetCurrent(args);
1671cb0ef41Sopenharmony_ci  HandleScope scope(env->isolate());
1681cb0ef41Sopenharmony_ci  Local<Object> arg0 = args[0].As<Object>();
1691cb0ef41Sopenharmony_ci  Local<Object> headers;
1701cb0ef41Sopenharmony_ci
1711cb0ef41Sopenharmony_ci  memset(&req, 0, sizeof(req));
1721cb0ef41Sopenharmony_ci  req._un.version = 1;
1731cb0ef41Sopenharmony_ci  SLURP_STRING(arg0, url, &req.url);
1741cb0ef41Sopenharmony_ci  SLURP_STRING(arg0, method, &req.method);
1751cb0ef41Sopenharmony_ci  SLURP_OBJECT(arg0, headers, &headers);
1761cb0ef41Sopenharmony_ci
1771cb0ef41Sopenharmony_ci  if (!(headers)->IsObject()) {
1781cb0ef41Sopenharmony_ci    return node::THROW_ERR_INVALID_ARG_TYPE(env,
1791cb0ef41Sopenharmony_ci        "expected object for request to contain string member headers");
1801cb0ef41Sopenharmony_ci  }
1811cb0ef41Sopenharmony_ci
1821cb0ef41Sopenharmony_ci  Local<Value> strfwdfor = headers->Get(
1831cb0ef41Sopenharmony_ci      env->context(), env->x_forwarded_string()).ToLocalChecked();
1841cb0ef41Sopenharmony_ci  node::Utf8Value fwdfor(env->isolate(), strfwdfor);
1851cb0ef41Sopenharmony_ci
1861cb0ef41Sopenharmony_ci  if (!strfwdfor->IsString() || (req.forwardedFor = *fwdfor) == nullptr)
1871cb0ef41Sopenharmony_ci    req.forwardedFor = const_cast<char*>("");
1881cb0ef41Sopenharmony_ci
1891cb0ef41Sopenharmony_ci  SLURP_CONNECTION(args[1], conn);
1901cb0ef41Sopenharmony_ci  NODE_HTTP_SERVER_REQUEST(&req, &conn, conn.remote, conn.port, req.method, \
1911cb0ef41Sopenharmony_ci                           req.url, conn.fd);
1921cb0ef41Sopenharmony_ci}
1931cb0ef41Sopenharmony_ci
1941cb0ef41Sopenharmony_ci
1951cb0ef41Sopenharmony_civoid DTRACE_HTTP_SERVER_RESPONSE(const FunctionCallbackInfo<Value>& args) {
1961cb0ef41Sopenharmony_ci  if (!NODE_HTTP_SERVER_RESPONSE_ENABLED())
1971cb0ef41Sopenharmony_ci    return;
1981cb0ef41Sopenharmony_ci  Environment* env = Environment::GetCurrent(args);
1991cb0ef41Sopenharmony_ci  SLURP_CONNECTION(args[0], conn);
2001cb0ef41Sopenharmony_ci  NODE_HTTP_SERVER_RESPONSE(&conn, conn.remote, conn.port, conn.fd);
2011cb0ef41Sopenharmony_ci}
2021cb0ef41Sopenharmony_ci
2031cb0ef41Sopenharmony_ci
2041cb0ef41Sopenharmony_civoid DTRACE_HTTP_CLIENT_REQUEST(const FunctionCallbackInfo<Value>& args) {
2051cb0ef41Sopenharmony_ci  node_dtrace_http_client_request_t req;
2061cb0ef41Sopenharmony_ci  char* header;
2071cb0ef41Sopenharmony_ci
2081cb0ef41Sopenharmony_ci  if (!NODE_HTTP_CLIENT_REQUEST_ENABLED())
2091cb0ef41Sopenharmony_ci    return;
2101cb0ef41Sopenharmony_ci
2111cb0ef41Sopenharmony_ci  Environment* env = Environment::GetCurrent(args);
2121cb0ef41Sopenharmony_ci  HandleScope scope(env->isolate());
2131cb0ef41Sopenharmony_ci
2141cb0ef41Sopenharmony_ci  /*
2151cb0ef41Sopenharmony_ci   * For the method and URL, we're going to dig them out of the header.  This
2161cb0ef41Sopenharmony_ci   * is not as efficient as it could be, but we would rather not force the
2171cb0ef41Sopenharmony_ci   * caller here to retain their method and URL until the time at which
2181cb0ef41Sopenharmony_ci   * DTRACE_HTTP_CLIENT_REQUEST can be called.
2191cb0ef41Sopenharmony_ci   */
2201cb0ef41Sopenharmony_ci  Local<Object> arg0 = args[0].As<Object>();
2211cb0ef41Sopenharmony_ci  SLURP_STRING(arg0, _header, &header);
2221cb0ef41Sopenharmony_ci
2231cb0ef41Sopenharmony_ci  req.method = header;
2241cb0ef41Sopenharmony_ci
2251cb0ef41Sopenharmony_ci  while (*header != '\0' && *header != ' ')
2261cb0ef41Sopenharmony_ci    header++;
2271cb0ef41Sopenharmony_ci
2281cb0ef41Sopenharmony_ci  if (*header != '\0')
2291cb0ef41Sopenharmony_ci    *header++ = '\0';
2301cb0ef41Sopenharmony_ci
2311cb0ef41Sopenharmony_ci  req.url = header;
2321cb0ef41Sopenharmony_ci
2331cb0ef41Sopenharmony_ci  while (*header != '\0' && *header != ' ')
2341cb0ef41Sopenharmony_ci    header++;
2351cb0ef41Sopenharmony_ci
2361cb0ef41Sopenharmony_ci  *header = '\0';
2371cb0ef41Sopenharmony_ci
2381cb0ef41Sopenharmony_ci  SLURP_CONNECTION_HTTP_CLIENT(args[1], conn);
2391cb0ef41Sopenharmony_ci  NODE_HTTP_CLIENT_REQUEST(&req, &conn, conn.remote, conn.port, req.method, \
2401cb0ef41Sopenharmony_ci                           req.url, conn.fd);
2411cb0ef41Sopenharmony_ci}
2421cb0ef41Sopenharmony_ci
2431cb0ef41Sopenharmony_ci
2441cb0ef41Sopenharmony_civoid DTRACE_HTTP_CLIENT_RESPONSE(const FunctionCallbackInfo<Value>& args) {
2451cb0ef41Sopenharmony_ci  if (!NODE_HTTP_CLIENT_RESPONSE_ENABLED())
2461cb0ef41Sopenharmony_ci    return;
2471cb0ef41Sopenharmony_ci  Environment* env = Environment::GetCurrent(args);
2481cb0ef41Sopenharmony_ci  SLURP_CONNECTION_HTTP_CLIENT_RESPONSE(args[0], args[1], conn);
2491cb0ef41Sopenharmony_ci  NODE_HTTP_CLIENT_RESPONSE(&conn, conn.remote, conn.port, conn.fd);
2501cb0ef41Sopenharmony_ci}
2511cb0ef41Sopenharmony_ci
2521cb0ef41Sopenharmony_civoid dtrace_gc_start(Isolate* isolate,
2531cb0ef41Sopenharmony_ci                     GCType type,
2541cb0ef41Sopenharmony_ci                     GCCallbackFlags flags,
2551cb0ef41Sopenharmony_ci                     void* data) {
2561cb0ef41Sopenharmony_ci  // Previous versions of this probe point only logged type and flags.
2571cb0ef41Sopenharmony_ci  // That's why for reasons of backwards compatibility the isolate goes last.
2581cb0ef41Sopenharmony_ci  NODE_GC_START(type, flags, isolate);
2591cb0ef41Sopenharmony_ci}
2601cb0ef41Sopenharmony_ci
2611cb0ef41Sopenharmony_civoid dtrace_gc_done(Isolate* isolate,
2621cb0ef41Sopenharmony_ci                    GCType type,
2631cb0ef41Sopenharmony_ci                    GCCallbackFlags flags,
2641cb0ef41Sopenharmony_ci                    void* data) {
2651cb0ef41Sopenharmony_ci  // Previous versions of this probe point only logged type and flags.
2661cb0ef41Sopenharmony_ci  // That's why for reasons of backwards compatibility the isolate goes last.
2671cb0ef41Sopenharmony_ci  NODE_GC_DONE(type, flags, isolate);
2681cb0ef41Sopenharmony_ci}
2691cb0ef41Sopenharmony_ci
2701cb0ef41Sopenharmony_ci
2711cb0ef41Sopenharmony_civoid InitDTrace(Environment* env) {
2721cb0ef41Sopenharmony_ci#ifdef HAVE_ETW
2731cb0ef41Sopenharmony_ci  // ETW is neither thread-safe nor does it clean up resources on exit,
2741cb0ef41Sopenharmony_ci  // so we can use it only on the main thread.
2751cb0ef41Sopenharmony_ci  if (env->is_main_thread()) {
2761cb0ef41Sopenharmony_ci    init_etw();
2771cb0ef41Sopenharmony_ci  }
2781cb0ef41Sopenharmony_ci#endif
2791cb0ef41Sopenharmony_ci
2801cb0ef41Sopenharmony_ci  // We need to use the variant of GC callbacks that takes data to
2811cb0ef41Sopenharmony_ci  // avoid running into DCHECKs when multiple Environments try to add
2821cb0ef41Sopenharmony_ci  // the same callback to the same isolate multiple times.
2831cb0ef41Sopenharmony_ci  env->isolate()->AddGCPrologueCallback(dtrace_gc_start, env);
2841cb0ef41Sopenharmony_ci  env->isolate()->AddGCEpilogueCallback(dtrace_gc_done, env);
2851cb0ef41Sopenharmony_ci  env->AddCleanupHook([](void* data) {
2861cb0ef41Sopenharmony_ci    Environment* env = static_cast<Environment*>(data);
2871cb0ef41Sopenharmony_ci    env->isolate()->RemoveGCPrologueCallback(dtrace_gc_start, env);
2881cb0ef41Sopenharmony_ci    env->isolate()->RemoveGCEpilogueCallback(dtrace_gc_done, env);
2891cb0ef41Sopenharmony_ci  }, env);
2901cb0ef41Sopenharmony_ci}
2911cb0ef41Sopenharmony_ci
2921cb0ef41Sopenharmony_ci#define NODE_PROBES(V)                                                         \
2931cb0ef41Sopenharmony_ci  V(DTRACE_NET_SERVER_CONNECTION)                                              \
2941cb0ef41Sopenharmony_ci  V(DTRACE_NET_STREAM_END)                                                     \
2951cb0ef41Sopenharmony_ci  V(DTRACE_HTTP_SERVER_REQUEST)                                                \
2961cb0ef41Sopenharmony_ci  V(DTRACE_HTTP_SERVER_RESPONSE)                                               \
2971cb0ef41Sopenharmony_ci  V(DTRACE_HTTP_CLIENT_REQUEST)                                                \
2981cb0ef41Sopenharmony_ci  V(DTRACE_HTTP_CLIENT_RESPONSE)
2991cb0ef41Sopenharmony_ci
3001cb0ef41Sopenharmony_civoid InitializeDTrace(Local<Object> target,
3011cb0ef41Sopenharmony_ci                      Local<Value> unused,
3021cb0ef41Sopenharmony_ci                      Local<Context> context,
3031cb0ef41Sopenharmony_ci                      void* priv) {
3041cb0ef41Sopenharmony_ci#if defined HAVE_DTRACE || defined HAVE_ETW
3051cb0ef41Sopenharmony_ci#define V(name) SetMethod(context, target, #name, name);
3061cb0ef41Sopenharmony_ci  NODE_PROBES(V)
3071cb0ef41Sopenharmony_ci#undef V
3081cb0ef41Sopenharmony_ci#endif  // defined HAVE_DTRACE || defined HAVE_ETW
3091cb0ef41Sopenharmony_ci}
3101cb0ef41Sopenharmony_ci
3111cb0ef41Sopenharmony_civoid RegisterDtraceExternalReferences(ExternalReferenceRegistry* registry) {
3121cb0ef41Sopenharmony_ci#if defined HAVE_DTRACE || defined HAVE_ETW
3131cb0ef41Sopenharmony_ci#define V(name) registry->Register(name);
3141cb0ef41Sopenharmony_ci  NODE_PROBES(V)
3151cb0ef41Sopenharmony_ci#undef V
3161cb0ef41Sopenharmony_ci#endif  // defined HAVE_DTRACE || defined HAVE_ETW
3171cb0ef41Sopenharmony_ci}
3181cb0ef41Sopenharmony_ci
3191cb0ef41Sopenharmony_ci}  // namespace node
3201cb0ef41Sopenharmony_ciNODE_BINDING_CONTEXT_AWARE_INTERNAL(dtrace, node::InitializeDTrace)
3211cb0ef41Sopenharmony_ciNODE_BINDING_EXTERNAL_REFERENCE(dtrace, node::RegisterDtraceExternalReferences)
322