summaryrefslogtreecommitdiff
path: root/lib/mkmf.rb
diff options
context:
space:
mode:
authoryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-01-03 15:36:17 +0000
committeryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-01-03 15:36:17 +0000
commit72b199940d8a19d869bb9f0bb6065d15bbb030d7 (patch)
treea10f236e37c0e673ffc68fb8ab547608e34e9ccb /lib/mkmf.rb
parent0e8fae89ab921e1be06ee7285c5e919e386a1b26 (diff)
* 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 'lib/mkmf.rb')
-rw-r--r--lib/mkmf.rb21
1 files changed, 16 insertions, 5 deletions
diff --git a/lib/mkmf.rb b/lib/mkmf.rb
index 895bca0bee..0ad63d61e3 100644
--- a/lib/mkmf.rb
+++ b/lib/mkmf.rb
@@ -69,6 +69,8 @@ $solaris = /solaris/ =~ RUBY_PLATFORM
$universal = /universal/ =~ RUBY_PLATFORM
$dest_prefix_pattern = (File::PATH_SEPARATOR == ';' ? /\A([[:alpha:]]:)?/ : /\A/)
+$dtrace_postprocess = (CONFIG['DTRACE_OBJ'] and /^\s*$/ !~ CONFIG['DTRACE_OBJ'])
+
# :stopdoc:
def config_string(key, config = CONFIG)
@@ -1450,6 +1452,7 @@ VPATH = #{vpath.join(CONFIG['PATH_SEPARATOR'])}
mk << %{
CC = #{CONFIG['CC']}
CXX = #{CONFIG['CXX']}
+DTRACE = #{CONFIG['DTRACE']}
LIBRUBY = #{CONFIG['LIBRUBY']}
LIBRUBY_A = #{CONFIG['LIBRUBY_A']}
LIBRUBYARG_SHARED = #$LIBRUBYARG_SHARED
@@ -1719,6 +1722,7 @@ LOCAL_LIBS = #{$LOCAL_LIBS}
LIBS = #{$LIBRUBYARG} #{$libs} #{$LIBS}
SRCS = #{srcs.collect(&File.method(:basename)).join(' ')}
OBJS = #{$objs.join(" ")}
+DTRACE_OBJ = #{$dtrace_postprocess ? "$(TARGET)_dtrace.#{$OBJEXT}" : ''}
TARGET = #{target}
DLLIB = #{dllib}
EXTSTATIC = #{$static || ""}
@@ -1739,6 +1743,12 @@ static: $(STATIC_LIB)#{$extout ? " install-rb" : ""}
.PHONY: clean clean-so clean-rb
"
mfile.print CLEANINGS
+
+ if $dtrace_postprocess
+ mfile.print "$(DTRACE_OBJ): $(OBJS)\n"
+ mfile.print "\t$(DTRACE) -G -o $@ -s $(arch_hdrdir)/ruby/dtrace.d $(OBJS)\n"
+ end
+
fsep = config_string('BUILD_FILE_SEPARATOR') {|s| s unless s == "/"}
if fsep
sep = ":/=#{fsep}"
@@ -1841,7 +1851,7 @@ site-install-rb: install-rb
mfile.print "$(RUBYARCHDIR)/" if $extout
mfile.print "$(DLLIB): "
mfile.print "$(DEFFILE) " if makedef
- mfile.print "$(OBJS) Makefile\n"
+ mfile.print "$(OBJS) $(DTRACE_OBJ) Makefile\n"
mfile.print "\t@-$(RM) $(@#{sep})\n"
mfile.print "\t@-$(MAKEDIRS) $(@D)\n" if $extout
link_so = LINK_SO.gsub(/^/, "\t")
@@ -1850,8 +1860,8 @@ site-install-rb: install-rb
end
mfile.print link_so, "\n\n"
unless $static.nil?
- mfile.print "$(STATIC_LIB): $(OBJS)\n\t@-$(RM) $(@#{sep})\n\t"
- mfile.print "$(AR) #{config_string('ARFLAGS') || 'cru '}$@ $(OBJS)"
+ mfile.print "$(STATIC_LIB): $(OBJS) $(DTRACE_OBJ)\n\t@-$(RM) $(@#{sep})\n\t"
+ mfile.print "$(AR) #{config_string('ARFLAGS') || 'cru '}$@ $(OBJS) $(DTRACE_OBJ)"
config_string('RANLIB') do |ranlib|
mfile.print "\n\t@-#{ranlib} $(DLLIB) 2> /dev/null || true"
end
@@ -1872,6 +1882,7 @@ site-install-rb: install-rb
end
headers << $config_h
headers << '$(RUBY_EXTCONF_H)' if $extconf_h
+ headers << '$(arch_hdrdir)/ruby/dtrace.d' if $dtrace_postprocess
mfile.print "$(OBJS): ", headers.join(' '), "\n"
end
@@ -2004,9 +2015,9 @@ TRY_LINK = config_string('TRY_LINK') ||
"$(CFLAGS) $(src) $(LIBPATH) $(LDFLAGS) $(ARCH_FLAG) $(LOCAL_LIBS) $(LIBS)"
LINK_SO = config_string('LINK_SO') ||
if CONFIG["DLEXT"] == $OBJEXT
- "ld $(DLDFLAGS) -r -o $@ $(OBJS)\n"
+ "ld $(DLDFLAGS) -r -o $@ $(OBJS) $(DTRACE_OBJ)\n"
else
- "$(LDSHARED) #{OUTFLAG}$@ $(OBJS) " \
+ "$(LDSHARED) #{OUTFLAG}$@ $(OBJS) $(DTRACE_OBJ) " \
"$(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)"
end
LIBPATHFLAG = config_string('LIBPATHFLAG') || ' -L"%s"'