The C and C++ Include Header Files
/usr/include/nodejs/src/node_win32_etw_provider-inl.h
$ cat -n /usr/include/nodejs/src/node_win32_etw_provider-inl.h 1 // Copyright Joyent, Inc. and other Node contributors. 2 // 3 // Permission is hereby granted, free of charge, to any person obtaining a 4 // copy of this software and associated documentation files (the 5 // "Software"), to deal in the Software without restriction, including 6 // without limitation the rights to use, copy, modify, merge, publish, 7 // distribute, sublicense, and/or sell copies of the Software, and to permit 8 // persons to whom the Software is furnished to do so, subject to the 9 // following conditions: 10 // 11 // The above copyright notice and this permission notice shall be included 12 // in all copies or substantial portions of the Software. 13 // 14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN 17 // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 20 // USE OR OTHER DEALINGS IN THE SOFTWARE. 21 22 #ifndef SRC_NODE_WIN32_ETW_PROVIDER_INL_H_ 23 #define SRC_NODE_WIN32_ETW_PROVIDER_INL_H_ 24 25 #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS 26 27 #include "node_win32_etw_provider.h" 28 #include "node_etw_provider.h" 29 30 namespace node { 31 32 // From node_win32_etw_provider.cc 33 extern REGHANDLE node_provider; 34 extern EventWriteFunc event_write; 35 extern int events_enabled; 36 37 #define ETW_WRITE_STRING_DATA(data_descriptor, data) \ 38 EventDataDescCreate(data_descriptor, \ 39 data, \ 40 (strlen(data) + 1) * sizeof(*data)); 41 42 #define ETW_WRITE_INT32_DATA(data_descriptor, data) \ 43 EventDataDescCreate(data_descriptor, data, sizeof(int32_t)); 44 45 #define ETW_WRITE_INT64_DATA(data_descriptor, data) \ 46 EventDataDescCreate(data_descriptor, data, sizeof(int64_t)); 47 48 #define ETW_WRITE_ADDRESS_DATA(data_descriptor, data) \ 49 EventDataDescCreate(data_descriptor, data, sizeof(intptr_t)); 50 51 #define ETW_WRITE_INT16_DATA(data_descriptor, data) \ 52 EventDataDescCreate(data_descriptor, data, sizeof(int16_t)); 53 54 #define ETW_WRITE_WSTRING_DATA_LENGTH(data_descriptor, data, data_len_bytes) \ 55 EventDataDescCreate(data_descriptor, \ 56 data, \ 57 data_len_bytes); 58 59 #define ETW_WRITE_NET_CONNECTION(descriptors, conn) \ 60 ETW_WRITE_INT32_DATA(descriptors, &conn->fd); \ 61 ETW_WRITE_INT32_DATA(descriptors + 1, &conn->port); \ 62 ETW_WRITE_STRING_DATA(descriptors + 2, conn->remote); \ 63 ETW_WRITE_INT32_DATA(descriptors + 3, &conn->buffered); 64 65 #define ETW_WRITE_HTTP_SERVER_REQUEST(descriptors, req) \ 66 ETW_WRITE_STRING_DATA(descriptors, req->url); \ 67 ETW_WRITE_STRING_DATA(descriptors + 1, req->method); \ 68 ETW_WRITE_STRING_DATA(descriptors + 2, req->forwardedFor); 69 70 #define ETW_WRITE_HTTP_CLIENT_REQUEST(descriptors, req) \ 71 ETW_WRITE_STRING_DATA(descriptors, req->url); \ 72 ETW_WRITE_STRING_DATA(descriptors + 1, req->method); 73 74 #define ETW_WRITE_GC(descriptors, type, flags) \ 75 ETW_WRITE_INT32_DATA(descriptors, &type); \ 76 ETW_WRITE_INT32_DATA(descriptors + 1, &flags); 77 78 #define ETW_WRITE_V8ADDRESSCHANGE(descriptors, addr1, addr2) \ 79 ETW_WRITE_ADDRESS_DATA(descriptors, &addr1); \ 80 ETW_WRITE_ADDRESS_DATA(descriptors + 1, &addr2); 81 82 #define ETW_WRITE_JSMETHOD_LOADUNLOAD(descriptors, \ 83 context, \ 84 startAddr, \ 85 size, \ 86 id, \ 87 flags, \ 88 rangeId, \ 89 sourceId, \ 90 line, \ 91 col, \ 92 name, \ 93 name_len_bytes) \ 94 ETW_WRITE_ADDRESS_DATA(descriptors, &context); \ 95 ETW_WRITE_ADDRESS_DATA(descriptors + 1, &startAddr); \ 96 ETW_WRITE_INT64_DATA(descriptors + 2, &size); \ 97 ETW_WRITE_INT32_DATA(descriptors + 3, &id); \ 98 ETW_WRITE_INT16_DATA(descriptors + 4, &flags); \ 99 ETW_WRITE_INT16_DATA(descriptors + 5, &rangeId); \ 100 ETW_WRITE_INT64_DATA(descriptors + 6, &sourceId); \ 101 ETW_WRITE_INT32_DATA(descriptors + 7, &line); \ 102 ETW_WRITE_INT32_DATA(descriptors + 8, &col); \ 103 ETW_WRITE_WSTRING_DATA_LENGTH(descriptors + 9, name, name_len_bytes); 104 105 106 #define ETW_WRITE_EVENT(eventDescriptor, dataDescriptors) \ 107 DWORD status = event_write(node_provider, \ 108 &eventDescriptor, \ 109 sizeof(dataDescriptors) / \ 110 sizeof(*dataDescriptors), \ 111 dataDescriptors); \ 112 CHECK_EQ(status, ERROR_SUCCESS); 113 114 #define ETW_WRITE_EMPTY_EVENT(eventDescriptor) \ 115 DWORD status = event_write(node_provider, \ 116 &eventDescriptor, \ 117 0, \ 118 NULL); // NOLINT (readability/null_usage) \ 119 CHECK_EQ(status, ERROR_SUCCESS); 120 121 122 void NODE_HTTP_SERVER_REQUEST(node_dtrace_http_server_request_t* req, 123 node_dtrace_connection_t* conn, const char* remote, int port, 124 const char* method, const char* url, int fd) { 125 EVENT_DATA_DESCRIPTOR descriptors[7]; 126 ETW_WRITE_HTTP_SERVER_REQUEST(descriptors, req); 127 ETW_WRITE_NET_CONNECTION(descriptors + 3, conn); 128 ETW_WRITE_EVENT(NODE_HTTP_SERVER_REQUEST_EVENT, descriptors); 129 } 130 131 132 void NODE_HTTP_SERVER_RESPONSE(node_dtrace_connection_t* conn, 133 const char* remote, int port, int fd) { 134 EVENT_DATA_DESCRIPTOR descriptors[4]; 135 ETW_WRITE_NET_CONNECTION(descriptors, conn); 136 ETW_WRITE_EVENT(NODE_HTTP_SERVER_RESPONSE_EVENT, descriptors); 137 } 138 139 140 void NODE_HTTP_CLIENT_REQUEST(node_dtrace_http_client_request_t* req, 141 node_dtrace_connection_t* conn, const char* remote, int port, 142 const char* method, const char* url, int fd) { 143 EVENT_DATA_DESCRIPTOR descriptors[6]; 144 ETW_WRITE_HTTP_CLIENT_REQUEST(descriptors, req); 145 ETW_WRITE_NET_CONNECTION(descriptors + 2, conn); 146 ETW_WRITE_EVENT(NODE_HTTP_CLIENT_REQUEST_EVENT, descriptors); 147 } 148 149 150 void NODE_HTTP_CLIENT_RESPONSE(node_dtrace_connection_t* conn, 151 const char* remote, int port, int fd) { 152 EVENT_DATA_DESCRIPTOR descriptors[4]; 153 ETW_WRITE_NET_CONNECTION(descriptors, conn); 154 ETW_WRITE_EVENT(NODE_HTTP_CLIENT_RESPONSE_EVENT, descriptors); 155 } 156 157 158 void NODE_NET_SERVER_CONNECTION(node_dtrace_connection_t* conn, 159 const char* remote, int port, int fd) { 160 EVENT_DATA_DESCRIPTOR descriptors[4]; 161 ETW_WRITE_NET_CONNECTION(descriptors, conn); 162 ETW_WRITE_EVENT(NODE_NET_SERVER_CONNECTION_EVENT, descriptors); 163 } 164 165 166 void NODE_NET_STREAM_END(node_dtrace_connection_t* conn, 167 const char* remote, int port, int fd) { 168 EVENT_DATA_DESCRIPTOR descriptors[4]; 169 ETW_WRITE_NET_CONNECTION(descriptors, conn); 170 ETW_WRITE_EVENT(NODE_NET_STREAM_END_EVENT, descriptors); 171 } 172 173 174 void NODE_GC_START(v8::GCType type, 175 v8::GCCallbackFlags flags, 176 v8::Isolate* isolate) { 177 if (events_enabled > 0) { 178 EVENT_DATA_DESCRIPTOR descriptors[2]; 179 ETW_WRITE_GC(descriptors, type, flags); 180 ETW_WRITE_EVENT(NODE_GC_START_EVENT, descriptors); 181 } 182 } 183 184 185 void NODE_GC_DONE(v8::GCType type, 186 v8::GCCallbackFlags flags, 187 v8::Isolate* isolate) { 188 if (events_enabled > 0) { 189 EVENT_DATA_DESCRIPTOR descriptors[2]; 190 ETW_WRITE_GC(descriptors, type, flags); 191 ETW_WRITE_EVENT(NODE_GC_DONE_EVENT, descriptors); 192 } 193 } 194 195 196 void NODE_V8SYMBOL_REMOVE(const void* addr1, const void* addr2) { 197 if (events_enabled > 0) { 198 EVENT_DATA_DESCRIPTOR descriptors[2]; 199 ETW_WRITE_V8ADDRESSCHANGE(descriptors, addr1, addr2); 200 ETW_WRITE_EVENT(NODE_V8SYMBOL_REMOVE_EVENT, descriptors); 201 } 202 } 203 204 205 void NODE_V8SYMBOL_MOVE(const void* addr1, const void* addr2) { 206 if (events_enabled > 0) { 207 EVENT_DATA_DESCRIPTOR descriptors[2]; 208 ETW_WRITE_V8ADDRESSCHANGE(descriptors, addr1, addr2); 209 ETW_WRITE_EVENT(NODE_V8SYMBOL_MOVE_EVENT, descriptors); 210 } 211 } 212 213 214 void NODE_V8SYMBOL_RESET() { 215 if (events_enabled > 0) { 216 ETW_WRITE_EMPTY_EVENT(NODE_V8SYMBOL_RESET_EVENT); 217 } 218 } 219 220 #define SETSYMBUF(s) \ 221 wcscpy(symbuf, s); \ 222 symbol_len = arraysize(s) - 1; 223 224 void NODE_V8SYMBOL_ADD(LPCSTR symbol, 225 int symbol_len, 226 const void* addr1, 227 int len) { 228 if (events_enabled > 0) { 229 wchar_t symbuf[128]; 230 if (symbol == nullptr) { 231 SETSYMBUF(L"nullptr"); 232 } else { 233 symbol_len = MultiByteToWideChar(CP_ACP, 234 0, 235 symbol, 236 symbol_len, 237 symbuf, 238 128); 239 if (symbol_len == 0) { 240 SETSYMBUF(L"Invalid"); 241 } else { 242 if (symbol_len > 127) { 243 symbol_len = 127; 244 } 245 symbuf[symbol_len] = L'\0'; 246 } 247 } 248 void* context = nullptr; 249 INT64 size = (INT64)len; 250 INT32 id = (INT32)addr1; 251 INT16 flags = 0; 252 INT16 rangeid = 1; 253 INT32 col = 1; 254 INT32 line = 1; 255 INT64 sourceid = 0; 256 EVENT_DATA_DESCRIPTOR descriptors[10]; 257 ETW_WRITE_JSMETHOD_LOADUNLOAD(descriptors, 258 context, 259 addr1, 260 size, 261 id, 262 flags, 263 rangeid, 264 sourceid, 265 line, 266 col, 267 symbuf, 268 (symbol_len + 1) * sizeof(symbuf[0])); 269 ETW_WRITE_EVENT(MethodLoad, descriptors); 270 } 271 } 272 #undef SETSYMBUF 273 274 275 bool NODE_HTTP_SERVER_REQUEST_ENABLED() { return events_enabled > 0; } 276 bool NODE_HTTP_SERVER_RESPONSE_ENABLED() { return events_enabled > 0; } 277 bool NODE_HTTP_CLIENT_REQUEST_ENABLED() { return events_enabled > 0; } 278 bool NODE_HTTP_CLIENT_RESPONSE_ENABLED() { return events_enabled > 0; } 279 bool NODE_NET_SERVER_CONNECTION_ENABLED() { return events_enabled > 0; } 280 bool NODE_NET_STREAM_END_ENABLED() { return events_enabled > 0; } 281 bool NODE_V8SYMBOL_ENABLED() { return events_enabled > 0; } 282 283 } // namespace node 284 285 #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS 286 287 #endif // SRC_NODE_WIN32_ETW_PROVIDER_INL_H_
Contact us
|
About us
|
Term of use
|
Copyright © 2000-2024 MyWebUniversity.com ™