Skip to content

Commit

Permalink
adding function entry and return probes to the right place
Browse files Browse the repository at this point in the history
  • Loading branch information
tenderlove committed May 1, 2012
1 parent f70d92d commit 68e32f3
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 19 deletions.
28 changes: 28 additions & 0 deletions insns.def
Expand Up @@ -875,6 +875,34 @@ trace
{
rb_event_flag_t flag = (rb_event_flag_t)nf;

if (RUBY_FUNCTION_ENTRY_ENABLED()) {
if (flag == RUBY_EVENT_CALL || flag == RUBY_EVENT_C_CALL) {
VALUE klass;
ID called_id;

rb_thread_method_id_and_class(th, &called_id, &klass);

RUBY_FUNCTION_ENTRY(
rb_class2name(klass),
rb_id2name(called_id),
rb_sourcefile(),
rb_sourceline());
}
}
if (RUBY_FUNCTION_RETURN_ENABLED()) {
if (flag == RUBY_EVENT_RETURN || flag == RUBY_EVENT_C_RETURN) {
VALUE klass;
ID called_id;

rb_thread_method_id_and_class(th, &called_id, &klass);

RUBY_FUNCTION_RETURN(
rb_class2name(klass),
rb_id2name(called_id),
rb_sourcefile(),
rb_sourceline());
}
}
EXEC_EVENT_HOOK(th, flag, GET_SELF(), 0, 0 /* TODO: id, klass */);
}

Expand Down
1 change: 1 addition & 0 deletions probes.d
Expand Up @@ -3,6 +3,7 @@ provider ruby {
probe array__alloc(const char *, int);
probe string__alloc(const char *, int);
probe function__entry(const char *, const char *, const char *, int);
probe function__return(const char *, const char *, const char *, int);

probe require__entry(const char *, const char *, int);
probe require__return(const char *);
Expand Down
12 changes: 1 addition & 11 deletions vm_eval.c
Expand Up @@ -46,17 +46,6 @@ vm_call0(rb_thread_t* th, VALUE recv, VALUE id, int argc, const VALUE *argv,
th->passed_block = 0;
}

if(RUBY_FUNCTION_ENTRY_ENABLED()) {
const char * file = rb_sourcefile();
const char * name = rb_id2name(id);

RUBY_FUNCTION_ENTRY(
rb_obj_classname(recv),
name,
file ? file : "",
rb_sourceline());
}

again:
switch (def->type) {
case VM_METHOD_TYPE_ISEQ: {
Expand Down Expand Up @@ -151,6 +140,7 @@ vm_call0(rb_thread_t* th, VALUE recv, VALUE id, int argc, const VALUE *argv,
rb_bug("vm_call0: unsupported method type (%d)", def->type);
val = Qundef;
}

RUBY_VM_CHECK_INTS();
return val;
}
Expand Down
8 changes: 0 additions & 8 deletions vm_insnhelper.c
Expand Up @@ -568,14 +568,6 @@ vm_call_method(rb_thread_t *th, rb_control_frame_t *cfp,

start_method_dispatch:
if (me != 0) {
if(RUBY_FUNCTION_ENTRY_ENABLED()) {
RUBY_FUNCTION_ENTRY(
rb_class2name(me->klass),
rb_id2name(me->called_id),
rb_sourcefile(),
rb_sourceline());
}

if ((me->flag == 0)) {
normal_method_dispatch:
switch (me->def->type) {
Expand Down

0 comments on commit 68e32f3

Please sign in to comment.