Revision 06810b29 src/node_dtrace.cc

View differences:

src/node_dtrace.cc
19 19
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20 20
// USE OR OTHER DEALINGS IN THE SOFTWARE.
21 21

  
22
#include "node_dtrace.h"
23
#include <string.h>
24 22

  
25 23
#ifdef HAVE_DTRACE
24
#include "node_dtrace.h"
25
#include <string.h>
26 26
#include "node_provider.h"
27 27
#elif HAVE_ETW
28
#include "node_dtrace.h"
29
#include <string.h>
28 30
#include "node_win32_etw_provider.h"
29 31
#include "node_win32_etw_provider-inl.h"
32
#elif HAVE_SYSTEMTAP
33
#include <string.h>
34
#include <node.h>
35
#include <v8.h>
36
#include <sys/sdt.h>
37
#include "node_systemtap.h"
38
#include "node_dtrace.h"
30 39
#else
31 40
#define NODE_HTTP_SERVER_REQUEST(arg0, arg1)
32 41
#define NODE_HTTP_SERVER_REQUEST_ENABLED() (0)
......
118 127

  
119 128

  
120 129
Handle<Value> DTRACE_NET_SERVER_CONNECTION(const Arguments& args) {
130
#ifndef HAVE_SYSTEMTAP
121 131
  if (!NODE_NET_SERVER_CONNECTION_ENABLED())
122 132
    return Undefined();
133
#endif
123 134

  
124 135
  HandleScope scope;
125 136

  
126 137
  SLURP_CONNECTION(args[0], conn);
138
#ifdef HAVE_SYSTEMTAP
139
  NODE_NET_SERVER_CONNECTION(conn.fd, conn.remote, conn.port, \
140
                             conn.buffered);
141
#else
127 142
  NODE_NET_SERVER_CONNECTION(&conn);
143
#endif
128 144

  
129 145
  return Undefined();
130 146
}
131 147

  
132 148
Handle<Value> DTRACE_NET_STREAM_END(const Arguments& args) {
149
#ifndef HAVE_SYSTEMTAP
133 150
  if (!NODE_NET_STREAM_END_ENABLED())
134 151
    return Undefined();
152
#endif
135 153

  
136 154
  HandleScope scope;
137 155

  
138 156
  SLURP_CONNECTION(args[0], conn);
157
#ifdef HAVE_SYSTEMTAP
158
  NODE_NET_STREAM_END(conn.fd, conn.remote, conn.port, conn.buffered);
159
#else
139 160
  NODE_NET_STREAM_END(&conn);
161
#endif
140 162

  
141 163
  return Undefined();
142 164
}
143 165

  
144 166
Handle<Value> DTRACE_NET_SOCKET_READ(const Arguments& args) {
167
#ifndef HAVE_SYSTEMTAP
145 168
  if (!NODE_NET_SOCKET_READ_ENABLED())
146 169
    return Undefined();
170
#endif
147 171

  
148 172
  HandleScope scope;
149
  int nbytes;
150 173

  
151 174
  SLURP_CONNECTION(args[0], conn);
152 175

  
176
#ifdef HAVE_SYSTEMTAP
177
  NODE_NET_SOCKET_READ(conn.fd, conn.remote, conn.port, conn.buffered);
178
#else
153 179
  if (!args[1]->IsNumber()) {
154 180
    return (ThrowException(Exception::Error(String::New("expected " 
155 181
      "argument 1 to be number of bytes"))));
156 182
  }
157

  
158
  nbytes = args[1]->Int32Value();
159

  
183
  int nbytes = args[1]->Int32Value();
160 184
  NODE_NET_SOCKET_READ(&conn, nbytes);
185
#endif
161 186

  
162 187
  return Undefined();
163 188
}
164 189

  
165 190
Handle<Value> DTRACE_NET_SOCKET_WRITE(const Arguments& args) {
191
#ifndef HAVE_SYSTEMTAP
166 192
  if (!NODE_NET_SOCKET_WRITE_ENABLED())
167 193
    return Undefined();
194
#endif
168 195

  
169 196
  HandleScope scope;
170
  int nbytes;
171 197

  
172 198
  SLURP_CONNECTION(args[0], conn);
173 199

  
200
#ifdef HAVE_SYSTEMTAP
201
  NODE_NET_SOCKET_WRITE(conn.fd, conn.remote, conn.port, conn.buffered);
202
#else
174 203
  if (!args[1]->IsNumber()) {
175 204
    return (ThrowException(Exception::Error(String::New("expected " 
176 205
      "argument 1 to be number of bytes"))));
177 206
  }
178

  
179
  nbytes = args[1]->Int32Value();
180

  
207
  int nbytes = args[1]->Int32Value();
181 208
  NODE_NET_SOCKET_WRITE(&conn, nbytes);
209
#endif
182 210

  
183 211
  return Undefined();
184 212
}
......
186 214
Handle<Value> DTRACE_HTTP_SERVER_REQUEST(const Arguments& args) {
187 215
  node_dtrace_http_server_request_t req;
188 216

  
217
#ifndef HAVE_SYSTEMTAP
189 218
  if (!NODE_HTTP_SERVER_REQUEST_ENABLED())
190 219
    return Undefined();
220
#endif
191 221

  
192 222
  HandleScope scope;
193 223

  
......
213 243

  
214 244
  SLURP_CONNECTION(args[1], conn);
215 245

  
246
#ifdef HAVE_SYSTEMTAP
247
  NODE_HTTP_SERVER_REQUEST(&req, conn.fd, conn.remote, conn.port, \
248
                           conn.buffered);
249
#else
216 250
  NODE_HTTP_SERVER_REQUEST(&req, &conn);
251
#endif
217 252
  return Undefined();
218 253
}
219 254

  
220 255
Handle<Value> DTRACE_HTTP_SERVER_RESPONSE(const Arguments& args) {
256
#ifndef HAVE_SYSTEMTAP
221 257
  if (!NODE_HTTP_SERVER_RESPONSE_ENABLED())
222 258
    return Undefined();
259
#endif
223 260

  
224 261
  HandleScope scope;
225 262

  
226 263
  SLURP_CONNECTION(args[0], conn);
264
#ifdef HAVE_SYSTEMTAP
265
  NODE_HTTP_SERVER_RESPONSE(conn.fd, conn.remote, conn.port, conn.buffered);
266
#else
227 267
  NODE_HTTP_SERVER_RESPONSE(&conn);
268
#endif
228 269

  
229 270
  return Undefined();
230 271
}
......
233 274
  node_dtrace_http_client_request_t req;
234 275
  char *header;
235 276

  
277
#ifndef HAVE_SYSTEMTAP
236 278
  if (!NODE_HTTP_CLIENT_REQUEST_ENABLED())
237 279
    return Undefined();
280
#endif
238 281

  
239 282
  HandleScope scope;
240 283

  
......
263 306
  *header = '\0';
264 307

  
265 308
  SLURP_CONNECTION_HTTP_CLIENT(args[1], conn);
309
#ifdef HAVE_SYSTEMTAP
310
  NODE_HTTP_CLIENT_REQUEST(&req, conn.fd, conn.remote, conn.port, \
311
                           conn.buffered);
312
#else
266 313
  NODE_HTTP_CLIENT_REQUEST(&req, &conn);
314
#endif
267 315
  return Undefined();
268 316
}
269 317

  
270 318
Handle<Value> DTRACE_HTTP_CLIENT_RESPONSE(const Arguments& args) {
319
#ifndef HAVE_SYSTEMTAP
271 320
  if (!NODE_HTTP_CLIENT_RESPONSE_ENABLED())
272 321
    return Undefined();
273

  
322
#endif
274 323
  HandleScope scope;
275 324

  
276 325
  SLURP_CONNECTION_HTTP_CLIENT_RESPONSE(args[0], args[1], conn);
326
#ifdef HAVE_SYSTEMTAP
327
  NODE_HTTP_CLIENT_RESPONSE(conn.fd, conn.remote, conn.port, conn.buffered);
328
#else
277 329
  NODE_HTTP_CLIENT_RESPONSE(&conn);
330
#endif
278 331

  
279 332
  return Undefined();
280 333
}
281 334

  
282
#define NODE_PROBE(name) #name, name
335
#define NODE_PROBE(name) #name, name, Persistent<FunctionTemplate>()
283 336

  
284 337
static int dtrace_gc_start(GCType type, GCCallbackFlags flags) {
338
#ifdef HAVE_SYSTEMTAP
339
  NODE_GC_START();
340
#else
285 341
  NODE_GC_START(type, flags);
342
#endif
286 343
  /*
287 344
   * We avoid the tail-call elimination of the USDT probe (which screws up
288 345
   * args) by forcing a return of 0.
......
291 348
}
292 349

  
293 350
static int dtrace_gc_done(GCType type, GCCallbackFlags flags) {
351
#ifdef HAVE_SYSTEMTAP
352
  NODE_GC_DONE();
353
#else
294 354
  NODE_GC_DONE(type, flags);
355
#endif
295 356
  return 0;
296 357
}
297 358

  
......
308 369
    { NODE_PROBE(DTRACE_HTTP_SERVER_REQUEST) },
309 370
    { NODE_PROBE(DTRACE_HTTP_SERVER_RESPONSE) },
310 371
    { NODE_PROBE(DTRACE_HTTP_CLIENT_REQUEST) },
311
    { NODE_PROBE(DTRACE_HTTP_CLIENT_RESPONSE) },
312
    { NULL }
372
    { NODE_PROBE(DTRACE_HTTP_CLIENT_RESPONSE) }
313 373
  };
314 374

  
315
  for (int i = 0; tab[i].name != NULL; i++) {
375
  for (unsigned int i = 0; i < ARRAY_SIZE(tab); i++) {
316 376
    tab[i].templ = Persistent<FunctionTemplate>::New(
317 377
        FunctionTemplate::New(tab[i].func));
318 378
    target->Set(String::NewSymbol(tab[i].name), tab[i].templ->GetFunction());
......
322 382
  init_etw();
323 383
#endif
324 384

  
325
#if defined HAVE_DTRACE || defined HAVE_ETW
385
#if defined HAVE_DTRACE || defined HAVE_ETW || defined HAVE_SYSTEMTAP
326 386
  v8::V8::AddGCPrologueCallback((GCPrologueCallback)dtrace_gc_start);
327 387
  v8::V8::AddGCEpilogueCallback((GCEpilogueCallback)dtrace_gc_done);
328 388
#endif

Also available in: Unified diff