diff --git a/configure b/configure index 112d7cda34..a97e964f7b 100755 --- a/configure +++ b/configure @@ -590,6 +590,21 @@ def configure_openssl(o): o['cflags'] += cflags.split() +def configure_winsdk(o): + if not sys.platform.startswith('win32'): + return + + try: + p = subprocess.Popen(['ctrpp.exe'], + stdin=subprocess.PIPE, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) + except OSError: + return + + o['variables']['node_has_winsdk'] = 'true' + + output = { 'variables': { 'python': sys.executable }, 'include_dirs': [], @@ -605,6 +620,7 @@ configure_cares(output) configure_libuv(output) configure_v8(output) configure_openssl(output) +configure_winsdk(output) # variables should be a root level element, # move everything else to target_defaults diff --git a/node.gyp b/node.gyp index cd5cad4a1b..8035464356 100644 --- a/node.gyp +++ b/node.gyp @@ -7,6 +7,7 @@ 'node_use_dtrace%': 'false', 'node_use_etw%': 'false', 'node_use_perfctr%': 'false', + 'node_has_winsdk%': 'false', 'node_shared_v8%': 'false', 'node_shared_zlib%': 'false', 'node_shared_http_parser%': 'false', @@ -72,6 +73,7 @@ 'include_dirs': [ 'src', + 'src/gen', 'deps/uv/src/ares', '<(SHARED_INTERMEDIATE_DIR)' # for node_natives.h ], @@ -191,8 +193,8 @@ 'src/node_win32_etw_provider-inl.h', 'src/node_win32_etw_provider.cc', 'src/node_dtrace.cc', - '<(SHARED_INTERMEDIATE_DIR)/node_etw_provider.h', - '<(SHARED_INTERMEDIATE_DIR)/node_etw_provider.rc', + 'src/gen/node_etw_provider.h', + 'src/gen/node_etw_provider.rc', ] } ], [ 'node_use_perfctr=="true"', { @@ -203,7 +205,7 @@ 'src/node_win32_perfctr_provider.cc', 'src/node_counters.cc', 'src/node_counters.h', - '<(SHARED_INTERMEDIATE_DIR)/node_perfctr_provider.rc', + 'src/gen/node_perfctr_provider.rc', ] } ], [ 'node_shared_v8=="false"', { @@ -286,16 +288,17 @@ 'target_name': 'node_etw', 'type': 'none', 'conditions': [ - [ 'node_use_etw=="true"', { + [ 'node_use_etw=="true" and node_has_winsdk=="true"', { 'actions': [ { 'action_name': 'node_etw', 'inputs': [ 'src/res/node_etw_provider.man' ], 'outputs': [ - '<(SHARED_INTERMEDIATE_DIR)/node_etw_provider.rc', - '<(SHARED_INTERMEDIATE_DIR)/node_etw_provider.h', + 'src/gen/node_etw_provider.rc', + 'src/gen/node_etw_provider.h', + 'src/gen/node_etw_providerTEMP.BIN', ], - 'action': [ 'mc <@(_inputs) -h <(SHARED_INTERMEDIATE_DIR) -r <(SHARED_INTERMEDIATE_DIR)' ] + 'action': [ 'mc <@(_inputs) -h src/gen -r src/gen' ] } ] } ] @@ -306,18 +309,19 @@ 'target_name': 'node_perfctr', 'type': 'none', 'conditions': [ - [ 'node_use_perfctr=="true"', { + [ 'node_use_perfctr=="true" and node_has_winsdk=="true"', { 'actions': [ { 'action_name': 'node_perfctr_man', 'inputs': [ 'src/res/node_perfctr_provider.man' ], 'outputs': [ - '<(SHARED_INTERMEDIATE_DIR)/node_perfctr_provider.h', - '<(SHARED_INTERMEDIATE_DIR)/node_perfctr_provider.rc', + 'src/gen/node_perfctr_provider.h', + 'src/gen/node_perfctr_provider.rc', + 'src/gen/MSG00001.BIN', ], 'action': [ 'ctrpp <@(_inputs) ' - '-o <(SHARED_INTERMEDIATE_DIR)/node_perfctr_provider.h ' - '-rc <(SHARED_INTERMEDIATE_DIR)/node_perfctr_provider.rc' + '-o src/gen/node_perfctr_provider.h ' + '-rc src/gen/node_perfctr_provider.rc' ] }, ], diff --git a/src/gen/MSG00001.bin b/src/gen/MSG00001.bin new file mode 100644 index 0000000000..051a5d8ca8 Binary files /dev/null and b/src/gen/MSG00001.bin differ diff --git a/src/gen/node_etw_provider.h b/src/gen/node_etw_provider.h new file mode 100644 index 0000000000..f9f21ad352 --- /dev/null +++ b/src/gen/node_etw_provider.h @@ -0,0 +1,59 @@ +//**********************************************************************` +//* This is an include file generated by Message Compiler. *` +//* *` +//* Copyright (c) Microsoft Corporation. All Rights Reserved. *` +//**********************************************************************` +#pragma once +//+ +// Provider NodeJS-ETW-provider Event Count 12 +//+ +EXTERN_C __declspec(selectany) const GUID NODE_ETW_PROVIDER = {0x77754e9b, 0x264b, 0x4d8d, {0xb9, 0x81, 0xe4, 0x13, 0x5c, 0x1e, 0xcb, 0x0c}}; + +// +// Opcodes +// +#define NODE_ETW_PROVIDER_OPCODE_NODE_HTTP_SERVER_REQUEST 0xa +#define NODE_ETW_PROVIDER_OPCODE_NODE_HTTP_SERVER_RESPONSE 0xb +#define NODE_ETW_PROVIDER_OPCODE_NODE_HTTP_CLIENT_REQUEST 0xc +#define NODE_ETW_PROVIDER_OPCODE_NODE_HTTP_CLIENT_RESPONSE 0xd +#define NODE_ETW_PROVIDER_OPCODE_NODE_NET_SERVER_CONNECTION 0xe +#define NODE_ETW_PROVIDER_OPCODE_NODE_NET_STREAM_END 0xf +#define NODE_ETW_PROVIDER_OPCODE_NODE_GC_START 0x10 +#define NODE_ETW_PROVIDER_OPCODE_NODE_GC_DONE 0x11 +#define NODE_ETW_PROVIDER_OPCODE_NODE_V8SYMBOL_REMOVE 0x15 +#define NODE_ETW_PROVIDER_OPCODE_NODE_V8SYMBOL_MOVE 0x16 +#define NODE_ETW_PROVIDER_OPCODE_NODE_V8SYMBOL_RESET 0x17 +#define JSCRIPT_METHOD_METHODLOAD_OPCODE 0xa + +// +// Tasks +// +#define JSCRIPT_METHOD_RUNTIME_TASK 0x1 + +// +// Event Descriptors +// +EXTERN_C __declspec(selectany) const EVENT_DESCRIPTOR NODE_HTTP_SERVER_REQUEST_EVENT = {0x1, 0x0, 0x0, 0x4, 0xa, 0x0, 0x0}; +#define NODE_HTTP_SERVER_REQUEST_EVENT_value 0x1 +EXTERN_C __declspec(selectany) const EVENT_DESCRIPTOR NODE_HTTP_SERVER_RESPONSE_EVENT = {0x2, 0x0, 0x0, 0x4, 0xb, 0x0, 0x0}; +#define NODE_HTTP_SERVER_RESPONSE_EVENT_value 0x2 +EXTERN_C __declspec(selectany) const EVENT_DESCRIPTOR NODE_HTTP_CLIENT_REQUEST_EVENT = {0x3, 0x0, 0x0, 0x4, 0xc, 0x0, 0x0}; +#define NODE_HTTP_CLIENT_REQUEST_EVENT_value 0x3 +EXTERN_C __declspec(selectany) const EVENT_DESCRIPTOR NODE_HTTP_CLIENT_RESPONSE_EVENT = {0x4, 0x0, 0x0, 0x4, 0xd, 0x0, 0x0}; +#define NODE_HTTP_CLIENT_RESPONSE_EVENT_value 0x4 +EXTERN_C __declspec(selectany) const EVENT_DESCRIPTOR NODE_NET_SERVER_CONNECTION_EVENT = {0x5, 0x0, 0x0, 0x4, 0xe, 0x0, 0x0}; +#define NODE_NET_SERVER_CONNECTION_EVENT_value 0x5 +EXTERN_C __declspec(selectany) const EVENT_DESCRIPTOR NODE_NET_STREAM_END_EVENT = {0x6, 0x0, 0x0, 0x4, 0xf, 0x0, 0x0}; +#define NODE_NET_STREAM_END_EVENT_value 0x6 +EXTERN_C __declspec(selectany) const EVENT_DESCRIPTOR NODE_GC_START_EVENT = {0x7, 0x0, 0x0, 0x4, 0x10, 0x0, 0x0}; +#define NODE_GC_START_EVENT_value 0x7 +EXTERN_C __declspec(selectany) const EVENT_DESCRIPTOR NODE_GC_DONE_EVENT = {0x8, 0x0, 0x0, 0x4, 0x11, 0x0, 0x0}; +#define NODE_GC_DONE_EVENT_value 0x8 +EXTERN_C __declspec(selectany) const EVENT_DESCRIPTOR MethodLoad = {0x9, 0x0, 0x0, 0x4, 0xa, 0x1, 0x0}; +#define MethodLoad_value 0x9 +EXTERN_C __declspec(selectany) const EVENT_DESCRIPTOR NODE_V8SYMBOL_REMOVE_EVENT = {0x15, 0x0, 0x0, 0x4, 0x15, 0x0, 0x0}; +#define NODE_V8SYMBOL_REMOVE_EVENT_value 0x15 +EXTERN_C __declspec(selectany) const EVENT_DESCRIPTOR NODE_V8SYMBOL_MOVE_EVENT = {0x16, 0x0, 0x0, 0x4, 0x16, 0x0, 0x0}; +#define NODE_V8SYMBOL_MOVE_EVENT_value 0x16 +EXTERN_C __declspec(selectany) const EVENT_DESCRIPTOR NODE_V8SYMBOL_RESET_EVENT = {0x17, 0x0, 0x0, 0x4, 0x17, 0x0, 0x0}; +#define NODE_V8SYMBOL_RESET_EVENT_value 0x17 diff --git a/src/gen/node_etw_provider.rc b/src/gen/node_etw_provider.rc new file mode 100644 index 0000000000..90b56169bc --- /dev/null +++ b/src/gen/node_etw_provider.rc @@ -0,0 +1,3 @@ +LANGUAGE 0x9,0x1 +1 11 "MSG00001.bin" +1 WEVT_TEMPLATE "node_etw_providerTEMP.BIN" diff --git a/src/gen/node_etw_providerTEMP.BIN b/src/gen/node_etw_providerTEMP.BIN new file mode 100644 index 0000000000..32bede3387 Binary files /dev/null and b/src/gen/node_etw_providerTEMP.BIN differ diff --git a/src/gen/node_perfctr_provider.h b/src/gen/node_perfctr_provider.h new file mode 100644 index 0000000000..a54ce90514 --- /dev/null +++ b/src/gen/node_perfctr_provider.h @@ -0,0 +1,79 @@ +/* This file was auto-generated from src\res\node_perfctr_provider.man by ctrpp.exe */ + +#pragma once + + +EXTERN_C DECLSPEC_SELECTANY GUID NodeCounterProviderGuid = { 0x1e2e15d7, 0x3760, 0x470e, 0x86, 0x99, 0xb9, 0xdb, 0x52, 0x48, 0xed, 0xd5 }; + +EXTERN_C DECLSPEC_SELECTANY GUID NodeCounterSetGuid = { 0x3a22a8ec, 0x297c, 0x48ac, 0xab, 0x15, 0x33, 0xec, 0x93, 0x3, 0x3f, 0xd8 }; + + +EXTERN_C DECLSPEC_SELECTANY HANDLE NodeCounterProvider = NULL; + +EXTERN_C DECLSPEC_SELECTANY struct { + PERF_COUNTERSET_INFO CounterSet; + PERF_COUNTER_INFO Counter0; + PERF_COUNTER_INFO Counter1; + PERF_COUNTER_INFO Counter2; + PERF_COUNTER_INFO Counter3; + PERF_COUNTER_INFO Counter4; + PERF_COUNTER_INFO Counter5; + PERF_COUNTER_INFO Counter6; + PERF_COUNTER_INFO Counter7; + PERF_COUNTER_INFO Counter8; + PERF_COUNTER_INFO Counter9; +} NodeCounterSetInfo = { + { { 0x3a22a8ec, 0x297c, 0x48ac, 0xab, 0x15, 0x33, 0xec, 0x93, 0x3, 0x3f, 0xd8 }, { 0x1e2e15d7, 0x3760, 0x470e, 0x86, 0x99, 0xb9, 0xdb, 0x52, 0x48, 0xed, 0xd5 }, 10, PERF_COUNTERSET_MULTI_INSTANCES }, + { 1, PERF_COUNTER_COUNTER, 0, sizeof(ULONG), PERF_DETAIL_NOVICE, 0, 0 }, + { 2, PERF_COUNTER_COUNTER, 0, sizeof(ULONG), PERF_DETAIL_NOVICE, 0, 0 }, + { 3, PERF_COUNTER_COUNTER, 0, sizeof(ULONG), PERF_DETAIL_NOVICE, 0, 0 }, + { 4, PERF_COUNTER_COUNTER, 0, sizeof(ULONG), PERF_DETAIL_NOVICE, 0, 0 }, + { 5, PERF_COUNTER_RAWCOUNT, 0, sizeof(ULONG), PERF_DETAIL_NOVICE, 0, 0 }, + { 6, PERF_COUNTER_BULK_COUNT, 0, sizeof(ULONGLONG), PERF_DETAIL_NOVICE, 4294967293, 0 }, + { 7, PERF_COUNTER_BULK_COUNT, 0, sizeof(ULONGLONG), PERF_DETAIL_NOVICE, 4294967293, 0 }, + { 8, PERF_COUNTER_RAWCOUNT, 0, sizeof(ULONG), PERF_DETAIL_NOVICE, 0, 0 }, + { 9, PERF_COUNTER_BULK_COUNT, 0, sizeof(ULONGLONG), PERF_DETAIL_NOVICE, 4294967293, 0 }, + { 10, PERF_COUNTER_BULK_COUNT, 0, sizeof(ULONGLONG), PERF_DETAIL_NOVICE, 4294967293, 0 }, +}; + +EXTERN_C FORCEINLINE +VOID +CounterCleanup( + VOID + ) +{ + if (NodeCounterProvider != NULL) { + PerfStopProvider(NodeCounterProvider); + NodeCounterProvider = NULL; + } +} + +EXTERN_C FORCEINLINE +ULONG +CounterInitialize( + VOID + ) +{ + ULONG Status; + PERF_PROVIDER_CONTEXT ProviderContext; + + ZeroMemory(&ProviderContext, sizeof(PERF_PROVIDER_CONTEXT)); + ProviderContext.ContextSize = sizeof(PERF_PROVIDER_CONTEXT); + + Status = PerfStartProviderEx(&NodeCounterProviderGuid, + &ProviderContext, + &NodeCounterProvider); + if (Status != ERROR_SUCCESS) { + NodeCounterProvider = NULL; + return Status; + } + + Status = PerfSetCounterSetInfo(NodeCounterProvider, + &NodeCounterSetInfo.CounterSet, + sizeof NodeCounterSetInfo); + if (Status != ERROR_SUCCESS) { + CounterCleanup(); + return Status; + } + return ERROR_SUCCESS; +} diff --git a/src/gen/node_perfctr_provider.rc b/src/gen/node_perfctr_provider.rc new file mode 100644 index 0000000000..c7816f5fa3 --- /dev/null +++ b/src/gen/node_perfctr_provider.rc @@ -0,0 +1,36 @@ +STRINGTABLE +BEGIN + 1 "Node.js" + 2 "Node.js" // {Locked} means don't localize + 3 "Node.js performance counters" + 5 "HTTP server requests" + 6 "HTTP server requests" // {Locked} means don't localize + 7 "Number of HTTP server requests" + 9 "HTTP server responses" + 10 "HTTP server responses" // {Locked} means don't localize + 11 "Number of HTTP server responses" + 13 "HTTP client requests" + 14 "HTTP client requests" // {Locked} means don't localize + 15 "Number of HTTP client requests" + 17 "HTTP client responses" + 18 "HTTP client responses" // {Locked} means don't localize + 19 "Number of HTTP client responses" + 21 "Active server connections" + 22 "Active server connections" // {Locked} means don't localize + 23 "Number of server connections" + 25 "Network bytes sent" + 26 "Network bytes sent" // {Locked} means don't localize + 27 "Number of bytes sent using TCP" + 29 "Network bytes received" + 30 "Network bytes received" // {Locked} means don't localize + 31 "Number of bytes received using TCP" + 33 "%Time in GC" + 34 "%Time in GC" // {Locked} means don't localize + 35 "Percent of time for last GC" + 37 "Pipe bytes sent" + 38 "Pipe bytes sent" // {Locked} means don't localize + 39 "Number of bytes sent using pipe" + 41 "Pipe bytes received" + 42 "Pipe bytes received" // {Locked} means don't localize + 43 "Number of bytes received using pipe" +END