diff options
author | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-01-03 15:36:17 +0000 |
---|---|---|
committer | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-01-03 15:36:17 +0000 |
commit | 72b199940d8a19d869bb9f0bb6065d15bbb030d7 (patch) | |
tree | a10f236e37c0e673ffc68fb8ab547608e34e9ccb /thread.c | |
parent | 0e8fae89ab921e1be06ee7285c5e919e386a1b26 (diff) | |
download | ruby-72b199940d8a19d869bb9f0bb6065d15bbb030d7.tar.gz |
* trace.h: new file. wraps tracing mechanisms.
* defs/dtrace.d: new file. defined a dtrace provider "ruby".
* include/ruby/ruby.h (LIKELY): moved from vm.c.
(UNLIKELY): ditto.
(OBJSETUP): probe "object-create".
(RUBY_EVENT_RESCUE): new event.
* vm_exec.c (DEBUG_ENTER_INSN): embeded a probe insn-entry into it.
(DEBUG_END_INSN): insn-return.
* vm.c (LIKELY): moved into ruby.h.
(UNLIKELY): ditto.
(Init_BareVM): embeded a probe "raise" into it.
* variable.c (rb_class2name_without_alloc): new utility function.
* tool/rbinstall.rb (install?(:ext, :arch, :'ext-arch')): installs
dtrace.d if necessary.
* thread_pthread.c (add_signal_thread_list): probe "raise".
(rb_thread_create_timer_thread): ditto.
* thread.c (rb_thread_schedule_rec): probes "thread-enter" and
"thread-leave",
(thread_start_func_2): ditto.
(thread_cleanup_func): probe "thread-term"
* lib/mkmf.rb: supports dtrace postprocessor on making an extension.
* iseq.c (rb_vm_insn_name): new utility function.
(rb_vm_insn_len): ditto.
* insns.def (hook): probes "method-etnry", "method-return", "line",
and "rescue".
* compile.c (iseq_compile_each): adds a trace op for "rescue" probe.
* gc.c (garbage_collect): probes "gc-begin" and "gc-end".
(obj_free): probe "object-free"
(garbage_collect_with_gvl): probe "raise"
(negative_size_allocation_error): ditto.
(rb_memerror): ditto.
* eval.c (rb_rescue2): probe "rescue"
(rb_longjmp): probe "raise"
* ext/probe/probe.c: new extension for application defined probes.
* ext/probe/extconf.rb: ditto.
* configure.in (--with-tracing-model): new option to choose a tracing
mechanism.
(DTRACE): new substitution. name of dtrace(1).
(RUBY_TRACING_MODEL): new substitution.
(DTRACE_OBJ): ditto.
(MINIDTRACE_OBJ): ditto.
(GOLFDTRACE_OBJ): ditto.
(LIBRUBY_DTRACE_OBJ): ditto.
(RUBY_DTRACE_POSTPROCESS): new macro. checks whether the dtrace on
the system needs postprocessing.
(RUBY_DTRACE_BSD_BROKEN): new macro. checks whether the dtrace
supports USDT.
* Makefile.in:
(DTRACE): new variable. name of dtrace(1).
(TRACING_MODEL): new variable. name of the chosen tracing mechanism.
(DTRACE_OBJ): same as the one in configure.in.
(MINIDTRACE_OBJ): ditto.
(GOLFDTRACE_OBJ): ditto.
(LIBRUBY_DTRACE_OBJ): ditto.
(CPPOUTFILE): new substitution. necessary for generating dtrace.d
(trace_none.h): new target for TRACING_MODEL=none
(RUBY_H_INCLUDES): appended a header for tracing.
(distclean-local): also removes preprocessed version of dtrace.d
($(LIBRUBY_A)): needs $(LIBRUBY_DTRACE_OBJ) if dtrace needs
postprocessing.
($(PROGRAM)): ditto.
(golf): ditto.
(miniruby): ditto.
($(arch_hdrdir)/ruby/dtrace.d): new target. preprocessed verson
of defs/dtrace.d. generated if necessary.
($(arch_hdrdir)/ruby/trace_dtrace.h): new target.
definition of probes.
($(LIBRUBY_DTRACE_OBJ)): new target. generated if dtrace needs
postprocessing.
($(DTRACE_OBJ)): ditto.
($(MINIDTRACE_OBJ)): ditto.
($(GOLFDTRACE_OBJ)): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26235 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'thread.c')
-rw-r--r-- | thread.c | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -376,6 +376,8 @@ thread_cleanup_func(void *th_ptr) { rb_thread_t *th = th_ptr; + if (TRACE_THREAD_TERM_ENABLED()) FIRE_THREAD_TERM(th->self, rb_sourcefile(), rb_sourceline()); + /* unlock all locking mutexes */ if (th->keeping_mutexes) { rb_mutex_unlock_all(th->keeping_mutexes, th); @@ -427,10 +429,16 @@ thread_start_func_2(rb_thread_t *th, VALUE *stack_start, VALUE *register_stack_s th->errinfo = Qnil; th->local_lfp = proc->block.lfp; th->local_svar = Qnil; + if (TRACE_THREAD_ENTER_ENABLED()) { + VALUE filename = proc->block.iseq->filename; + int lineno = proc->block.iseq->line_no; + FIRE_THREAD_ENTER(th->self, (TYPE(filename) == T_STRING ? RSTRING_PTR(filename) : 0), lineno); + } th->value = rb_vm_invoke_proc(th, proc, proc->block.self, (int)RARRAY_LEN(args), RARRAY_PTR(args), 0); } else { + if (TRACE_THREAD_ENTER_ENABLED()) FIRE_THREAD_ENTER(th->self, 0, 0); th->value = (*th->first_func)((void *)args); } }); @@ -461,6 +469,7 @@ thread_start_func_2(rb_thread_t *th, VALUE *stack_start, VALUE *register_stack_s th->status = THREAD_KILLED; thread_debug("thread end: %p\n", (void *)th); + if (TRACE_THREAD_LEAVE_ENABLED()) FIRE_THREAD_LEAVE(th->self, 0, 0); main_th = th->vm->main_thread; if (th != main_th) { @@ -533,6 +542,7 @@ thread_create_core(VALUE thval, VALUE args, VALUE (*fn)(ANYARGS)) native_mutex_initialize(&th->interrupt_lock); /* kick thread */ st_insert(th->vm->living_threads, thval, (st_data_t) th->thread_id); + if (TRACE_THREAD_INIT_ENABLED()) FIRE_THREAD_INIT(th->self, rb_sourcefile(), rb_sourceline()); err = native_thread_create(th); if (err) { st_delete_wrap(th->vm->living_threads, th->self); @@ -982,6 +992,7 @@ rb_thread_schedule_rec(int sched_depth) rb_thread_t *th = GET_THREAD(); thread_debug("rb_thread_schedule/switch start\n"); + if (TRACE_THREAD_LEAVE_ENABLED()) FIRE_THREAD_LEAVE(th->self, rb_sourcefile(), rb_sourceline()); RB_GC_SAVE_MACHINE_CONTEXT(th); native_mutex_unlock(&th->vm->global_vm_lock); @@ -992,6 +1003,7 @@ rb_thread_schedule_rec(int sched_depth) rb_thread_set_current(th); thread_debug("rb_thread_schedule/switch done\n"); + if (TRACE_THREAD_ENTER_ENABLED()) FIRE_THREAD_ENTER(th->self, rb_sourcefile(), rb_sourceline()); if (!sched_depth && UNLIKELY(GET_THREAD()->interrupt_flag)) { rb_threadptr_execute_interrupts_rec(GET_THREAD(), sched_depth+1); |