Permalink
Browse files

version 0.2.1, removed rb_raise C shim and LD_PRELOAD kruft

  • Loading branch information...
1 parent 99bce4f commit e830c6ffb0e5d518e29f0e935240a1fd319d102a @banister banister committed Oct 3, 2012
Showing with 2 additions and 105 deletions.
  1. +0 −1 Rakefile
  2. +0 −20 bin/pry-shim
  3. +0 −81 lib/pry-exception_explorer/shim_builder.rb
  4. +1 −1 lib/pry-exception_explorer/version.rb
  5. +1 −2 pry-exception_explorer.gemspec
View
@@ -26,7 +26,6 @@ def apply_spec_defaults(s)
s.add_dependency('pry-stack_explorer', ">=0.4.6")
s.add_development_dependency("bacon","~>1.1.0")
s.add_development_dependency('rake', '~> 0.9')
- s.executables = ['pry-shim']
s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- test/*`.split("\n")
View
@@ -1,20 +0,0 @@
-require 'pry'
-require 'pry-exception_explorer'
-require 'pry-exception_explorer/shim_builder'
-
-binary_name = "lib_overrides.#{PryExceptionExplorer::ShimBuilder::Dyname}"
-
-if !File.exists? File.join PryExceptionExplorer::ShimBuilder.dir, binary_name
- puts "First run, building shim"
- PryExceptionExplorer::ShimBuilder.compile
- puts "Hopefully built...!"
-end
-
-if RUBY_PLATFORM =~ /darwin/
- ENV['DYLD_FORCE_FLAT_NAMESPACE'] = "1"
- ENV['DYLD_INSERT_LIBRARIES'] = File.join PryExceptionExplorer::ShimBuilder.dir, binary_name
-else
- ENV['LD_PRELOAD'] = File.join PryExceptionExplorer::ShimBuilder.dir, binary_name
-end
-
-exec(*ARGV)
@@ -1,81 +0,0 @@
-require 'rbconfig'
-require 'fileutils'
-
-module PryExceptionExplorer
- CompileError = Class.new(StandardError)
-
- module ShimBuilder
- class << self
- attr_reader :dir, :file
- end
-
- @dir = File.expand_path("~/.pry-exception_explorer/#{RUBY_VERSION}")
- @file = File.join(@dir, "raise_shim.c")
-
- if RUBY_PLATFORM =~ /darwin/
- Dyname = "dylib"
- else
- Dyname = "so"
- end
-
- ShimCode = <<-EOF
-#include <stdio.h>
-#include <dlfcn.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <ruby.h>
-
-void
-rb_raise(VALUE exc, const char *fmt, ...)
-{
- va_list args;
- VALUE mesg;
-
- va_start(args, fmt);
- mesg = rb_vsprintf(fmt, args);
- va_end(args);
- rb_funcall(rb_cObject, rb_intern("raise"), 2, exc, mesg);
-}
-
-void
-rb_name_error(ID id, const char *fmt, ...)
-{
- rb_funcall(rb_cObject, rb_intern("raise"), 2, rb_eNameError, rb_str_new2("hooked exception (pry)"));
-}
-
-EOF
-
- def self.create_directory_and_source_file
- FileUtils.mkdir_p(@dir)
- File.open(@file, 'w') do |f|
- f.puts(ShimCode)
- end
- end
-
- def self.compile
- create_directory_and_source_file
-
- # -L
- lib_dir = RbConfig::CONFIG['libdir']
-
- # -I
- arch_include = File.join RbConfig::CONFIG['includedir'], "ruby-1.9.1", RbConfig::CONFIG['arch']
- backward_include = File.join RbConfig::CONFIG['includedir'], "ruby-1.9.1", "ruby/backward"
- ruby191_include = File.join RbConfig::CONFIG['includedir'], "ruby-1.9.1"
-
- if RUBY_PLATFORM =~ /darwin/
- compile_line = "gcc -Wall -L#{lib_dir} -lruby -I#{arch_include} -I#{backward_include} -I#{ruby191_include} -o lib_overrides.dylib -dynamiclib #{@file}"
- else
- compile_line = "gcc -Wall -O2 -fpic -shared -ldl -g -I#{arch_include} -I#{backward_include} -I#{ruby191_include} -o lib_overrides.so #{@file}"
- end
-
- FileUtils.chdir @dir do
- if !system(compile_line)
- raise CompileError, "There was a problem building the shim, aborted!"
- end
- end
-
- end
- end
-end
-
@@ -1,3 +1,3 @@
module PryExceptionExplorer
- VERSION = "0.2.0"
+ VERSION = "0.2.1"
end
@@ -2,14 +2,13 @@
Gem::Specification.new do |s|
s.name = "pry-exception_explorer"
- s.version = "0.2.0"
+ s.version = "0.2.1"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["John Mair (banisterfiend)"]
s.date = "2012-10-04"
s.description = "Enter the context of exceptions"
s.email = "jrmair@gmail.com"
- s.executables = ["pry-shim"]
s.files = [".gemtest", ".gitignore", ".travis.yml", ".yardopts", "CHANGELOG", "Gemfile", "LICENSE", "README.md", "Rakefile", "bin/pry-shim", "examples/example_c_inline.rb", "examples/example_inline.rb", "examples/example_wrap.rb", "lib/pry-exception_explorer.rb", "lib/pry-exception_explorer/cli.rb", "lib/pry-exception_explorer/commands.rb", "lib/pry-exception_explorer/core_ext.rb", "lib/pry-exception_explorer/intercept.rb", "lib/pry-exception_explorer/lazy_frame.rb", "lib/pry-exception_explorer/shim_builder.rb", "lib/pry-exception_explorer/version.rb", "pry-exception_explorer.gemspec", "test/helper.rb", "test/test_exceptions_in_pry.rb", "test/test_inline_exceptions.rb", "test/test_raise.rb", "test/test_wrapped_exceptions.rb"]
s.homepage = "https://github.com/banister/pry-exception_explorer"
s.require_paths = ["lib"]

0 comments on commit e830c6f

Please sign in to comment.