diff --git a/src/node_dtrace.cc b/src/node_dtrace.cc index 3c407f3447f171..7808a649a4a088 100644 --- a/src/node_dtrace.cc +++ b/src/node_dtrace.cc @@ -44,6 +44,7 @@ #include "env-inl.h" #include "node_errors.h" +#include "node_external_reference.h" #include @@ -288,6 +289,14 @@ void InitDTrace(Environment* env) { }, env); } +#define NODE_PROBES(V) \ + V(DTRACE_NET_SERVER_CONNECTION) \ + V(DTRACE_NET_STREAM_END) \ + V(DTRACE_HTTP_SERVER_REQUEST) \ + V(DTRACE_HTTP_SERVER_RESPONSE) \ + V(DTRACE_HTTP_CLIENT_REQUEST) \ + V(DTRACE_HTTP_CLIENT_RESPONSE) + void InitializeDTrace(Local target, Local unused, Local context, @@ -295,16 +304,20 @@ void InitializeDTrace(Local target, Environment* env = Environment::GetCurrent(context); #if defined HAVE_DTRACE || defined HAVE_ETW -# define NODE_PROBE(name) env->SetMethod(target, #name, name); - NODE_PROBE(DTRACE_NET_SERVER_CONNECTION) - NODE_PROBE(DTRACE_NET_STREAM_END) - NODE_PROBE(DTRACE_HTTP_SERVER_REQUEST) - NODE_PROBE(DTRACE_HTTP_SERVER_RESPONSE) - NODE_PROBE(DTRACE_HTTP_CLIENT_REQUEST) - NODE_PROBE(DTRACE_HTTP_CLIENT_RESPONSE) -# undef NODE_PROBE -#endif +#define V(name) env->SetMethod(target, #name, name); + NODE_PROBES(V) +#undef V +#endif // defined HAVE_DTRACE || defined HAVE_ETW +} + +void RegisterDtraceExternalReferences(ExternalReferenceRegistry* registry) { +#if defined HAVE_DTRACE || defined HAVE_ETW +#define V(name) registry->Register(name); + NODE_PROBES(V) +#undef V +#endif // defined HAVE_DTRACE || defined HAVE_ETW } } // namespace node NODE_MODULE_CONTEXT_AWARE_INTERNAL(dtrace, node::InitializeDTrace) +NODE_MODULE_EXTERNAL_REFERENCE(dtrace, node::RegisterDtraceExternalReferences) diff --git a/src/node_external_reference.h b/src/node_external_reference.h index 8d2de64ad43445..280f1269d9bc27 100644 --- a/src/node_external_reference.h +++ b/src/node_external_reference.h @@ -92,10 +92,17 @@ class ExternalReferenceRegistry { #define EXTERNAL_REFERENCE_BINDING_LIST_INSPECTOR(V) #endif // HAVE_INSPECTOR +#if HAVE_DTRACE || HAVE_ETW +#define EXTERNAL_REFERENCE_BINDING_LIST_DTRACE(V) V(dtrace) +#else +#define EXTERNAL_REFERENCE_BINDING_LIST_DTRACE(V) +#endif + #define EXTERNAL_REFERENCE_BINDING_LIST(V) \ EXTERNAL_REFERENCE_BINDING_LIST_BASE(V) \ EXTERNAL_REFERENCE_BINDING_LIST_INSPECTOR(V) \ - EXTERNAL_REFERENCE_BINDING_LIST_I18N(V) + EXTERNAL_REFERENCE_BINDING_LIST_I18N(V) \ + EXTERNAL_REFERENCE_BINDING_LIST_DTRACE(V) } // namespace node