The data contained in this repository can be downloaded to your computer using one of several clients.
Please see the documentation of your version control software client for more information.

Please select the desired protocol below to get the URL.

This URL has Read-Only access.

Statistics
| Branch: | Revision:

main_repo / src / node_win32_etw_provider-inl.h @ 35a1421e

History | View | Annotate | Download (5.73 KB)

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_ETW_INL_H_
23
#define SRC_ETW_INL_H_
24

    
25
#include "node_win32_etw_provider.h"
26
#include "node_etw_provider.h"
27

    
28
namespace node {
29

    
30
using namespace v8;
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(char));
41

    
42
#define ETW_WRITE_INT32_DATA(data_descriptor, data)  \
43
  EventDataDescCreate(data_descriptor, data, sizeof(int32_t));
44

    
45
#define ETW_WRITE_NET_CONNECTION(descriptors, conn)                           \
46
  ETW_WRITE_INT32_DATA(descriptors, &conn->fd);                               \
47
  ETW_WRITE_INT32_DATA(descriptors + 1, &conn->port);                         \
48
  ETW_WRITE_STRING_DATA(descriptors + 2, conn->remote);                       \
49
  ETW_WRITE_INT32_DATA(descriptors + 3, &conn->buffered);
50

    
51
#define ETW_WRITE_HTTP_SERVER_REQUEST(descriptors, req)                       \
52
  ETW_WRITE_STRING_DATA(descriptors, req->url);                               \
53
  ETW_WRITE_STRING_DATA(descriptors + 1, req->method);                        \
54
  ETW_WRITE_STRING_DATA(descriptors + 2, req->forwardedFor);
55

    
56
#define ETW_WRITE_HTTP_CLIENT_REQUEST(descriptors, req)                       \
57
  ETW_WRITE_STRING_DATA(descriptors, req->url);                               \
58
  ETW_WRITE_STRING_DATA(descriptors + 1, req->method);
59

    
60
#define ETW_WRITE_GC(descriptors, type, flags)                                \
61
  ETW_WRITE_INT32_DATA(descriptors, &type);                                   \
62
  ETW_WRITE_INT32_DATA(descriptors + 1, &flags);
63

    
64
#define ETW_WRITE_EVENT(eventDescriptor, dataDescriptors)                     \
65
  DWORD status = event_write(node_provider,                                   \
66
                             &eventDescriptor,                                \
67
                             sizeof(dataDescriptors)/sizeof(*dataDescriptors),\
68
                             dataDescriptors);                                \
69
  assert(status == ERROR_SUCCESS);
70

    
71

    
72
void NODE_HTTP_SERVER_REQUEST(node_dtrace_http_server_request_t* req,
73
    node_dtrace_connection_t* conn) {
74
  EVENT_DATA_DESCRIPTOR descriptors[7];
75
  ETW_WRITE_HTTP_SERVER_REQUEST(descriptors, req);
76
  ETW_WRITE_NET_CONNECTION(descriptors + 3, conn);
77
  ETW_WRITE_EVENT(NODE_HTTP_SERVER_REQUEST_EVENT, descriptors);
78
}
79

    
80

    
81
void NODE_HTTP_SERVER_RESPONSE(node_dtrace_connection_t* conn) {
82
  EVENT_DATA_DESCRIPTOR descriptors[4];
83
  ETW_WRITE_NET_CONNECTION(descriptors, conn);
84
  ETW_WRITE_EVENT(NODE_HTTP_SERVER_RESPONSE_EVENT, descriptors);
85
}
86

    
87

    
88
void NODE_HTTP_CLIENT_REQUEST(node_dtrace_http_client_request_t* req,
89
    node_dtrace_connection_t* conn) {
90
  EVENT_DATA_DESCRIPTOR descriptors[6];
91
  ETW_WRITE_HTTP_CLIENT_REQUEST(descriptors, req);
92
  ETW_WRITE_NET_CONNECTION(descriptors + 2, conn);
93
  ETW_WRITE_EVENT(NODE_HTTP_CLIENT_REQUEST_EVENT, descriptors);
94
}
95

    
96

    
97
void NODE_HTTP_CLIENT_RESPONSE(node_dtrace_connection_t* conn) {
98
  EVENT_DATA_DESCRIPTOR descriptors[4];
99
  ETW_WRITE_NET_CONNECTION(descriptors, conn);
100
  ETW_WRITE_EVENT(NODE_HTTP_CLIENT_RESPONSE_EVENT, descriptors);
101
}
102

    
103

    
104
void NODE_NET_SERVER_CONNECTION(node_dtrace_connection_t* conn) {
105
  EVENT_DATA_DESCRIPTOR descriptors[4];
106
  ETW_WRITE_NET_CONNECTION(descriptors, conn);
107
  ETW_WRITE_EVENT(NODE_NET_SERVER_CONNECTION_EVENT, descriptors);
108
}
109

    
110

    
111
void NODE_NET_STREAM_END(node_dtrace_connection_t* conn) {
112
  EVENT_DATA_DESCRIPTOR descriptors[4];
113
  ETW_WRITE_NET_CONNECTION(descriptors, conn);
114
  ETW_WRITE_EVENT(NODE_NET_STREAM_END_EVENT, descriptors);
115
}
116

    
117

    
118
void NODE_GC_START(GCType type, GCCallbackFlags flags) {
119
  EVENT_DATA_DESCRIPTOR descriptors[2];
120
  ETW_WRITE_GC(descriptors, type, flags);
121
  ETW_WRITE_EVENT(NODE_GC_START_EVENT, descriptors);
122
}
123

    
124

    
125
void NODE_GC_DONE(GCType type, GCCallbackFlags flags) {
126
  EVENT_DATA_DESCRIPTOR descriptors[2];
127
  ETW_WRITE_GC(descriptors, type, flags);
128
  ETW_WRITE_EVENT(NODE_GC_DONE_EVENT, descriptors);
129
}
130

    
131

    
132
bool NODE_HTTP_SERVER_REQUEST_ENABLED() { return events_enabled > 0; }
133
bool NODE_HTTP_SERVER_RESPONSE_ENABLED() { return events_enabled > 0; }
134
bool NODE_HTTP_CLIENT_REQUEST_ENABLED() { return events_enabled > 0; }
135
bool NODE_HTTP_CLIENT_RESPONSE_ENABLED() { return events_enabled > 0; }
136
bool NODE_NET_SERVER_CONNECTION_ENABLED() { return events_enabled > 0; }
137
bool NODE_NET_STREAM_END_ENABLED() { return events_enabled > 0; }
138
bool NODE_NET_SOCKET_READ_ENABLED() { return events_enabled > 0; }
139
bool NODE_NET_SOCKET_WRITE_ENABLED() { return events_enabled > 0; }
140
}
141
#endif  // SRC_ETW_INL_H_