From a73894337a830cdd32a913964f3150bc35269975 Mon Sep 17 00:00:00 2001 From: ko1 Date: Thu, 19 Apr 2007 10:37:08 +0000 Subject: * eval.c, node.h, thread.c, yarvcore.[ch], eval_intern.h: support set_trace_func (incomplete. id and klass don't be passed). And support Thread#set_trace_func which hook only specified thread and Thread#add_trace_func which add new trace func instead of replace old one. C level API was modified. See thread.c (logic) and yarvcore.h (data structures). * vm.c, vm_macro.def: add hook points. * compile.c, insns.def: fix "trace" instruction. * iseq.c, vm_macro.h: add compile option "trace_instruction". * test/ruby/test_settracefunc.rb: hook "c-return" of set_trace_func. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12195 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- eval_intern.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'eval_intern.h') diff --git a/eval_intern.h b/eval_intern.h index 33386a0eab..8b2c972631 100644 --- a/eval_intern.h +++ b/eval_intern.h @@ -239,4 +239,30 @@ void rb_thread_terminate_all(void); #define ruby_cbase() th_get_cbase(GET_THREAD()) + +/* tracer */ +static void inline +exec_event_hooks(rb_event_hook_t *hook, rb_event_flag_t flag, VALUE self, ID id, VALUE klass) +{ + while (hook) { + (*hook->func)(flag, hook->data, self, id, klass); + hook = hook->next; + } +} + +#define EXEC_EVENT_HOOK(th, flag, self, id, klass) do { \ + rb_event_flag_t wait_event__ = th->event_flags; \ + if (UNLIKELY(wait_event__)) { \ + VALUE self__ = (self), klass__ = (klass); \ + ID id__ = (id); \ + if (wait_event__ & flag) { \ + exec_event_hooks(th->event_hooks, flag, self__, id__, klass__); \ + } \ + if (wait_event__ & RUBY_EVENT_VM) { \ + exec_event_hooks(th->vm->event_hooks, flag, self__, id__, klass__); \ + } \ + } \ +} while (0) + + #endif /* EVAL_INTERN_H_INCLUDED */ -- cgit v1.2.3