Permalink
Browse files

SystemTap support

  • Loading branch information...
1 parent 00a2209 commit eacc691db1d4daba0a2903b64a14d12bdfc0ac36 @yugui committed Jan 4, 2012
Showing with 33 additions and 20 deletions.
  1. +16 −12 Makefile.in
  2. +14 −6 configure.in
  3. 0 defs/{dtrace.d → probes.d}
  4. +3 −2 lib/mkmf.rb
View
@@ -173,17 +173,20 @@ miniruby$(EXEEXT):
@-if test -f $@; then $(MV) -f $@ $@.old; $(RM) $@.old; fi
$(ECHO) linking $@
$(Q) $(PURIFY) $(CC) $(LDFLAGS) $(XLDFLAGS) $(MAINLIBS) $(NORMALMAINOBJ) $(MINIOBJS) $(COMMONOBJS) $(DMYEXT) $(MINIDTRACE_OBJ) $(LIBS) $(OUTFLAG)$@
-$(MINIDTRACE_OBJ): $(arch_hdrdir)/ruby/dtrace.d $(NORMALMAINOBJ) $(MINIOBJS) $(COMMONOBJS) $(DMYEXT)
- $(DTRACE) -G -o $@ -s $(arch_hdrdir)/ruby/dtrace.d $(NORMALMAINOBJ) $(MINIOBJS) $(COMMONOBJS) $(DMYEXT)
+$(MINIDTRACE_OBJ): $(arch_hdrdir)/ruby/probes.d $(NORMALMAINOBJ) $(MINIOBJS) $(COMMONOBJS) $(DMYEXT)
+ $(ECHO) generating $@
+ $(Q) $(DTRACE) -G -o $@ -s $(arch_hdrdir)/ruby/probes.d $(NORMALMAINOBJ) $(MINIOBJS) $(COMMONOBJS) $(DMYEXT)
$(PROGRAM):
@$(RM) $@
$(ECHO) linking $@
$(Q) $(PURIFY) $(CC) $(LDFLAGS) $(XLDFLAGS) $(MAINLIBS) $(MAINOBJ) $(EXTOBJS) $(DTRACE_OBJ) $(LIBRUBYARG) $(LIBS) $(OUTFLAG)$@
-$(DTRACE_OBJ): $(arch_hdrdir)/ruby/dtrace.d $(MAINOBJ) $(EXTOBJS)
- $(DTRACE) -G -o $@ -s $(arch_hdrdir)/ruby/dtrace.d $(MAINOBJ) $(EXTOBJS)
-$(GOLFDTRACE_OBJ): $(arch_hdrdir)/ruby/dtrace.d $(GOLFOBJS) $(EXTOBJS)
- $(DTRACE) -G -o $@ -s $(arch_hdrdir)/ruby/dtrace.d $(GOLFOBJS) $(EXTOBJS)
+$(DTRACE_OBJ): $(arch_hdrdir)/ruby/probes.d $(MAINOBJ) $(EXTOBJS)
+ $(ECHO) generating $@
+ $(Q) $(DTRACE) -G -o $@ -s $(arch_hdrdir)/ruby/probes.d $(MAINOBJ) $(EXTOBJS)
+$(GOLFDTRACE_OBJ): $(arch_hdrdir)/ruby/probes.d $(GOLFOBJS) $(EXTOBJS)
+ $(ECHO) generating $@
+ $(Q) $(DTRACE) -G -o $@ -s $(arch_hdrdir)/ruby/probes.d $(GOLFOBJS) $(EXTOBJS)
# We must `rm' the library each time this rule is invoked because "updating" a
# MAB library on Apple/NeXT (see --enable-fat-binary in configure) is not
@@ -205,8 +208,8 @@ $(LIBRUBY_SO):
File.symlink "$(LIBRUBY_SO)", link}' \
$(LIBRUBY_ALIASES) || true
-$(LIBRUBY_DTRACE_OBJ): $(arch_hdrdir)/ruby/dtrace.d $(OBJS) $(DMYEXT)
- $(DTRACE) -G -o $@ -s $(arch_hdrdir)/ruby/dtrace.d $(OBJS) $(DMYEXT)
+$(LIBRUBY_DTRACE_OBJ): $(arch_hdrdir)/ruby/probes.d $(OBJS) $(DMYEXT)
+ $(DTRACE) -G -o $@ -s $(arch_hdrdir)/ruby/probes.d $(OBJS) $(DMYEXT)
fake: $(arch)-fake.rb
$(arch)-fake.rb: config.status $(srcdir)/template/fake.rb.in
@@ -264,19 +267,20 @@ $(srcdir)/configure: $(srcdir)/configure.in
incs: id.h
-$(arch_hdrdir)/ruby/trace_dtrace.h: $(arch_hdrdir)/ruby/dtrace.d
- $(DTRACE) -h -o $@ -s $(arch_hdrdir)/ruby/dtrace.d
+$(arch_hdrdir)/ruby/trace_dtrace.h: $(arch_hdrdir)/ruby/probes.d
+ @$(ECHO) generating $@
+ $(Q) $(DTRACE) -h -o $@ -s $(arch_hdrdir)/ruby/probes.d
# NOTE: dtrace is not used on cross compiling
-$(arch_hdrdir)/ruby/dtrace.d: $(srcdir)/defs/dtrace.d
+$(arch_hdrdir)/ruby/probes.d: $(srcdir)/defs/probes.d
@$(ECHO) generating $@
@echo '#include <limits.h>' > conftest.c
@echo '#define RUBY_TRACE_H' >> conftest.c
@echo '#include "ruby/ruby.h"' >> conftest.c
@echo 'int main(){ printf("%d", SIZEOF_VALUE * CHAR_BIT); return 0; }' >> conftest.c
@$(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) -c $(COUTFLAG)conftest.o conftest.c
$(Q) $(CC) $(LDFLAGS) $(XLDFLAGS) conftest.o $(LIBS) $(OUTFLAG)conftest
- @$(CP) $(srcdir)/defs/dtrace.d dtrace.c
+ @$(CP) $(srcdir)/defs/probes.d dtrace.c
$(Q) $(CPP) $(CPPFLAGS) -DBITSIZE_OF_VALUE=`./conftest` dtrace.c $(CPPOUTFILE)
$(Q) grep -v '^# [0-9]' conftest.i | grep '.' > $@
@$(RM) conftest conftest.[coi] dtrace.c
View
@@ -379,6 +379,7 @@ AC_CHECK_PROG(DOXYGEN, doxygen)
AC_CHECK_PROG(PKG_CONFIG, pkg-config, [], [], [],
[`$as_dir/$ac_word$ac_exec_ext --print-errors --version > /dev/null 2>&1 || continue`])
+# gcc on Mac OS X does not need post-processing, but BSD or Solaris needs.
AC_DEFUN([RUBY_DTRACE_POSTPROCESS],
[AC_CACHE_CHECK(whether $DTRACE needs post processing, rb_cv_prog_dtrace_g,
[
@@ -396,6 +397,7 @@ AC_DEFUN([RUBY_DTRACE_POSTPROCESS],
])
])
+# User space tracing is broken on some versions of FreeBSD.
AC_DEFUN([RUBY_DTRACE_BSD_BROKEN],
[AC_CACHE_CHECK(whether dtrace USDT is broken, rb_cv_dtrace_bsd_broken,
[
@@ -1182,7 +1184,7 @@ AC_CHECK_HEADERS(limits.h sys/file.h sys/ioctl.h sys/syscall.h\
syscall.h pwd.h grp.h a.out.h utime.h direct.h sys/resource.h \
sys/mkdev.h sys/utime.h xti.h netinet/in_systm.h float.h ieeefp.h \
ucontext.h intrinsics.h langinfo.h locale.h sys/sendfile.h time.h \
- net/socket.h sys/socket.h process.h sys/prctl.h)
+ net/socket.h sys/socket.h process.h sys/prctl.h sys/sdt.h)
AC_TYPE_SIZE_T
RUBY_CHECK_SIZEOF(size_t, [int long void*], [], [@%:@include <sys/types.h>])
@@ -2372,7 +2374,7 @@ AS_CASE(["$target_os"],
])
AC_ARG_WITH(tracing-model,
- AS_HELP_STRING([--with-tracing-model=MODEL], [use MODEL for tracing ruby's internal. [[auto]] (none|dtrace|auto)]),
+ AS_HELP_STRING([--with-tracing-model=MODEL], [use MODEL for tracing ruby's internal. [[auto]] (none|dtrace|systemtap|auto)]),
[TRACING_MODEL=$withval], [TRACING_MODEL=auto])
if test "${TRACING_MODEL}" = "auto"; then
@@ -2383,14 +2385,16 @@ if test "${TRACING_MODEL}" = "auto"; then
else
TRACING_MODEL=dtrace
fi
+ elif test x"$SYSTEMTAP" != x; then
+ TRACING_MODEL=systemtap
else
TRACING_MODEL=none
fi
fi
AS_CASE(["${TRACING_MODEL}"],
[none], [ AC_DEFINE(RUBY_TRACING_MODEL, RUBY_TRACING_MODEL_NONE, [none]) ],
- [dtrace], [
+ [dtrace|systemtap], [
if test -z "$DTRACE"; then
AC_MSG_ERROR([dtrace(1) is missing])
elif test "$cross_compiling" = yes; then
@@ -2405,15 +2409,19 @@ AS_CASE(["${TRACING_MODEL}"],
LIBRUBY_DTRACE_OBJ='libruby_dtrace.$(OBJEXT)'
fi
fi
+ AS_CASE(["$target_os"],
+ [linux*], [
+ test x"$ac_cv_header_sys_sdt_h" = xyes || AC_MSG_ERROR([systemtap requires sys/sdt.h])
+ ])
AC_DEFINE(RUBY_TRACING_MODEL, RUBY_TRACING_MODEL_DTRACE, [dtrace])
AC_SUBST(DTRACE_OBJ)
AC_SUBST(MINIDTRACE_OBJ)
AC_SUBST(GOLFDTRACE_OBJ)
AC_SUBST(LIBRUBY_DTRACE_OBJ)
- ]
- [*], [
+ ],
+ [
AC_MSG_ERROR([unknown tracing model: ${TRACING_MODEL}])
- ])
+ ])
AC_SUBST(TRACING_MODEL)
AC_ARG_WITH(soname,
File renamed without changes.
View
@@ -2051,7 +2051,8 @@ def create_makefile(target, srcprefix = nil)
if $dtrace_postprocess
mfile.print "$(DTRACE_OBJ): $(OBJS)\n"
- mfile.print "\t$(DTRACE) -G -o $@ -s $(arch_hdrdir)/ruby/dtrace.d $(OBJS)\n"
+ mfile.print "\t$(ECHO) generating $@\n"
+ mfile.print "\t$(Q) $(DTRACE) -G -o $@ -s $(arch_hdrdir)/ruby/probes.d $(OBJS)\n"
end
fsep = config_string('BUILD_FILE_SEPARATOR') {|s| s unless s == "/"}
@@ -2195,7 +2196,7 @@ def create_makefile(target, srcprefix = nil)
end
headers << $config_h
headers << '$(RUBY_EXTCONF_H)' if $extconf_h
- headers << '$(arch_hdrdir)/ruby/dtrace.d' if $dtrace_postprocess
+ headers << '$(arch_hdrdir)/ruby/probes.d' if $dtrace_postprocess
mfile.print "$(OBJS): ", headers.join(' '), "\n"
end

0 comments on commit eacc691

Please sign in to comment.