Permalink
Browse files

Rename native extension to xray_native. DTrace goodies

git-svn-id: svn+ssh://rubyforge.org/var/svn/xray@5 5dde6e04-f255-48cb-b2b1-8039b2f1cec5
  • Loading branch information...
1 parent a4e4b48 commit b588544f5fa9030b4aa2503a07efffb3ed0f7f48 ph7 committed Mar 27, 2008
View
@@ -54,13 +54,13 @@ specification = Gem::Specification.new do |s|
s.author = "Philippe Hanrigou"
s.email = 'xray-developer@rubyforge.org'
s.homepage = "http://xray.rubyforge.com"
- s.rubyforge_project = 'xray'
+ s.rubyforge_project = 'flipper'
s.platform = Gem::Platform::RUBY
s.files = ["ext/xray/xray.c", "ext/xray/extconf.rb"] + FileList['lib/**/*.rb'] + FileList['test/**/*.rb']
s.require_path = "lib"
# s.autorequire = "MenuBuilder"
s.extensions = ["ext/xray/extconf.rb"]
- s.rdoc_options << '--title' << 'XRay' << '--main' << 'README' << '--line-numbers'
+ s.rdoc_options << '--title' << 'Flipper' << '--main' << 'README' << '--line-numbers'
s.has_rdoc = true
s.extra_rdoc_files = ['README']
s.test_file = "test/all_tests.rb"
View
@@ -0,0 +1,149 @@
+
+SHELL = /bin/sh
+
+#### Start of system configuration section. ####
+
+srcdir = .
+topdir = /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin9.0
+hdrdir = $(topdir)
+VPATH = $(srcdir):$(topdir):$(hdrdir)
+prefix = $(DESTDIR)/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr
+exec_prefix = $(prefix)
+sitedir = $(DESTDIR)/Library/Ruby/Site
+rubylibdir = $(libdir)/ruby/$(ruby_version)
+docdir = $(datarootdir)/doc/$(PACKAGE)
+dvidir = $(docdir)
+datarootdir = $(prefix)/share
+archdir = $(rubylibdir)/$(arch)
+sbindir = $(exec_prefix)/sbin
+psdir = $(docdir)
+localedir = $(datarootdir)/locale
+htmldir = $(docdir)
+datadir = $(datarootdir)
+includedir = $(prefix)/include
+infodir = $(DESTDIR)/usr/share/info
+sysconfdir = $(prefix)/etc
+mandir = $(DESTDIR)/usr/share/man
+libdir = $(exec_prefix)/lib
+sharedstatedir = $(prefix)/com
+oldincludedir = $(DESTDIR)/usr/include
+pdfdir = $(docdir)
+sitearchdir = $(sitelibdir)/$(sitearch)
+bindir = $(exec_prefix)/bin
+localstatedir = $(prefix)/var
+sitelibdir = $(sitedir)/$(ruby_version)
+libexecdir = $(exec_prefix)/libexec
+
+CC = gcc
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -l$(RUBY_SO_NAME)
+
+RUBY_EXTCONF_H =
+CFLAGS = -fno-common -arch ppc -arch i386 -Os -pipe -fno-common
+INCFLAGS = -I. -I$(topdir)/../universal-darwin8.0 -I$(topdir) -I$(hdrdir) -I$(srcdir)
+CPPFLAGS =
+CXXFLAGS = $(CFLAGS)
+DLDFLAGS = -L. -arch ppc -arch i386
+LDSHARED = cc -arch ppc -arch i386 -pipe -bundle -undefined dynamic_lookup
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = ruby
+RUBY_SO_NAME = ruby
+arch = universal-darwin9.0
+sitearch = universal-darwin9.0
+ruby_version = 1.8
+ruby = /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
+RUBY = $(ruby)
+RM = rm -f
+MAKEDIRS = mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+
+#### End of system configuration section. ####
+
+preload =
+
+libpath = . $(libdir)
+LIBPATH = -L"." -L"$(libdir)"
+DEFFILE =
+
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+
+extout =
+extout_prefix =
+target_prefix =
+LOCAL_LIBS =
+LIBS = $(LIBRUBYARG_SHARED) -lpthread -ldl -lm
+SRCS = xray_native.c
+OBJS = xray_native.o
+TARGET = xray_native
+DLLIB = $(TARGET).bundle
+EXTSTATIC =
+STATIC_LIB =
+
+RUBYCOMMONDIR = $(sitedir)$(target_prefix)
+RUBYLIBDIR = $(sitelibdir)$(target_prefix)
+RUBYARCHDIR = $(sitearchdir)$(target_prefix)
+
+TARGET_SO = $(DLLIB)
+CLEANLIBS = $(TARGET).bundle $(TARGET).il? $(TARGET).tds $(TARGET).map
+CLEANOBJS = *.o *.a *.s[ol] *.pdb *.exp *.bak
+
+all: $(DLLIB)
+static: $(STATIC_LIB)
+
+clean:
+ @-$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES)
+
+distclean: clean
+ @-$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ @-$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+
+realclean: distclean
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+$(RUBYARCHDIR)/$(DLLIB): $(DLLIB)
+ $(INSTALL_PROG) $(DLLIB) $(RUBYARCHDIR)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+$(RUBYARCHDIR):
+ $(MAKEDIRS) $@
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
+.SUFFIXES: .c .m .cc .cxx .cpp .C .o
+
+.cc.o:
+ $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
+
+.cxx.o:
+ $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
+
+.cpp.o:
+ $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
+
+.C.o:
+ $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
+
+.c.o:
+ $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) -c $<
+
+$(DLLIB): $(OBJS)
+ @-$(RM) $@
+ $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
+
+
+
+$(OBJS): ruby.h defines.h
View
@@ -3,4 +3,4 @@
if PLATFORM["darwin"]
$INCFLAGS = "-I$(topdir)/../universal-darwin8.0 #{$INCFLAGS}" # To get rb_thread_t from node.h
end
-create_makefile("xray")
+create_makefile("xray_native")
View
@@ -1,123 +0,0 @@
-#include "ruby.h"
-#include "node.h"
-#include "env.h"
-
-static int id_push;
-
-
-static VALUE frame_backtrace(struct FRAME *frame, int lev)
-{
- char buf[BUFSIZ];
- VALUE ary;
- NODE *n;
-
- frame = ruby_frame; // Does not seem to work if we start from any other frame :-(
- ary = rb_ary_new();
- if (NULL == frame) { return ary; }
-
- printf("Got frame %d level=%d\n", frame, lev);
- if (frame->last_func == ID_ALLOCATOR) {
- frame = frame->prev;
- }
- if (lev < 0) {
- printf("Level <0 \n");
- ruby_set_current_source();
- printf("Source set. last_func=%d\n", frame->last_func);
- if (frame->last_func) {
- snprintf(buf, BUFSIZ, "%s:%d:in `%s'",
- ruby_sourcefile, ruby_sourceline,
- rb_id2name(frame->last_func));
- } else if (ruby_sourceline == 0) {
- snprintf(buf, BUFSIZ, "%s", ruby_sourcefile);
- } else {
- snprintf(buf, BUFSIZ, "%s:%d", ruby_sourcefile, ruby_sourceline);
- }
- printf("updated buf with %s\n", buf);
- rb_ary_push(ary, rb_str_new2(buf));
- printf("Pushed in ary, lev=%d\n", lev);
- if (lev < -1) return ary;
- } else {
- while (lev-- > 0) {
- frame = frame->prev;
- if (!frame) {
- ary = Qnil;
- break;
- }
- }
- }
-
- printf("Entering for loop frame=%d\n", frame);
- for (; frame && (n = frame->node); frame = frame->prev) {
- if (frame->prev && frame->prev->last_func) {
- if (frame->prev->node == n) {
- if (frame->prev->last_func == frame->last_func) continue;
- }
- snprintf(buf, BUFSIZ, "%s:%d:in `%s'",
- n->nd_file, nd_line(n),
- rb_id2name(frame->prev->last_func));
- } else {
- snprintf(buf, BUFSIZ, "%s:%d", n->nd_file, nd_line(n));
- }
- rb_ary_push(ary, rb_str_new2(buf));
- }
-
- return ary;
-}
-
-static void print_thread_info(rb_thread_t th)
-{
- printf("======================================\n");
- printf("Thread id : %d\n", th);
- printf(" \\_ Status : %d\n", th->status);
- printf(" \\_ Priority : %d\n", th->priority);
- printf(" \\_ Node : %d\n", th->node);
- printf(" \\_ Frame : %d\n", th->frame);
- printf(" \\_ Next : %d\n", th->next);
-
-}
-
-static VALUE xray_backtrace(VALUE self)
-{
- NODE *node;
- struct FRAME *frame;
- VALUE ary;
- rb_thread_t th;
- rb_thread_t th2;
-
- printf("XRay backtrace\n");
- Check_Type(self, T_DATA);
- th = (rb_thread_t) DATA_PTR(self);
-
- print_thread_info(th);
-
- ary = frame_backtrace(th->frame, -1);
-
- return ary;
-}
-
-
-VALUE rb_xray_dump_all_threads()
-{
- NODE *node;
- struct FRAME *frame;
- rb_thread_t th;
- rb_thread_t th2;
- VALUE current_thread;
-
- current_thread = rb_thread_current();
- Check_Type(current_thread, T_DATA);
- th = (rb_thread_t) DATA_PTR(current_thread);
-
- print_thread_info(th);
- for (th2 = th->next; th2 && th2 != th; th2 = th2->next) {
- print_thread_info(th2);
- }
-
- return Qnil;
-}
-
-void Init_xray() {
- rb_define_method(rb_cThread, "xray_backtrace", xray_backtrace, 0);
- rb_define_singleton_method(rb_cThread, "xray_dump_all_threads", rb_xray_dump_all_threads, 0);
-}
-
Oops, something went wrong.

0 comments on commit b588544

Please sign in to comment.