Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Wynholds <jan@rootmusic.com>2012-10-10 02:09:07 +0400
committerBen Noordhuis <info@bnoordhuis.nl>2012-11-01 04:25:22 +0400
commit06810b29fae7c549c3a016f2faa3cf6b444a1149 (patch)
tree8088e13139fc993be84c11cbd059a4f999651039 /src/node_dtrace.cc
parentab1e66d93f4eddf23f62fd69094690124357e3e9 (diff)
tracing: add systemtap support
Diffstat (limited to 'src/node_dtrace.cc')
-rw-r--r--src/node_dtrace.cc92
1 files changed, 76 insertions, 16 deletions
diff --git a/src/node_dtrace.cc b/src/node_dtrace.cc
index e560999c52f..df42af2a977 100644
--- a/src/node_dtrace.cc
+++ b/src/node_dtrace.cc
@@ -19,14 +19,23 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
-#include "node_dtrace.h"
-#include <string.h>
#ifdef HAVE_DTRACE
+#include "node_dtrace.h"
+#include <string.h>
#include "node_provider.h"
#elif HAVE_ETW
+#include "node_dtrace.h"
+#include <string.h>
#include "node_win32_etw_provider.h"
#include "node_win32_etw_provider-inl.h"
+#elif HAVE_SYSTEMTAP
+#include <string.h>
+#include <node.h>
+#include <v8.h>
+#include <sys/sdt.h>
+#include "node_systemtap.h"
+#include "node_dtrace.h"
#else
#define NODE_HTTP_SERVER_REQUEST(arg0, arg1)
#define NODE_HTTP_SERVER_REQUEST_ENABLED() (0)
@@ -118,67 +127,86 @@ using namespace v8;
Handle<Value> DTRACE_NET_SERVER_CONNECTION(const Arguments& args) {
+#ifndef HAVE_SYSTEMTAP
if (!NODE_NET_SERVER_CONNECTION_ENABLED())
return Undefined();
+#endif
HandleScope scope;
SLURP_CONNECTION(args[0], conn);
+#ifdef HAVE_SYSTEMTAP
+ NODE_NET_SERVER_CONNECTION(conn.fd, conn.remote, conn.port, \
+ conn.buffered);
+#else
NODE_NET_SERVER_CONNECTION(&conn);
+#endif
return Undefined();
}
Handle<Value> DTRACE_NET_STREAM_END(const Arguments& args) {
+#ifndef HAVE_SYSTEMTAP
if (!NODE_NET_STREAM_END_ENABLED())
return Undefined();
+#endif
HandleScope scope;
SLURP_CONNECTION(args[0], conn);
+#ifdef HAVE_SYSTEMTAP
+ NODE_NET_STREAM_END(conn.fd, conn.remote, conn.port, conn.buffered);
+#else
NODE_NET_STREAM_END(&conn);
+#endif
return Undefined();
}
Handle<Value> DTRACE_NET_SOCKET_READ(const Arguments& args) {
+#ifndef HAVE_SYSTEMTAP
if (!NODE_NET_SOCKET_READ_ENABLED())
return Undefined();
+#endif
HandleScope scope;
- int nbytes;
SLURP_CONNECTION(args[0], conn);
+#ifdef HAVE_SYSTEMTAP
+ NODE_NET_SOCKET_READ(conn.fd, conn.remote, conn.port, conn.buffered);
+#else
if (!args[1]->IsNumber()) {
return (ThrowException(Exception::Error(String::New("expected "
"argument 1 to be number of bytes"))));
}
-
- nbytes = args[1]->Int32Value();
-
+ int nbytes = args[1]->Int32Value();
NODE_NET_SOCKET_READ(&conn, nbytes);
+#endif
return Undefined();
}
Handle<Value> DTRACE_NET_SOCKET_WRITE(const Arguments& args) {
+#ifndef HAVE_SYSTEMTAP
if (!NODE_NET_SOCKET_WRITE_ENABLED())
return Undefined();
+#endif
HandleScope scope;
- int nbytes;
SLURP_CONNECTION(args[0], conn);
+#ifdef HAVE_SYSTEMTAP
+ NODE_NET_SOCKET_WRITE(conn.fd, conn.remote, conn.port, conn.buffered);
+#else
if (!args[1]->IsNumber()) {
return (ThrowException(Exception::Error(String::New("expected "
"argument 1 to be number of bytes"))));
}
-
- nbytes = args[1]->Int32Value();
-
+ int nbytes = args[1]->Int32Value();
NODE_NET_SOCKET_WRITE(&conn, nbytes);
+#endif
return Undefined();
}
@@ -186,8 +214,10 @@ Handle<Value> DTRACE_NET_SOCKET_WRITE(const Arguments& args) {
Handle<Value> DTRACE_HTTP_SERVER_REQUEST(const Arguments& args) {
node_dtrace_http_server_request_t req;
+#ifndef HAVE_SYSTEMTAP
if (!NODE_HTTP_SERVER_REQUEST_ENABLED())
return Undefined();
+#endif
HandleScope scope;
@@ -213,18 +243,29 @@ Handle<Value> DTRACE_HTTP_SERVER_REQUEST(const Arguments& args) {
SLURP_CONNECTION(args[1], conn);
+#ifdef HAVE_SYSTEMTAP
+ NODE_HTTP_SERVER_REQUEST(&req, conn.fd, conn.remote, conn.port, \
+ conn.buffered);
+#else
NODE_HTTP_SERVER_REQUEST(&req, &conn);
+#endif
return Undefined();
}
Handle<Value> DTRACE_HTTP_SERVER_RESPONSE(const Arguments& args) {
+#ifndef HAVE_SYSTEMTAP
if (!NODE_HTTP_SERVER_RESPONSE_ENABLED())
return Undefined();
+#endif
HandleScope scope;
SLURP_CONNECTION(args[0], conn);
+#ifdef HAVE_SYSTEMTAP
+ NODE_HTTP_SERVER_RESPONSE(conn.fd, conn.remote, conn.port, conn.buffered);
+#else
NODE_HTTP_SERVER_RESPONSE(&conn);
+#endif
return Undefined();
}
@@ -233,8 +274,10 @@ Handle<Value> DTRACE_HTTP_CLIENT_REQUEST(const Arguments& args) {
node_dtrace_http_client_request_t req;
char *header;
+#ifndef HAVE_SYSTEMTAP
if (!NODE_HTTP_CLIENT_REQUEST_ENABLED())
return Undefined();
+#endif
HandleScope scope;
@@ -263,26 +306,40 @@ Handle<Value> DTRACE_HTTP_CLIENT_REQUEST(const Arguments& args) {
*header = '\0';
SLURP_CONNECTION_HTTP_CLIENT(args[1], conn);
+#ifdef HAVE_SYSTEMTAP
+ NODE_HTTP_CLIENT_REQUEST(&req, conn.fd, conn.remote, conn.port, \
+ conn.buffered);
+#else
NODE_HTTP_CLIENT_REQUEST(&req, &conn);
+#endif
return Undefined();
}
Handle<Value> DTRACE_HTTP_CLIENT_RESPONSE(const Arguments& args) {
+#ifndef HAVE_SYSTEMTAP
if (!NODE_HTTP_CLIENT_RESPONSE_ENABLED())
return Undefined();
-
+#endif
HandleScope scope;
SLURP_CONNECTION_HTTP_CLIENT_RESPONSE(args[0], args[1], conn);
+#ifdef HAVE_SYSTEMTAP
+ NODE_HTTP_CLIENT_RESPONSE(conn.fd, conn.remote, conn.port, conn.buffered);
+#else
NODE_HTTP_CLIENT_RESPONSE(&conn);
+#endif
return Undefined();
}
-#define NODE_PROBE(name) #name, name
+#define NODE_PROBE(name) #name, name, Persistent<FunctionTemplate>()
static int dtrace_gc_start(GCType type, GCCallbackFlags flags) {
+#ifdef HAVE_SYSTEMTAP
+ NODE_GC_START();
+#else
NODE_GC_START(type, flags);
+#endif
/*
* We avoid the tail-call elimination of the USDT probe (which screws up
* args) by forcing a return of 0.
@@ -291,7 +348,11 @@ static int dtrace_gc_start(GCType type, GCCallbackFlags flags) {
}
static int dtrace_gc_done(GCType type, GCCallbackFlags flags) {
+#ifdef HAVE_SYSTEMTAP
+ NODE_GC_DONE();
+#else
NODE_GC_DONE(type, flags);
+#endif
return 0;
}
@@ -308,11 +369,10 @@ void InitDTrace(Handle<Object> target) {
{ NODE_PROBE(DTRACE_HTTP_SERVER_REQUEST) },
{ NODE_PROBE(DTRACE_HTTP_SERVER_RESPONSE) },
{ NODE_PROBE(DTRACE_HTTP_CLIENT_REQUEST) },
- { NODE_PROBE(DTRACE_HTTP_CLIENT_RESPONSE) },
- { NULL }
+ { NODE_PROBE(DTRACE_HTTP_CLIENT_RESPONSE) }
};
- for (int i = 0; tab[i].name != NULL; i++) {
+ for (unsigned int i = 0; i < ARRAY_SIZE(tab); i++) {
tab[i].templ = Persistent<FunctionTemplate>::New(
FunctionTemplate::New(tab[i].func));
target->Set(String::NewSymbol(tab[i].name), tab[i].templ->GetFunction());
@@ -322,7 +382,7 @@ void InitDTrace(Handle<Object> target) {
init_etw();
#endif
-#if defined HAVE_DTRACE || defined HAVE_ETW
+#if defined HAVE_DTRACE || defined HAVE_ETW || defined HAVE_SYSTEMTAP
v8::V8::AddGCPrologueCallback((GCPrologueCallback)dtrace_gc_start);
v8::V8::AddGCEpilogueCallback((GCEpilogueCallback)dtrace_gc_done);
#endif