debug-inspector-0.0.2/0000755000076400007640000000000012560644314013644 5ustar pravipravidebug-inspector-0.0.2/debug_inspector.gemspec0000644000076400007640000000106712560644314020371 0ustar pravipravi# -*- encoding: utf-8 -*- require File.expand_path('../lib/debug_inspector/version', __FILE__) Gem::Specification.new do |s| s.name = "debug_inspector" s.version = DebugInspector::VERSION s.authors = ["John Mair (banisterfiend)"] s.email = ["jrmair@gmail.com"] s.homepage = "https://github.com/banister/debug_inspector" s.summary = "A Ruby wrapper for the MRI 2.0 debug_inspector API" s.description = s.summary s.files = `git ls-files`.split("\n") s.platform = Gem::Platform::RUBY s.extensions = ["ext/debug_inspector/extconf.rb"] end debug-inspector-0.0.2/README.md0000644000076400007640000000360212560644314015124 0ustar pravipravidebug_inspector =============== (C) John Mair (banisterfiend) 2012 _A Ruby wrapper for the new MRI 2.0 debug\_inspector API_ **This library only works on MRI 2.0. Requiring it on unsupported Rubies will result in a no-op** Usage ----- ```ruby require 'debug_inspector' # binding of nth caller frame (returns a Binding object) RubyVM::DebugInspector.open { |i| i.frame_binding(n) } # iseq of nth caller frame (returns a RubyVM::InstructionSequence object) RubyVM::DebugInspector.open { |i| i.frame_iseq(n) } # class of nth caller frame RubyVM::DebugInspector.open { |i| i.frame_class(n) } # backtrace locations (returns an array of Thread::Backtrace::Location objects) RubyVM::DebugInspector.open { |i| i.backtrace_locations } ``` Contact ------- Problems or questions contact me at [github](http://github.com/banister) License ------- (The MIT License) Copyright (c) 2012 (John Mair) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. debug-inspector-0.0.2/metadata.yml0000644000076400007640000000232212560644314016146 0ustar pravipravi--- !ruby/object:Gem::Specification name: debug_inspector version: !ruby/object:Gem::Version version: 0.0.2 prerelease: platform: ruby authors: - John Mair (banisterfiend) autorequire: bindir: bin cert_chain: [] date: 2013-02-13 00:00:00.000000000 Z dependencies: [] description: A Ruby wrapper for the MRI 2.0 debug_inspector API email: - jrmair@gmail.com executables: [] extensions: - ext/debug_inspector/extconf.rb extra_rdoc_files: [] files: - README.md - Rakefile - debug_inspector.gemspec - ext/debug_inspector/debug_inspector.c - ext/debug_inspector/extconf.rb - lib/debug_inspector.rb - lib/debug_inspector/version.rb homepage: https://github.com/banister/debug_inspector licenses: [] post_install_message: rdoc_options: [] require_paths: - lib required_ruby_version: !ruby/object:Gem::Requirement none: false requirements: - - ! '>=' - !ruby/object:Gem::Version version: '0' required_rubygems_version: !ruby/object:Gem::Requirement none: false requirements: - - ! '>=' - !ruby/object:Gem::Version version: '0' requirements: [] rubyforge_project: rubygems_version: 1.8.23 signing_key: specification_version: 3 summary: A Ruby wrapper for the MRI 2.0 debug_inspector API test_files: [] debug-inspector-0.0.2/lib/0000755000076400007640000000000012560644314014412 5ustar pravipravidebug-inspector-0.0.2/lib/debug_inspector/0000755000076400007640000000000012560644314017566 5ustar pravipravidebug-inspector-0.0.2/lib/debug_inspector/version.rb0000644000076400007640000000005612560644314021601 0ustar pravipravimodule DebugInspector VERSION = "0.0.2" end debug-inspector-0.0.2/lib/debug_inspector.rb0000644000076400007640000000017012560644314020111 0ustar pravipravirequire 'rbconfig' dlext = RbConfig::CONFIG['DLEXT'] begin require "debug_inspector.#{dlext}" rescue LoadError end debug-inspector-0.0.2/Rakefile0000755000076400007640000000331612560644314015317 0ustar pravipravi$:.unshift 'lib' require 'rake/clean' require "debug_inspector/version" dlext = RbConfig::CONFIG['DLEXT'] direc = File.expand_path(File.dirname(__FILE__)) CLOBBER.include("**/*.#{dlext}", "**/*~", "**/*#*", "**/*.log", "**/*.o") CLEAN.include("ext/**/*.#{dlext}", "ext/**/*.log", "ext/**/*.o", "ext/**/*~", "ext/**/*#*", "ext/**/*.obj", "**/*#*", "**/*#*.*", "ext/**/*.def", "ext/**/*.pdb", "**/*_flymake*.*", "**/*_flymake", "**/*.rbc") desc "Show version" task :version do puts "debug_inspector version: #{DebugInspector::VERSION}" end desc "run tests" task :default => [:test] desc "Run tests" task :test do sh "bacon -Itest -rubygems -a -q" end task :pry do puts "loading debug_inspector into pry" sh "pry -r #{direc}/lib/debug_inspector" end desc "build the binaries" task :compile do chdir "#{direc}/ext/debug_inspector/" do sh "ruby extconf.rb" sh "make clean" sh "make" sh "cp *.#{dlext} ../../lib/" end end desc 'cleanup the extensions' task :cleanup do sh "rm -rf lib/debug_inspector.#{dlext}" chdir "#{direc}/ext/debug_inspector/" do sh 'make clean' rescue nil end end desc "(re)install gem" task :reinstall => :gem do sh "gem uninstall debug_inspector" rescue nil sh "gem install -l #{direc}/debug_inspector-#{DebugInspector::VERSION}.gem" end task :install => :reinstall desc "build all platform gems at once" task :gem => [:clean, :rmgems] do sh "gem build #{direc}/debug_inspector.gemspec" end desc "remove all platform gems" task :rmgems do sh "rm #{direc}/*.gem" rescue nil end desc "build and push latest gems" task :pushgems => :gem do chdir(direc) do Dir["*.gem"].each do |gemfile| sh "gem push #{gemfile}" end end end debug-inspector-0.0.2/ext/0000755000076400007640000000000012560644314014444 5ustar pravipravidebug-inspector-0.0.2/ext/debug_inspector/0000755000076400007640000000000012560644314017620 5ustar pravipravidebug-inspector-0.0.2/ext/debug_inspector/debug_inspector.c0000644000076400007640000000636112560644314023146 0ustar pravipravi/********************************************************************** debug_inspector.c $Author: ko1 $ created at: Thu Nov 15 17:34:36 2012 Copyright (C) 1993-2012 Yukihiro Matsumoto **********************************************************************/ #include "ruby/ruby.h" typedef struct rb_debug_inspector_struct rb_debug_inspector_t; typedef VALUE (*rb_debug_inspector_func_t)(const rb_debug_inspector_t *, void *); VALUE rb_debug_inspector_open(rb_debug_inspector_func_t func, void *data); VALUE rb_debug_inspector_frame_binding_get(const rb_debug_inspector_t *dc, int index); VALUE rb_debug_inspector_frame_class_get(const rb_debug_inspector_t *dc, int index); VALUE rb_debug_inspector_frame_iseq_get(const rb_debug_inspector_t *dc, int index); VALUE rb_debug_inspector_backtrace_locations(const rb_debug_inspector_t *dc); static size_t di_size(const void *dummy) { return sizeof(void *); } static const rb_data_type_t di_data_type = { "simple_debugger", {0, 0, di_size,}, }; static const rb_debug_inspector_t * di_get_dc(VALUE self) { const rb_debug_inspector_t *dc; TypedData_Get_Struct(self, const rb_debug_inspector_t, &di_data_type, dc); if (dc == 0) { rb_raise(rb_eArgError, "invalid inspector context"); } return dc; } static VALUE di_backtrace_locations(VALUE self) { const rb_debug_inspector_t *dc = di_get_dc(self); return rb_debug_inspector_backtrace_locations(dc); } static VALUE di_binding(VALUE self, VALUE index) { const rb_debug_inspector_t *dc = di_get_dc(self); return rb_debug_inspector_frame_binding_get(dc, NUM2INT(index)); } static VALUE di_frame_class(VALUE self, VALUE index) { const rb_debug_inspector_t *dc = di_get_dc(self); return rb_debug_inspector_frame_class_get(dc, NUM2INT(index)); } static VALUE di_frame_iseq(VALUE self, VALUE index) { const rb_debug_inspector_t *dc = di_get_dc(self); return rb_debug_inspector_frame_iseq_get(dc, NUM2INT(index)); } static VALUE breakpoint_i(const rb_debug_inspector_t *dc, void *ptr) { VALUE self = (VALUE)ptr; VALUE result; /* should protect */ DATA_PTR(self) = (void *)dc; result = rb_yield(self); return result; } static VALUE di_open_body(VALUE self) { return rb_debug_inspector_open(breakpoint_i, (void *)self); } static VALUE di_open_ensure(VALUE self) { DATA_PTR(self) = 0; return self; } static VALUE di_open_s(VALUE klass) { VALUE self = TypedData_Wrap_Struct(klass, &di_data_type, 0); return rb_ensure(di_open_body, self, di_open_ensure, self); } void Init_debug_inspector(void) { VALUE rb_cRubyVM = rb_const_get(rb_cObject, rb_intern("RubyVM")); VALUE cDebugInspector = rb_define_class_under(rb_cRubyVM, "DebugInspector", rb_cObject); rb_undef_alloc_func(cDebugInspector); rb_define_singleton_method(cDebugInspector, "open", di_open_s, 0); rb_define_method(cDebugInspector, "backtrace_locations", di_backtrace_locations, 0); rb_define_method(cDebugInspector, "frame_binding", di_binding, 1); rb_define_method(cDebugInspector, "frame_class", di_frame_class, 1); rb_define_method(cDebugInspector, "frame_iseq", di_frame_iseq, 1); } debug-inspector-0.0.2/ext/debug_inspector/extconf.rb0000755000076400007640000000050012560644314021611 0ustar pravipravidef fake_makefile File.open(File.join(File.dirname(__FILE__), "Makefile"), "w") {|f| f.puts %[install:\n\techo "Nada."] } end def mri_2? defined?(RUBY_ENGINE) && RUBY_ENGINE == "ruby" && RUBY_VERSION =~ /^2/ end if mri_2? require 'mkmf' create_makefile('debug_inspector') else fake_makefile end