Ruby 2.0.0p247(2013-06-27revision41674)

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

probes_helper.h
Go to the documentation of this file.
1 #ifndef RUBY_PROBES_HELPER_H
2 #define RUBY_PROBES_HELPER_H
3
4 #include "ruby/ruby.h"
5 #include "probes.h"
6
7 VALUE rb_class_path_no_cache(VALUE _klass);
8
9 #define RUBY_DTRACE_HOOK(name, th, klazz, id) \
10 do { \
11 if (RUBY_DTRACE_##name##_ENABLED()) { \
12 VALUE _klass = (klazz); \
13 VALUE _id = (id); \
14 const char * classname; \
15 const char * methodname; \
16 const char * filename; \
17 if (!_klass) { \
18 rb_thread_method_id_and_class((th), &_id, &_klass); \
19 } \
20 if (_klass) { \
21 if (RB_TYPE_P(_klass, T_ICLASS)) { \
22 _klass = RBASIC(_klass)->klass; \
23 } \
24 else if (FL_TEST(_klass, FL_SINGLETON)) { \
25 _klass = rb_iv_get(_klass, "__attached__"); \
26 } \
27 switch (TYPE(_klass)) { \
28 case T_CLASS: \
29 case T_ICLASS: \
30 case T_MODULE: \
31 { \
32 VALUE _name = rb_class_path_no_cache(_klass); \
33 if (!NIL_P(_name)) { \
34 classname = StringValuePtr(_name); \
35 } \
36 else { \
37 classname = "<unknown>"; \
38 } \
39 methodname = rb_id2name(_id); \
40 filename = rb_sourcefile(); \
41 if (classname && methodname && filename) { \
42 RUBY_DTRACE_##name( \
43 classname, \
44 methodname, \
45 filename, \
46 rb_sourceline()); \
47 } \
48 break; \
49 } \
50 } \
51 } \
52 } \
53 } while (0)
54
55 #define RUBY_DTRACE_METHOD_ENTRY_HOOK(th, klass, id) \
56 RUBY_DTRACE_HOOK(METHOD_ENTRY, th, klass, id)
57
58 #define RUBY_DTRACE_METHOD_RETURN_HOOK(th, klass, id) \
59 RUBY_DTRACE_HOOK(METHOD_RETURN, th, klass, id)
60
61 #define RUBY_DTRACE_CMETHOD_ENTRY_HOOK(th, klass, id) \
62 RUBY_DTRACE_HOOK(CMETHOD_ENTRY, th, klass, id)
63
64 #define RUBY_DTRACE_CMETHOD_RETURN_HOOK(th, klass, id) \
65 RUBY_DTRACE_HOOK(CMETHOD_RETURN, th, klass, id)
66
67 #endif /* RUBY_PROBES_HELPER_H */
68