Skip to content

Commit bf22f99

Browse files
Dave Pachecoisaacs
authored andcommitted
dtrace: pass more arguments to probes
OSX and other DTrace implementations don't support dereferencing structs in probes. To accomodate that pass members from the struct as arguments so that DTrace is useful on those systems.
1 parent ec69fcf commit bf22f99

File tree

2 files changed

+28
-24
lines changed

2 files changed

+28
-24
lines changed

src/node_dtrace.cc

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ Handle<Value> DTRACE_NET_SERVER_CONNECTION(const Arguments& args) {
139139
NODE_NET_SERVER_CONNECTION(conn.fd, conn.remote, conn.port, \
140140
conn.buffered);
141141
#else
142-
NODE_NET_SERVER_CONNECTION(&conn);
142+
NODE_NET_SERVER_CONNECTION(&conn, conn.remote, conn.port);
143143
#endif
144144

145145
return Undefined();
@@ -157,7 +157,7 @@ Handle<Value> DTRACE_NET_STREAM_END(const Arguments& args) {
157157
#ifdef HAVE_SYSTEMTAP
158158
NODE_NET_STREAM_END(conn.fd, conn.remote, conn.port, conn.buffered);
159159
#else
160-
NODE_NET_STREAM_END(&conn);
160+
NODE_NET_STREAM_END(&conn, conn.remote, conn.port);
161161
#endif
162162

163163
return Undefined();
@@ -181,7 +181,7 @@ Handle<Value> DTRACE_NET_SOCKET_READ(const Arguments& args) {
181181
"argument 1 to be number of bytes"))));
182182
}
183183
int nbytes = args[1]->Int32Value();
184-
NODE_NET_SOCKET_READ(&conn, nbytes);
184+
NODE_NET_SOCKET_READ(&conn, nbytes, conn.remote, conn.port);
185185
#endif
186186

187187
return Undefined();
@@ -205,7 +205,7 @@ Handle<Value> DTRACE_NET_SOCKET_WRITE(const Arguments& args) {
205205
"argument 1 to be number of bytes"))));
206206
}
207207
int nbytes = args[1]->Int32Value();
208-
NODE_NET_SOCKET_WRITE(&conn, nbytes);
208+
NODE_NET_SOCKET_WRITE(&conn, nbytes, conn.remote, conn.port);
209209
#endif
210210

211211
return Undefined();
@@ -247,7 +247,8 @@ Handle<Value> DTRACE_HTTP_SERVER_REQUEST(const Arguments& args) {
247247
NODE_HTTP_SERVER_REQUEST(&req, conn.fd, conn.remote, conn.port, \
248248
conn.buffered);
249249
#else
250-
NODE_HTTP_SERVER_REQUEST(&req, &conn);
250+
NODE_HTTP_SERVER_REQUEST(&req, &conn, conn.remote, conn.port, req.method, \
251+
req.url);
251252
#endif
252253
return Undefined();
253254
}
@@ -264,7 +265,7 @@ Handle<Value> DTRACE_HTTP_SERVER_RESPONSE(const Arguments& args) {
264265
#ifdef HAVE_SYSTEMTAP
265266
NODE_HTTP_SERVER_RESPONSE(conn.fd, conn.remote, conn.port, conn.buffered);
266267
#else
267-
NODE_HTTP_SERVER_RESPONSE(&conn);
268+
NODE_HTTP_SERVER_RESPONSE(&conn, conn.remote, conn.port);
268269
#endif
269270

270271
return Undefined();
@@ -310,7 +311,8 @@ Handle<Value> DTRACE_HTTP_CLIENT_REQUEST(const Arguments& args) {
310311
NODE_HTTP_CLIENT_REQUEST(&req, conn.fd, conn.remote, conn.port, \
311312
conn.buffered);
312313
#else
313-
NODE_HTTP_CLIENT_REQUEST(&req, &conn);
314+
NODE_HTTP_CLIENT_REQUEST(&req, &conn, conn.remote, conn.port, req.method, \
315+
req.url);
314316
#endif
315317
return Undefined();
316318
}
@@ -326,7 +328,7 @@ Handle<Value> DTRACE_HTTP_CLIENT_RESPONSE(const Arguments& args) {
326328
#ifdef HAVE_SYSTEMTAP
327329
NODE_HTTP_CLIENT_RESPONSE(conn.fd, conn.remote, conn.port, conn.buffered);
328330
#else
329-
NODE_HTTP_CLIENT_RESPONSE(&conn);
331+
NODE_HTTP_CLIENT_RESPONSE(&conn, conn.remote, conn.port);
330332
#endif
331333

332334
return Undefined();

src/node_provider.d

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -52,24 +52,26 @@ typedef struct {
5252
} node_http_request_t;
5353

5454
provider node {
55-
probe net__server__connection(node_dtrace_connection_t *c) :
56-
(node_connection_t *c);
57-
probe net__stream__end(node_dtrace_connection_t *c) :
58-
(node_connection_t *c);
59-
probe net__socket__read(node_dtrace_connection_t *c, int b) :
60-
(node_connection_t *c, int b);
61-
probe net__socket__write(node_dtrace_connection_t *c, int b) :
62-
(node_connection_t *c, int b);
55+
probe net__server__connection(node_dtrace_connection_t *c,
56+
const char *a, int p) : (node_connection_t *c, string a, int p);
57+
probe net__stream__end(node_dtrace_connection_t *c, const char *a,
58+
int p) : (node_connection_t *c, string a, int p);
59+
probe net__socket__read(node_dtrace_connection_t *c, int b,
60+
const char *a, int p) : (node_connection_t *c, int b, string a, int p);
61+
probe net__socket__write(node_dtrace_connection_t *c, int b,
62+
const char *a, int p) : (node_connection_t *c, int b, string a, int p);
6363
probe http__server__request(node_dtrace_http_server_request_t *h,
64-
node_dtrace_connection_t *c) :
65-
(node_http_request_t *h, node_connection_t *c);
66-
probe http__server__response(node_dtrace_connection_t *c) :
67-
(node_connection_t *c);
64+
node_dtrace_connection_t *c, const char *a, int p, const char *m,
65+
const char *u) : (node_http_request_t *h, node_connection_t *c,
66+
string a, int p, string m, string u);
67+
probe http__server__response(node_dtrace_connection_t *c, const char *a,
68+
int p) : (node_connection_t *c, string a, int p);
6869
probe http__client__request(node_dtrace_http_client_request_t *h,
69-
node_dtrace_connection_t *c) :
70-
(node_http_request_t *h, node_connection_t *c);
71-
probe http__client__response(node_dtrace_connection_t *c) :
72-
(node_connection_t *c);
70+
node_dtrace_connection_t *c, const char *a, int p, const char *m,
71+
const char *u) : (node_http_request_t *h, node_connection_t *c, string a,
72+
int p, string m, string u);
73+
probe http__client__response(node_dtrace_connection_t *c, const char *a,
74+
int p) : (node_connection_t *c, string a, int p);
7375
probe gc__start(int t, int f);
7476
probe gc__done(int t, int f);
7577
};

0 commit comments

Comments
 (0)