Skip to content

Commit

Permalink
dtrace: pass more arguments to probes
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Dave Pacheco authored and bnoordhuis committed Mar 30, 2013
1 parent fe7440c commit 7634069
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 24 deletions.
18 changes: 10 additions & 8 deletions src/node_dtrace.cc
Expand Up @@ -139,7 +139,7 @@ Handle<Value> DTRACE_NET_SERVER_CONNECTION(const Arguments& args) {
NODE_NET_SERVER_CONNECTION(conn.fd, conn.remote, conn.port, \
conn.buffered);
#else
NODE_NET_SERVER_CONNECTION(&conn);
NODE_NET_SERVER_CONNECTION(&conn, conn.remote, conn.port);
#endif

return Undefined(node_isolate);
Expand All @@ -157,7 +157,7 @@ Handle<Value> DTRACE_NET_STREAM_END(const Arguments& args) {
#ifdef HAVE_SYSTEMTAP
NODE_NET_STREAM_END(conn.fd, conn.remote, conn.port, conn.buffered);
#else
NODE_NET_STREAM_END(&conn);
NODE_NET_STREAM_END(&conn, conn.remote, conn.port);
#endif

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

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

return Undefined(node_isolate);
Expand Down Expand Up @@ -247,7 +247,8 @@ Handle<Value> DTRACE_HTTP_SERVER_REQUEST(const Arguments& args) {
NODE_HTTP_SERVER_REQUEST(&req, conn.fd, conn.remote, conn.port, \
conn.buffered);
#else
NODE_HTTP_SERVER_REQUEST(&req, &conn);
NODE_HTTP_SERVER_REQUEST(&req, &conn, conn.remote, conn.port, req.method, \
req.url);
#endif
return Undefined(node_isolate);
}
Expand All @@ -264,7 +265,7 @@ Handle<Value> DTRACE_HTTP_SERVER_RESPONSE(const Arguments& args) {
#ifdef HAVE_SYSTEMTAP
NODE_HTTP_SERVER_RESPONSE(conn.fd, conn.remote, conn.port, conn.buffered);
#else
NODE_HTTP_SERVER_RESPONSE(&conn);
NODE_HTTP_SERVER_RESPONSE(&conn, conn.remote, conn.port);
#endif

return Undefined(node_isolate);
Expand Down Expand Up @@ -310,7 +311,8 @@ Handle<Value> DTRACE_HTTP_CLIENT_REQUEST(const Arguments& args) {
NODE_HTTP_CLIENT_REQUEST(&req, conn.fd, conn.remote, conn.port, \
conn.buffered);
#else
NODE_HTTP_CLIENT_REQUEST(&req, &conn);
NODE_HTTP_CLIENT_REQUEST(&req, &conn, conn.remote, conn.port, req.method, \
req.url);
#endif
return Undefined(node_isolate);
}
Expand All @@ -326,7 +328,7 @@ Handle<Value> DTRACE_HTTP_CLIENT_RESPONSE(const Arguments& args) {
#ifdef HAVE_SYSTEMTAP
NODE_HTTP_CLIENT_RESPONSE(conn.fd, conn.remote, conn.port, conn.buffered);
#else
NODE_HTTP_CLIENT_RESPONSE(&conn);
NODE_HTTP_CLIENT_RESPONSE(&conn, conn.remote, conn.port);
#endif

return Undefined(node_isolate);
Expand Down
34 changes: 18 additions & 16 deletions src/node_provider.d
Expand Up @@ -52,24 +52,26 @@ typedef struct {
} node_http_request_t;

provider node {
probe net__server__connection(node_dtrace_connection_t *c) :
(node_connection_t *c);
probe net__stream__end(node_dtrace_connection_t *c) :
(node_connection_t *c);
probe net__socket__read(node_dtrace_connection_t *c, int b) :
(node_connection_t *c, int b);
probe net__socket__write(node_dtrace_connection_t *c, int b) :
(node_connection_t *c, int b);
probe net__server__connection(node_dtrace_connection_t *c,
const char *a, int p) : (node_connection_t *c, string a, int p);
probe net__stream__end(node_dtrace_connection_t *c, const char *a,
int p) : (node_connection_t *c, string a, int p);
probe net__socket__read(node_dtrace_connection_t *c, int b,
const char *a, int p) : (node_connection_t *c, int b, string a, int p);
probe net__socket__write(node_dtrace_connection_t *c, int b,
const char *a, int p) : (node_connection_t *c, int b, string a, int p);
probe http__server__request(node_dtrace_http_server_request_t *h,
node_dtrace_connection_t *c) :
(node_http_request_t *h, node_connection_t *c);
probe http__server__response(node_dtrace_connection_t *c) :
(node_connection_t *c);
node_dtrace_connection_t *c, const char *a, int p, const char *m,
const char *u) : (node_http_request_t *h, node_connection_t *c,
string a, int p, string m, string u);
probe http__server__response(node_dtrace_connection_t *c, const char *a,
int p) : (node_connection_t *c, string a, int p);
probe http__client__request(node_dtrace_http_client_request_t *h,
node_dtrace_connection_t *c) :
(node_http_request_t *h, node_connection_t *c);
probe http__client__response(node_dtrace_connection_t *c) :
(node_connection_t *c);
node_dtrace_connection_t *c, const char *a, int p, const char *m,
const char *u) : (node_http_request_t *h, node_connection_t *c, string a,
int p, string m, string u);
probe http__client__response(node_dtrace_connection_t *c, const char *a,
int p) : (node_connection_t *c, string a, int p);
probe gc__start(int t, int f);
probe gc__done(int t, int f);
};
Expand Down

0 comments on commit 7634069

Please sign in to comment.