ruby-dtrace-consumer 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. data/LICENCE +20 -0
  2. data/README.md +51 -0
  3. data/ext/Makefile +187 -0
  4. data/ext/dtrace_aggdata.c +132 -0
  5. data/ext/dtrace_aggdata.c~ +141 -0
  6. data/ext/dtrace_aggdata.o +0 -0
  7. data/ext/dtrace_api.bundle +0 -0
  8. data/ext/dtrace_api.c +102 -0
  9. data/ext/dtrace_api.c~ +113 -0
  10. data/ext/dtrace_api.h +138 -0
  11. data/ext/dtrace_api.h~ +155 -0
  12. data/ext/dtrace_api.o +0 -0
  13. data/ext/dtrace_bufdata.c +130 -0
  14. data/ext/dtrace_bufdata.c~ +139 -0
  15. data/ext/dtrace_bufdata.o +0 -0
  16. data/ext/dtrace_dropdata.c +121 -0
  17. data/ext/dtrace_dropdata.c~ +131 -0
  18. data/ext/dtrace_dropdata.o +0 -0
  19. data/ext/dtrace_errdata.c +100 -0
  20. data/ext/dtrace_errdata.c~ +110 -0
  21. data/ext/dtrace_errdata.o +0 -0
  22. data/ext/dtrace_hdl.c +677 -0
  23. data/ext/dtrace_hdl.c~ +689 -0
  24. data/ext/dtrace_hdl.o +0 -0
  25. data/ext/dtrace_probedata.c +273 -0
  26. data/ext/dtrace_probedata.c~ +283 -0
  27. data/ext/dtrace_probedata.o +0 -0
  28. data/ext/dtrace_probedesc.c +93 -0
  29. data/ext/dtrace_probedesc.c~ +78 -0
  30. data/ext/dtrace_probedesc.o +0 -0
  31. data/ext/dtrace_process.c +44 -0
  32. data/ext/dtrace_process.c~ +56 -0
  33. data/ext/dtrace_process.o +0 -0
  34. data/ext/dtrace_program.c +52 -0
  35. data/ext/dtrace_program.c~ +62 -0
  36. data/ext/dtrace_program.o +0 -0
  37. data/ext/dtrace_programinfo.c +70 -0
  38. data/ext/dtrace_programinfo.c~ +60 -0
  39. data/ext/dtrace_programinfo.o +0 -0
  40. data/ext/dtrace_recdesc.c +37 -0
  41. data/ext/dtrace_recdesc.c~ +46 -0
  42. data/ext/dtrace_recdesc.o +0 -0
  43. data/ext/dtrace_util.c +92 -0
  44. data/ext/dtrace_util.o +0 -0
  45. data/ext/extconf.rb +7 -0
  46. data/lib/dtrace.rb +95 -0
  47. data/lib/dtrace/aggregate.rb +40 -0
  48. data/lib/dtrace/aggregateset.rb +19 -0
  49. data/lib/dtrace/consumer.rb +174 -0
  50. data/lib/dtrace/data.rb +85 -0
  51. data/lib/dtrace/dof.rb +8 -0
  52. data/lib/dtrace/printfrecord.rb +10 -0
  53. data/lib/dtrace/probedata.rb +23 -0
  54. data/lib/dtrace/probedesc.rb +15 -0
  55. data/lib/dtrace/record.rb +11 -0
  56. data/lib/dtrace/stackrecord.rb +31 -0
  57. data/lib/dtrace/tracer.rb +35 -0
  58. data/lib/dtrace/version.rb +8 -0
  59. data/lib/dtrace/version.rb~ +8 -0
  60. data/lib/dtraceconsumer.rb +9 -0
  61. data/test/test_aggregates.rb +45 -0
  62. data/test/test_drops_errors.rb +166 -0
  63. data/test/test_dtrace.rb +155 -0
  64. data/test/test_gc.rb +11 -0
  65. data/test/test_helper.rb +20 -0
  66. data/test/test_helper.rb~ +16 -0
  67. data/test/test_legacy_consumer.rb +47 -0
  68. data/test/test_probedata.rb +30 -0
  69. data/test/test_processes.rb +66 -0
  70. data/test/test_profile.rb +198 -0
  71. data/test/test_repeat.rb +50 -0
  72. data/test/test_rubyprobe.rb +52 -0
  73. data/test/test_rubyprobe.rb~ +52 -0
  74. data/test/test_typefilter.rb +94 -0
  75. metadata +121 -0
Binary file
Binary file
@@ -0,0 +1,102 @@
1
+ /* Ruby-DTrace
2
+ * (c) 2007 Chris Andrews <chris@nodnol.org>
3
+ */
4
+
5
+ #include "dtrace_api.h"
6
+
7
+ VALUE cDTrace;
8
+ VALUE cDTraceProbeDesc;
9
+ VALUE cDTraceProgram;
10
+ VALUE cDTraceProgramInfo;
11
+ VALUE cDTraceAggData;
12
+ VALUE cDTraceRecDesc;
13
+ VALUE cDTraceProbeData;
14
+ VALUE cDTraceBufData;
15
+ VALUE cDTraceProcess;
16
+ VALUE cDTraceDropData;
17
+ VALUE cDTraceErrData;
18
+ VALUE cDTraceProbe;
19
+
20
+ VALUE eDTraceException;
21
+
22
+ void Init_dtrace_api() {
23
+
24
+ cDTrace = rb_define_class("DTrace", rb_cObject);
25
+ rb_define_method(cDTrace, "close", dtrace_hdl_close, 0);
26
+ rb_define_method(cDTrace, "each_probe_all", dtrace_each_probe_all, 0);
27
+ rb_define_method(cDTrace, "each_probe_match", dtrace_each_probe_match, 4);
28
+ rb_define_method(cDTrace, "each_probe_prog", dtrace_each_probe_prog, 1);
29
+ rb_define_method(cDTrace, "compile", dtrace_strcompile, -1);
30
+ rb_define_method(cDTrace, "stop", dtrace_hdl_stop, 0);
31
+ rb_define_method(cDTrace, "status", dtrace_hdl_status, 0);
32
+ rb_define_method(cDTrace, "go", dtrace_hdl_go, 0);
33
+ rb_define_method(cDTrace, "error", dtrace_hdl_error, 0);
34
+ rb_define_method(cDTrace, "setopt", dtrace_hdl_setopt, 2);
35
+ rb_define_method(cDTrace, "sleep", dtrace_hdl_sleep, 0);
36
+ rb_define_method(cDTrace, "work", dtrace_hdl_work, -1);
37
+ rb_define_method(cDTrace, "buf_consumer", dtrace_hdl_buf_consumer, 1);
38
+ rb_define_method(cDTrace, "drop_consumer", dtrace_hdl_drop_consumer, 1);
39
+ rb_define_method(cDTrace, "err_consumer", dtrace_hdl_err_consumer, 1);
40
+ rb_define_method(cDTrace, "createprocess", dtrace_hdl_createprocess, 1);
41
+ rb_define_method(cDTrace, "grabprocess", dtrace_hdl_grabprocess, 1);
42
+ rb_define_alloc_func(cDTrace, dtrace_hdl_alloc);
43
+
44
+ cDTraceProcess = rb_define_class_under(cDTrace, "Process", rb_cObject);
45
+ rb_define_method(cDTraceProcess, "release", dtrace_process_release, 0);
46
+ rb_define_method(cDTraceProcess, "continue", dtrace_process_continue, 0);
47
+
48
+ cDTraceProbeDesc = rb_define_class_under(cDTrace, "ProbeDesc", rb_cObject);
49
+ rb_define_method(cDTraceProbeDesc, "probe_id", dtraceprobedesc_probe_id, 0);
50
+ rb_define_method(cDTraceProbeDesc, "provider", dtraceprobedesc_provider, 0);
51
+ rb_define_method(cDTraceProbeDesc, "mod", dtraceprobedesc_mod, 0);
52
+ rb_define_method(cDTraceProbeDesc, "func", dtraceprobedesc_func, 0);
53
+ rb_define_method(cDTraceProbeDesc, "name", dtraceprobedesc_name, 0);
54
+
55
+ cDTraceProbeData = rb_define_class_under(cDTrace, "ProbeData", rb_cObject);
56
+ rb_define_method(cDTraceProbeData, "epid", dtraceprobedata_epid, 0);
57
+ rb_define_method(cDTraceProbeData, "probe", dtraceprobedata_probe, 0);
58
+ rb_define_method(cDTraceProbeData, "cpu", dtraceprobedata_cpu, 0);
59
+ rb_define_method(cDTraceProbeData, "indent", dtraceprobedata_indent, 0);
60
+ rb_define_method(cDTraceProbeData, "prefix", dtraceprobedata_prefix, 0);
61
+ rb_define_method(cDTraceProbeData, "flow", dtraceprobedata_flow, 0);
62
+ rb_define_method(cDTraceProbeData, "each_record", dtraceprobedata_each_record, 0);
63
+
64
+ cDTraceBufData = rb_define_class_under(cDTrace, "BufData", rb_cObject);
65
+ rb_define_method(cDTraceBufData, "epid", dtracebufdata_epid, 0);
66
+ rb_define_method(cDTraceBufData, "probe", dtracebufdata_probe, 0);
67
+ rb_define_method(cDTraceBufData, "record", dtracebufdata_record, 0);
68
+
69
+ cDTraceProgram = rb_define_class_under(cDTrace, "Program", rb_cObject);
70
+ rb_define_method(cDTraceProgram, "execute", dtraceprogram_exec, 0);
71
+ rb_define_method(cDTraceProgram, "info", dtraceprogram_info, 0);
72
+
73
+ cDTraceProgramInfo = rb_define_class_under(cDTrace, "ProgramInfo", rb_cObject);
74
+ rb_define_method(cDTraceProgramInfo, "aggregates_count", dtraceprograminfo_aggregates_count, 0);
75
+ rb_define_method(cDTraceProgramInfo, "recgens_count", dtraceprograminfo_recgens_count, 0);
76
+ rb_define_method(cDTraceProgramInfo, "matches_count", dtraceprograminfo_matches_count, 0);
77
+ rb_define_method(cDTraceProgramInfo, "speculations_count", dtraceprograminfo_speculations_count, 0);
78
+
79
+ cDTraceAggData = rb_define_class_under(cDTrace, "AggData", rb_cObject);
80
+ rb_define_method(cDTraceAggData, "value", dtraceaggdata_value, 0);
81
+ rb_define_method(cDTraceAggData, "aggtype", dtraceaggdata_aggtype, 0);
82
+
83
+ cDTraceRecDesc = rb_define_class_under(cDTrace, "RecDesc", rb_cObject);
84
+ rb_define_method(cDTraceRecDesc, "action", dtracerecdesc_action, 0);
85
+
86
+ cDTraceDropData = rb_define_class_under(cDTrace, "DropData", rb_cObject);
87
+ rb_define_method(cDTraceDropData, "cpu", dtracedropdata_cpu, 0);
88
+ rb_define_method(cDTraceDropData, "drops", dtracedropdata_drops, 0);
89
+ rb_define_method(cDTraceDropData, "total", dtracedropdata_total, 0);
90
+ rb_define_method(cDTraceDropData, "msg", dtracedropdata_msg, 0);
91
+ rb_define_method(cDTraceDropData, "kind", dtracedropdata_kind, 0);
92
+
93
+ cDTraceErrData = rb_define_class_under(cDTrace, "ErrData", rb_cObject);
94
+ rb_define_method(cDTraceErrData, "cpu", dtraceerrdata_cpu, 0);
95
+ rb_define_method(cDTraceErrData, "action", dtraceerrdata_action, 0);
96
+ rb_define_method(cDTraceErrData, "offset", dtraceerrdata_offset, 0);
97
+ rb_define_method(cDTraceErrData, "fault", dtraceerrdata_fault, 0);
98
+ rb_define_method(cDTraceErrData, "addr", dtraceerrdata_addr, 0);
99
+ rb_define_method(cDTraceErrData, "msg", dtraceerrdata_msg, 0);
100
+
101
+ eDTraceException = rb_define_class_under(cDTrace, "Exception", rb_eStandardError);
102
+ }
@@ -0,0 +1,113 @@
1
+ /* Ruby-DTrace
2
+ * (c) 2007 Chris Andrews <chris@nodnol.org>
3
+ */
4
+
5
+ #include "dtrace_api.h"
6
+
7
+ VALUE cDTrace;
8
+ VALUE cDTraceProbeDesc;
9
+ VALUE cDTraceProgram;
10
+ VALUE cDTraceProgramInfo;
11
+ VALUE cDTraceAggData;
12
+ VALUE cDTraceRecDesc;
13
+ VALUE cDTraceProbeData;
14
+ VALUE cDTraceBufData;
15
+ VALUE cDTraceProcess;
16
+ VALUE cDTraceDropData;
17
+ VALUE cDTraceErrData;
18
+ VALUE cDTraceProbe;
19
+
20
+ VALUE eDTraceException;
21
+
22
+ void Init_dtrace_api() {
23
+
24
+ cDTrace = rb_define_class("DTrace", rb_cObject);
25
+ rb_define_method(cDTrace, "initialize", dtrace_init, 0);
26
+ rb_define_method(cDTrace, "close", dtrace_hdl_close, 0);
27
+ rb_define_method(cDTrace, "each_probe_all", dtrace_each_probe_all, 0);
28
+ rb_define_method(cDTrace, "each_probe_match", dtrace_each_probe_match, 4);
29
+ rb_define_method(cDTrace, "each_probe_prog", dtrace_each_probe_prog, 1);
30
+ rb_define_method(cDTrace, "compile", dtrace_strcompile, -1);
31
+ rb_define_method(cDTrace, "stop", dtrace_hdl_stop, 0);
32
+ rb_define_method(cDTrace, "status", dtrace_hdl_status, 0);
33
+ rb_define_method(cDTrace, "go", dtrace_hdl_go, 0);
34
+ rb_define_method(cDTrace, "error", dtrace_hdl_error, 0);
35
+ rb_define_method(cDTrace, "setopt", dtrace_hdl_setopt, 2);
36
+ rb_define_method(cDTrace, "sleep", dtrace_hdl_sleep, 0);
37
+ rb_define_method(cDTrace, "work", dtrace_hdl_work, -1);
38
+ rb_define_method(cDTrace, "buf_consumer", dtrace_hdl_buf_consumer, 1);
39
+ rb_define_method(cDTrace, "drop_consumer", dtrace_hdl_drop_consumer, 1);
40
+ rb_define_method(cDTrace, "err_consumer", dtrace_hdl_err_consumer, 1);
41
+ rb_define_method(cDTrace, "createprocess", dtrace_hdl_createprocess, 1);
42
+ rb_define_method(cDTrace, "grabprocess", dtrace_hdl_grabprocess, 1);
43
+ rb_define_alloc_func(cDTrace, dtrace_hdl_alloc);
44
+
45
+ cDTraceProcess = rb_define_class_under(cDTrace, "Process", rb_cObject);
46
+ rb_define_method(cDTraceProcess, "initialize", dtrace_process_init, 0);
47
+ rb_define_method(cDTraceProcess, "release", dtrace_process_release, 0);
48
+ rb_define_method(cDTraceProcess, "continue", dtrace_process_continue, 0);
49
+
50
+ cDTraceProbeDesc = rb_define_class_under(cDTrace, "ProbeDesc", rb_cObject);
51
+ rb_define_method(cDTraceProbeDesc, "initialize", dtraceprobedesc_init, 0);
52
+ rb_define_method(cDTraceProbeDesc, "probe_id", dtraceprobedesc_probe_id, 0);
53
+ rb_define_method(cDTraceProbeDesc, "provider", dtraceprobedesc_provider, 0);
54
+ rb_define_method(cDTraceProbeDesc, "mod", dtraceprobedesc_mod, 0);
55
+ rb_define_method(cDTraceProbeDesc, "func", dtraceprobedesc_func, 0);
56
+ rb_define_method(cDTraceProbeDesc, "name", dtraceprobedesc_name, 0);
57
+
58
+ cDTraceProbeData = rb_define_class_under(cDTrace, "ProbeData", rb_cObject);
59
+ rb_define_method(cDTraceProbeData, "initialize", dtraceprobedata_init, 0);
60
+ rb_define_method(cDTraceProbeData, "epid", dtraceprobedata_epid, 0);
61
+ rb_define_method(cDTraceProbeData, "probe", dtraceprobedata_probe, 0);
62
+ rb_define_method(cDTraceProbeData, "cpu", dtraceprobedata_cpu, 0);
63
+ rb_define_method(cDTraceProbeData, "indent", dtraceprobedata_indent, 0);
64
+ rb_define_method(cDTraceProbeData, "prefix", dtraceprobedata_prefix, 0);
65
+ rb_define_method(cDTraceProbeData, "flow", dtraceprobedata_flow, 0);
66
+ rb_define_method(cDTraceProbeData, "each_record", dtraceprobedata_each_record, 0);
67
+
68
+ cDTraceBufData = rb_define_class_under(cDTrace, "BufData", rb_cObject);
69
+ rb_define_method(cDTraceBufData, "initialize", dtracebufdata_init, 0);
70
+ rb_define_method(cDTraceBufData, "epid", dtracebufdata_epid, 0);
71
+ rb_define_method(cDTraceBufData, "probe", dtracebufdata_probe, 0);
72
+ rb_define_method(cDTraceBufData, "record", dtracebufdata_record, 0);
73
+
74
+ cDTraceProgram = rb_define_class_under(cDTrace, "Program", rb_cObject);
75
+ rb_define_method(cDTraceProgram, "initialize", dtraceprogram_init, 0);
76
+ rb_define_method(cDTraceProgram, "execute", dtraceprogram_exec, 0);
77
+ rb_define_method(cDTraceProgram, "info", dtraceprogram_info, 0);
78
+
79
+ cDTraceProgramInfo = rb_define_class_under(cDTrace, "ProgramInfo", rb_cObject);
80
+ rb_define_method(cDTraceProgramInfo, "initialize", dtraceprograminfo_init, 0);
81
+ rb_define_method(cDTraceProgramInfo, "aggregates_count", dtraceprograminfo_aggregates_count, 0);
82
+ rb_define_method(cDTraceProgramInfo, "recgens_count", dtraceprograminfo_recgens_count, 0);
83
+ rb_define_method(cDTraceProgramInfo, "matches_count", dtraceprograminfo_matches_count, 0);
84
+ rb_define_method(cDTraceProgramInfo, "speculations_count", dtraceprograminfo_speculations_count, 0);
85
+
86
+ cDTraceAggData = rb_define_class_under(cDTrace, "AggData", rb_cObject);
87
+ rb_define_method(cDTraceAggData, "initialize", dtraceaggdata_init, 0);
88
+ rb_define_method(cDTraceAggData, "value", dtraceaggdata_value, 0);
89
+ rb_define_method(cDTraceAggData, "aggtype", dtraceaggdata_aggtype, 0);
90
+
91
+ cDTraceRecDesc = rb_define_class_under(cDTrace, "RecDesc", rb_cObject);
92
+ rb_define_method(cDTraceRecDesc, "initialize", dtracerecdesc_init, 0);
93
+ rb_define_method(cDTraceRecDesc, "action", dtracerecdesc_action, 0);
94
+
95
+ cDTraceDropData = rb_define_class_under(cDTrace, "DropData", rb_cObject);
96
+ rb_define_method(cDTraceDropData, "initialize", dtracedropdata_init, 0);
97
+ rb_define_method(cDTraceDropData, "cpu", dtracedropdata_cpu, 0);
98
+ rb_define_method(cDTraceDropData, "drops", dtracedropdata_drops, 0);
99
+ rb_define_method(cDTraceDropData, "total", dtracedropdata_total, 0);
100
+ rb_define_method(cDTraceDropData, "msg", dtracedropdata_msg, 0);
101
+ rb_define_method(cDTraceDropData, "kind", dtracedropdata_kind, 0);
102
+
103
+ cDTraceErrData = rb_define_class_under(cDTrace, "ErrData", rb_cObject);
104
+ rb_define_method(cDTraceErrData, "initialize", dtraceerrdata_init, 0);
105
+ rb_define_method(cDTraceErrData, "cpu", dtraceerrdata_cpu, 0);
106
+ rb_define_method(cDTraceErrData, "action", dtraceerrdata_action, 0);
107
+ rb_define_method(cDTraceErrData, "offset", dtraceerrdata_offset, 0);
108
+ rb_define_method(cDTraceErrData, "fault", dtraceerrdata_fault, 0);
109
+ rb_define_method(cDTraceErrData, "addr", dtraceerrdata_addr, 0);
110
+ rb_define_method(cDTraceErrData, "msg", dtraceerrdata_msg, 0);
111
+
112
+ eDTraceException = rb_define_class_under(cDTrace, "Exception", rb_eStandardError);
113
+ }
@@ -0,0 +1,138 @@
1
+ /* Ruby-DTrace
2
+ * (c) 2007 Chris Andrews <chris@nodnol.org>
3
+ */
4
+
5
+ /* this is a full path because the ruby-dtrace probes add a "dtrace.h"
6
+ * in the same directory as ruby.h, and we must avoid loading that...
7
+ */
8
+ #include "/usr/include/dtrace.h"
9
+
10
+ /* undefine _FILE_OFFSET_BITS: we want the definition from ruby. */
11
+ #undef _FILE_OFFSET_BITS
12
+
13
+ #include "ruby.h"
14
+
15
+ /* Used to pass three Ruby VALUEs as the void *arg of dtrace_work() to
16
+ its callbacks: the dtrace handle, a Proc for the probe callback,
17
+ and a Proc for the recdesc callback. */
18
+ typedef struct dtrace_work_handlers {
19
+ VALUE handle;
20
+ VALUE probe;
21
+ VALUE rec;
22
+ } dtrace_work_handlers_t;
23
+
24
+ /* Used to wrap up the DTrace handle, so we can keep references to the
25
+ various callbacks: we must mark them from the dtrace_hdl_mark
26
+ routine, which only gets a pointer to this structure. */
27
+ typedef struct dtrace_handle {
28
+ dtrace_hdl_t *hdl;
29
+ VALUE probe;
30
+ VALUE rec;
31
+ VALUE buf;
32
+ VALUE err;
33
+ VALUE drop;
34
+ VALUE procs;
35
+ } dtrace_handle_t;
36
+
37
+ /* Used to keep a reference to a struct ps_prochandle and a reference
38
+ to the DTrace handle in a DTraceProcess object: we need to be able
39
+ to call dtrace_proc_release() when the DTraceProcess goes away, and
40
+ that requires the DTrace handle. */
41
+ typedef struct dtrace_process {
42
+ dtrace_handle_t *handle;
43
+ struct ps_prochandle *proc;
44
+ } dtrace_process_t;
45
+
46
+ /* Struct wrapping a probe, a handcrafted function created to be a
47
+ probe trigger point, and its corresponding is_enabled tracepoint.
48
+
49
+ This is actually a pointer to the is_enabled function (the probe
50
+ function is after) so it's declared to take no args, and return
51
+ int. */
52
+ typedef struct dtrace_probe {
53
+ int (*func)();
54
+ } dtrace_probe_t;
55
+
56
+ /* Handle missing RARRAY_LEN etc */
57
+ #ifdef RARRAY_LEN
58
+ static inline long rb_str_len(VALUE s) {return RSTRING_LEN(s);}
59
+ static inline char *rb_str_ptr(VALUE s) {return RSTRING_PTR(s);}
60
+ static inline long rb_ary_len(VALUE s) {return RARRAY_LEN(s);}
61
+ static inline VALUE *rb_ary_ptr(VALUE s) {return RARRAY_PTR(s);}
62
+ #else
63
+ static inline long rb_str_len(VALUE s) {return RSTRING(s)->len;}
64
+ static inline char *rb_str_ptr(VALUE s) {return RSTRING(s)->ptr;}
65
+ static inline long rb_ary_len(VALUE s) {return RARRAY(s)->len;}
66
+ static inline VALUE *rb_ary_ptr(VALUE s) {return RARRAY(s)->ptr;}
67
+ #endif // RARRAY_LEN
68
+
69
+ VALUE handle_bytedata(caddr_t addr, uint32_t nbytes);
70
+
71
+ void dtrace_process_free(dtrace_process_t *process);
72
+ VALUE dtrace_process_release(VALUE self);
73
+ VALUE dtrace_process_continue(VALUE self);
74
+
75
+ VALUE dtraceaggdata_value(VALUE self);
76
+ VALUE dtraceaggdata_aggtype(VALUE self);
77
+
78
+ VALUE dtrace_hdl_alloc(VALUE klass);
79
+ VALUE dtrace_hdl_close(VALUE self);
80
+ VALUE dtrace_each_probe_all(VALUE self);
81
+ VALUE dtrace_each_probe_match(VALUE self, VALUE provider, VALUE mod, VALUE func, VALUE name);
82
+ VALUE dtrace_each_probe_prog(VALUE self, VALUE program);
83
+ VALUE dtrace_strcompile(int argc, VALUE *argv, VALUE self);
84
+ VALUE dtrace_hdl_go(VALUE self);
85
+ VALUE dtrace_hdl_status(VALUE self);
86
+ VALUE dtrace_hdl_setopt(VALUE self, VALUE key, VALUE value);
87
+ VALUE dtrace_hdl_stop(VALUE self);
88
+ VALUE dtrace_hdl_error(VALUE self);
89
+ VALUE dtrace_hdl_sleep(VALUE self);
90
+ VALUE dtrace_hdl_work(int argc, VALUE *argv, VALUE self);
91
+ VALUE dtrace_hdl_buf_consumer(VALUE self, VALUE buf_consumer_proc);
92
+ VALUE dtrace_hdl_drop_consumer(VALUE self, VALUE drop_consumer_proc);
93
+ VALUE dtrace_hdl_err_consumer(VALUE self, VALUE err_consumer_proc);
94
+ VALUE dtrace_hdl_createprocess(VALUE self, VALUE rbargv);
95
+ VALUE dtrace_hdl_grabprocess(VALUE self, VALUE pid);
96
+
97
+ VALUE dtraceprobedesc_init(dtrace_probedesc_t *p);
98
+ VALUE dtraceprobedesc_probe_id(VALUE self);
99
+ VALUE dtraceprobedesc_provider(VALUE self);
100
+ VALUE dtraceprobedesc_mod(VALUE self);
101
+ VALUE dtraceprobedesc_func(VALUE self);
102
+ VALUE dtraceprobedesc_name(VALUE self);
103
+
104
+ VALUE dtraceprobedata_epid(VALUE self);
105
+ VALUE dtraceprobedata_probe(VALUE self);
106
+ VALUE dtraceprobedata_cpu(VALUE self);
107
+ VALUE dtraceprobedata_indent(VALUE self);
108
+ VALUE dtraceprobedata_prefix(VALUE self);
109
+ VALUE dtraceprobedata_flow(VALUE self);
110
+ VALUE dtraceprobedata_each_record(VALUE self);
111
+
112
+ VALUE dtracebufdata_epid(VALUE self);
113
+ VALUE dtracebufdata_probe(VALUE self);
114
+ VALUE dtracebufdata_record(VALUE self);
115
+
116
+ VALUE dtraceprogram_exec(VALUE self);
117
+ VALUE dtraceprogram_info(VALUE self);
118
+
119
+ VALUE dtraceprograminfo_init(dtrace_proginfo_t *proginfo);
120
+ VALUE dtraceprograminfo_aggregates_count(VALUE self);
121
+ VALUE dtraceprograminfo_recgens_count(VALUE self);
122
+ VALUE dtraceprograminfo_matches_count(VALUE self);
123
+ VALUE dtraceprograminfo_speculations_count(VALUE self);
124
+
125
+ VALUE dtracerecdesc_action(VALUE self);
126
+
127
+ VALUE dtracedropdata_cpu(VALUE self);
128
+ VALUE dtracedropdata_drops(VALUE self);
129
+ VALUE dtracedropdata_total(VALUE self);
130
+ VALUE dtracedropdata_msg(VALUE self);
131
+ VALUE dtracedropdata_kind(VALUE self);
132
+
133
+ VALUE dtraceerrdata_cpu(VALUE self);
134
+ VALUE dtraceerrdata_action(VALUE self);
135
+ VALUE dtraceerrdata_offset(VALUE self);
136
+ VALUE dtraceerrdata_fault(VALUE self);
137
+ VALUE dtraceerrdata_addr(VALUE self);
138
+ VALUE dtraceerrdata_msg(VALUE self);
@@ -0,0 +1,155 @@
1
+ /* Ruby-DTrace
2
+ * (c) 2007 Chris Andrews <chris@nodnol.org>
3
+ */
4
+
5
+ /* this is a full path because the ruby-dtrace probes add a "dtrace.h"
6
+ * in the same directory as ruby.h, and we must avoid loading that...
7
+ */
8
+ #include "/usr/include/dtrace.h"
9
+
10
+ /* undefine _FILE_OFFSET_BITS: we want the definition from ruby. */
11
+ #undef _FILE_OFFSET_BITS
12
+
13
+ #include "ruby.h"
14
+
15
+ /* Used to pass three Ruby VALUEs as the void *arg of dtrace_work() to
16
+ its callbacks: the dtrace handle, a Proc for the probe callback,
17
+ and a Proc for the recdesc callback. */
18
+ typedef struct dtrace_work_handlers {
19
+ VALUE handle;
20
+ VALUE probe;
21
+ VALUE rec;
22
+ } dtrace_work_handlers_t;
23
+
24
+ /* Used to wrap up the DTrace handle, so we can keep references to the
25
+ various callbacks: we must mark them from the dtrace_hdl_mark
26
+ routine, which only gets a pointer to this structure. */
27
+ typedef struct dtrace_handle {
28
+ dtrace_hdl_t *hdl;
29
+ VALUE probe;
30
+ VALUE rec;
31
+ VALUE buf;
32
+ VALUE err;
33
+ VALUE drop;
34
+ VALUE procs;
35
+ } dtrace_handle_t;
36
+
37
+ /* Used to keep a reference to a struct ps_prochandle and a reference
38
+ to the DTrace handle in a DTraceProcess object: we need to be able
39
+ to call dtrace_proc_release() when the DTraceProcess goes away, and
40
+ that requires the DTrace handle. */
41
+ typedef struct dtrace_process {
42
+ dtrace_handle_t *handle;
43
+ struct ps_prochandle *proc;
44
+ } dtrace_process_t;
45
+
46
+ /* Struct wrapping a probe, a handcrafted function created to be a
47
+ probe trigger point, and its corresponding is_enabled tracepoint.
48
+
49
+ This is actually a pointer to the is_enabled function (the probe
50
+ function is after) so it's declared to take no args, and return
51
+ int. */
52
+ typedef struct dtrace_probe {
53
+ int (*func)();
54
+ } dtrace_probe_t;
55
+
56
+ /* Handle missing RARRAY_LEN etc */
57
+ #ifdef RARRAY_LEN
58
+ static inline long rb_str_len(VALUE s) {return RSTRING_LEN(s);}
59
+ static inline char *rb_str_ptr(VALUE s) {return RSTRING_PTR(s);}
60
+ static inline long rb_ary_len(VALUE s) {return RARRAY_LEN(s);}
61
+ static inline VALUE *rb_ary_ptr(VALUE s) {return RARRAY_PTR(s);}
62
+ #else
63
+ static inline long rb_str_len(VALUE s) {return RSTRING(s)->len;}
64
+ static inline char *rb_str_ptr(VALUE s) {return RSTRING(s)->ptr;}
65
+ static inline long rb_ary_len(VALUE s) {return RARRAY(s)->len;}
66
+ static inline VALUE *rb_ary_ptr(VALUE s) {return RARRAY(s)->ptr;}
67
+ #endif // RARRAY_LEN
68
+
69
+ VALUE handle_bytedata(caddr_t addr, uint32_t nbytes);
70
+
71
+ VALUE dtrace_process_init(VALUE self);
72
+ void dtrace_process_free(dtrace_process_t *process);
73
+ VALUE dtrace_process_release(VALUE self);
74
+ VALUE dtrace_process_continue(VALUE self);
75
+
76
+ VALUE dtraceaggdata_init(VALUE self);
77
+ VALUE dtraceaggdata_value(VALUE self);
78
+ VALUE dtraceaggdata_aggtype(VALUE self);
79
+
80
+ VALUE dtrace_init(VALUE self);
81
+ VALUE dtrace_hdl_alloc(VALUE klass);
82
+ VALUE dtrace_hdl_close(VALUE self);
83
+ VALUE dtrace_each_probe_all(VALUE self);
84
+ VALUE dtrace_each_probe_match(VALUE self, VALUE provider, VALUE mod, VALUE func, VALUE name);
85
+ VALUE dtrace_each_probe_prog(VALUE self, VALUE program);
86
+ VALUE dtrace_strcompile(int argc, VALUE *argv, VALUE self);
87
+ VALUE dtrace_hdl_go(VALUE self);
88
+ VALUE dtrace_hdl_status(VALUE self);
89
+ VALUE dtrace_hdl_setopt(VALUE self, VALUE key, VALUE value);
90
+ VALUE dtrace_hdl_stop(VALUE self);
91
+ VALUE dtrace_hdl_error(VALUE self);
92
+ VALUE dtrace_hdl_sleep(VALUE self);
93
+ VALUE dtrace_hdl_work(int argc, VALUE *argv, VALUE self);
94
+ VALUE dtrace_hdl_buf_consumer(VALUE self, VALUE buf_consumer_proc);
95
+ VALUE dtrace_hdl_drop_consumer(VALUE self, VALUE drop_consumer_proc);
96
+ VALUE dtrace_hdl_err_consumer(VALUE self, VALUE err_consumer_proc);
97
+ VALUE dtrace_hdl_createprocess(VALUE self, VALUE rbargv);
98
+ VALUE dtrace_hdl_grabprocess(VALUE self, VALUE pid);
99
+
100
+ VALUE dtraceprobedesc_init(VALUE self);
101
+ VALUE dtraceprobedesc_probe_id(VALUE self);
102
+ VALUE dtraceprobedesc_provider(VALUE self);
103
+ VALUE dtraceprobedesc_mod(VALUE self);
104
+ VALUE dtraceprobedesc_func(VALUE self);
105
+ VALUE dtraceprobedesc_name(VALUE self);
106
+
107
+ VALUE dtraceprobedata_init(VALUE self);
108
+ VALUE dtraceprobedata_epid(VALUE self);
109
+ VALUE dtraceprobedata_probe(VALUE self);
110
+ VALUE dtraceprobedata_cpu(VALUE self);
111
+ VALUE dtraceprobedata_indent(VALUE self);
112
+ VALUE dtraceprobedata_prefix(VALUE self);
113
+ VALUE dtraceprobedata_flow(VALUE self);
114
+ VALUE dtraceprobedata_each_record(VALUE self);
115
+
116
+ VALUE dtracebufdata_init(VALUE self);
117
+ VALUE dtracebufdata_epid(VALUE self);
118
+ VALUE dtracebufdata_probe(VALUE self);
119
+ VALUE dtracebufdata_record(VALUE self);
120
+
121
+ VALUE dtraceprogram_init(VALUE self);
122
+ VALUE dtraceprogram_exec(VALUE self);
123
+ VALUE dtraceprogram_info(VALUE self);
124
+
125
+ VALUE dtraceprograminfo_init(VALUE self);
126
+ VALUE dtraceprograminfo_aggregates_count(VALUE self);
127
+ VALUE dtraceprograminfo_recgens_count(VALUE self);
128
+ VALUE dtraceprograminfo_matches_count(VALUE self);
129
+ VALUE dtraceprograminfo_speculations_count(VALUE self);
130
+
131
+ VALUE dtracerecdesc_init(VALUE self);
132
+ VALUE dtracerecdesc_action(VALUE self);
133
+
134
+ VALUE dtracedropdata_init(VALUE self);
135
+ VALUE dtracedropdata_cpu(VALUE self);
136
+ VALUE dtracedropdata_drops(VALUE self);
137
+ VALUE dtracedropdata_total(VALUE self);
138
+ VALUE dtracedropdata_msg(VALUE self);
139
+ VALUE dtracedropdata_kind(VALUE self);
140
+
141
+ VALUE dtraceerrdata_init(VALUE self);
142
+ VALUE dtraceerrdata_cpu(VALUE self);
143
+ VALUE dtraceerrdata_action(VALUE self);
144
+ VALUE dtraceerrdata_offset(VALUE self);
145
+ VALUE dtraceerrdata_fault(VALUE self);
146
+ VALUE dtraceerrdata_addr(VALUE self);
147
+ VALUE dtraceerrdata_msg(VALUE self);
148
+
149
+ VALUE dtraceprobe_alloc(VALUE klass);
150
+ VALUE dtraceprobe_init(VALUE self, VALUE argc);
151
+ VALUE dtraceprobe_addr(VALUE self);
152
+ VALUE dtraceprobe_fire(int argc, VALUE *argv, VALUE self);
153
+ VALUE dtraceprobe_is_enabled(VALUE self);
154
+ VALUE dtraceprobe_probe_offset(VALUE self, VALUE rfile, VALUE argc);
155
+ VALUE dtraceprobe_is_enabled_offset(VALUE self, VALUE rfile);