2012-11-18 20:30:10 +04:00
|
|
|
#ifndef RUBY_PROBES_HELPER_H
|
|
|
|
#define RUBY_PROBES_HELPER_H
|
|
|
|
|
|
|
|
#include "ruby/ruby.h"
|
|
|
|
#include "probes.h"
|
|
|
|
|
2012-11-29 00:20:50 +04:00
|
|
|
#define RUBY_DTRACE_METHOD_ENTRY_HOOK(klass, id) \
|
|
|
|
if (RUBY_DTRACE_METHOD_ENTRY_ENABLED()) { \
|
2012-11-18 20:30:10 +04:00
|
|
|
const char * classname = rb_class2name((klass)); \
|
|
|
|
const char * methodname = rb_id2name((id)); \
|
|
|
|
const char * filename = rb_sourcefile(); \
|
|
|
|
if (classname && methodname && filename) { \
|
2012-11-29 00:20:50 +04:00
|
|
|
RUBY_DTRACE_METHOD_ENTRY( \
|
2012-11-18 20:30:10 +04:00
|
|
|
classname, \
|
|
|
|
methodname, \
|
|
|
|
filename, \
|
|
|
|
rb_sourceline()); \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
|
2012-11-29 21:55:54 +04:00
|
|
|
#define RUBY_DTRACE_METHOD_RETURN_HOOK(th, klass, id) \
|
2012-11-29 00:20:50 +04:00
|
|
|
if (RUBY_DTRACE_METHOD_RETURN_ENABLED()) { \
|
2012-11-29 21:55:54 +04:00
|
|
|
VALUE _klass = (klass); \
|
|
|
|
VALUE _id = (id); \
|
|
|
|
const char * classname; \
|
|
|
|
const char * methodname; \
|
|
|
|
const char * filename; \
|
|
|
|
if (!_klass) { \
|
|
|
|
rb_thread_method_id_and_class((th), &_id, &_klass); \
|
|
|
|
} \
|
|
|
|
classname = rb_class2name(_klass); \
|
|
|
|
methodname = rb_id2name(_id); \
|
|
|
|
filename = rb_sourcefile(); \
|
2012-11-18 20:30:10 +04:00
|
|
|
if (classname && methodname && filename) { \
|
2012-11-29 00:20:50 +04:00
|
|
|
RUBY_DTRACE_METHOD_RETURN( \
|
2012-11-18 20:30:10 +04:00
|
|
|
classname, \
|
|
|
|
methodname, \
|
|
|
|
filename, \
|
|
|
|
rb_sourceline()); \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
|
|
|
|
#endif /* RUBY_PROBES_HELPER_H */
|