public
Last active

  • Download Gist
gistfile1.diff
Diff
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
diff --git a/Makefile.in b/Makefile.in
index a01faae..ff05dae 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -297,6 +297,10 @@ enc/unicode/name2ctype.h: enc/unicode/name2ctype.kwd
@$(ECHO) preprocessing $<
$(Q) $(CPP) $(XCFLAGS) $(CPPFLAGS) $(COUTFLAG)$@ -E $< > $@
+probes.h:
+ @$(ECHO) translating probes $<
+ dtrace -o $@ -h -s probes.d
+
clean-local::
$(Q)$(RM) ext/extinit.c ext/extinit.$(OBJEXT) ext/ripper/y.output
-$(Q)$(RM) $(pkgconfig_DATA)
diff --git a/array.c b/array.c
index 82ae7ef..5c7cc7e 100644
--- a/array.c
+++ b/array.c
@@ -15,6 +15,7 @@
#include "ruby/util.h"
#include "ruby/st.h"
#include "ruby/encoding.h"
+#include "probes.h"
#include "internal.h"
#ifndef ARRAY_DEBUG
@@ -303,6 +304,10 @@ ary_alloc(VALUE klass)
FL_SET_EMBED((VALUE)ary);
ARY_SET_EMBED_LEN((VALUE)ary, 0);
+ if(RUBY_ARRAY_ALLOC_ENABLED()) {
+ RUBY_ARRAY_ALLOC(rb_sourcefile(), rb_sourceline());
+ }
+
return (VALUE)ary;
}
diff --git a/gc.c b/gc.c
index d5b8dfd..2c0c37f 100644
--- a/gc.c
+++ b/gc.c
@@ -21,6 +21,7 @@
#include "internal.h"
#include "gc.h"
#include "constant.h"
+#include "probes.h"
#include <stdio.h>
#include <setjmp.h>
#include <sys/types.h>
@@ -1167,6 +1168,8 @@ rb_newobj(void)
}
}
+ if(RUBY_OBJECT_ALLOC_ENABLED()) RUBY_OBJECT_ALLOC();
+
obj = (VALUE)freelist;
freelist = freelist->as.free.next;
diff --git a/hash.c b/hash.c
index b49aff8..c40d94d 100644
--- a/hash.c
+++ b/hash.c
@@ -15,6 +15,7 @@
#include "ruby/st.h"
#include "ruby/util.h"
#include "ruby/encoding.h"
+#include "probes.h"
#include <errno.h>
#ifdef __APPLE__
@@ -221,6 +222,9 @@ hash_alloc(VALUE klass)
OBJSETUP(hash, klass, T_HASH);
RHASH_IFNONE(hash) = Qnil;
+ if(RUBY_HASH_ALLOC_ENABLED()) {
+ RUBY_HASH_ALLOC(rb_sourcefile(), rb_sourceline());
+ }
return (VALUE)hash;
}
diff --git a/probes.d b/probes.d
new file mode 100644
index 0000000..0996276
--- /dev/null
+++ b/probes.d
@@ -0,0 +1,7 @@
+provider ruby {
+ probe hash__alloc(const char *, int);
+ probe array__alloc(const char *, int);
+ probe string__alloc(const char *, int);
+ probe function__entry(const char *, const char *, int, const char *, int);
+ probe object__alloc();
+};
diff --git a/string.c b/string.c
index 9a85f81..a42c3c2 100644
--- a/string.c
+++ b/string.c
@@ -15,6 +15,7 @@
#include "ruby/re.h"
#include "ruby/encoding.h"
#include "internal.h"
+#include "probes.h"
#include <assert.h>
#define BEG(no) (regs->beg[(no)])
@@ -377,6 +378,10 @@ str_alloc(VALUE klass)
str->as.heap.len = 0;
str->as.heap.aux.capa = 0;
+ if(RUBY_STRING_ALLOC_ENABLED()) {
+ RUBY_STRING_ALLOC(rb_sourcefile(), rb_sourceline());
+ }
+
return (VALUE)str;
}
diff --git a/vm_eval.c b/vm_eval.c
index 7df7f5f..2fd2b94 100644
--- a/vm_eval.c
+++ b/vm_eval.c
@@ -11,6 +11,8 @@
**********************************************************************/
+#include "probes.h"
+
static inline VALUE method_missing(VALUE obj, ID id, int argc, const VALUE *argv, int call_status);
static inline VALUE rb_vm_set_finish_env(rb_thread_t * th);
static inline VALUE vm_yield_with_cref(rb_thread_t *th, int argc, const VALUE *argv, const NODE *cref);
@@ -224,6 +226,14 @@ static inline VALUE
rb_call0(VALUE recv, ID mid, int argc, const VALUE *argv,
call_type scope, VALUE self)
{
+ if(RUBY_FUNCTION_ENTRY_ENABLED()) {
+ RUBY_FUNCTION_ENTRY(
+ rb_obj_classname(recv),
+ rb_id2name(mid),
+ argc,
+ rb_sourcefile(),
+ rb_sourceline());
+ }
rb_method_entry_t *me = rb_search_method_entry(recv, mid);
rb_thread_t *th = GET_THREAD();
int call_status = rb_method_call_status(th, me, scope, self);

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.