Permalink
Browse files

adding function entry / exit on C_CALL events

  • Loading branch information...
1 parent 62a35ff commit 166533373e8a973bc663b7219ee75962671a4cba @tenderlove committed Dec 2, 2011
Showing with 48 additions and 0 deletions.
  1. +24 −0 vm_eval.c
  2. +24 −0 vm_insnhelper.c
View
@@ -68,6 +68,18 @@ vm_call0(rb_thread_t* th, VALUE recv, VALUE id, int argc, const VALUE *argv,
}
case VM_METHOD_TYPE_NOTIMPLEMENTED:
case VM_METHOD_TYPE_CFUNC: {
+ if (RUBY_FUNCTION_ENTRY_ENABLED()) {
+ const char * classname = rb_class2name(klass);
+ const char * methodname = rb_id2name(id);
+ const char * filename = rb_sourcefile();
+ if (classname && methodname && filename) {
+ RUBY_FUNCTION_ENTRY(
+ classname,
+ methodname,
+ filename,
+ rb_sourceline());
+ }
+ }
EXEC_EVENT_HOOK(th, RUBY_EVENT_C_CALL, recv, id, klass);
{
rb_control_frame_t *reg_cfp = th->cfp;
@@ -83,6 +95,18 @@ vm_call0(rb_thread_t* th, VALUE recv, VALUE id, int argc, const VALUE *argv,
}
vm_pop_frame(th);
}
+ if (RUBY_FUNCTION_RETURN_ENABLED()) {
+ const char * classname = rb_class2name(klass);
+ const char * methodname = rb_id2name(id);
+ const char * filename = rb_sourcefile();
+ if (classname && methodname && filename) {
+ RUBY_FUNCTION_RETURN(
+ classname,
+ methodname,
+ filename,
+ rb_sourceline());
+ }
+ }
EXEC_EVENT_HOOK(th, RUBY_EVENT_C_RETURN, recv, id, klass);
break;
}
View
@@ -445,6 +445,18 @@ vm_call_cfunc(rb_thread_t *th, rb_control_frame_t *reg_cfp,
const rb_method_definition_t *def = me->def;
rb_control_frame_t *cfp;
+ if (RUBY_FUNCTION_ENTRY_ENABLED()) {
+ const char * classname = rb_class2name(me->klass);
+ const char * methodname = rb_id2name(me->called_id);
+ const char * filename = rb_sourcefile();
+ if (classname && methodname && filename) {
+ RUBY_FUNCTION_ENTRY(
+ classname,
+ methodname,
+ filename,
+ rb_sourceline());
+ }
+ }
EXEC_EVENT_HOOK(th, RUBY_EVENT_C_CALL, recv, me->called_id, me->klass);
cfp = vm_push_frame(th, 0, VM_FRAME_MAGIC_CFUNC,
@@ -460,6 +472,18 @@ vm_call_cfunc(rb_thread_t *th, rb_control_frame_t *reg_cfp,
vm_pop_frame(th);
+ if (RUBY_FUNCTION_RETURN_ENABLED()) {
+ const char * classname = rb_class2name(me->klass);
+ const char * methodname = rb_id2name(me->called_id);
+ const char * filename = rb_sourcefile();
+ if (classname && methodname && filename) {
+ RUBY_FUNCTION_RETURN(
+ classname,
+ methodname,
+ filename,
+ rb_sourceline());
+ }
+ }
EXEC_EVENT_HOOK(th, RUBY_EVENT_C_RETURN, recv, me->called_id, me->klass);
return val;

0 comments on commit 1665333

Please sign in to comment.