Module: PryExceptionExplorer::ShimBuilder
- Defined in:
- lib/pry-exception_explorer/shim_builder.rb
Constant Summary
- Dyname =
"so"- ShimCode =
<<-EOF #include <stdio.h> #include <dlfcn.h> #include <stdlib.h> #include <unistd.h> #include <ruby.h> void rb_raise(unsigned long exc, const char *fmt, ...) { rb_funcall(rb_cObject, rb_intern("raise"), 2, exc, rb_str_new2("hooked exception (pry)")); } 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
Class Attribute Summary (collapse)
-
+ (Object) dir
readonly
Returns the value of attribute dir.
-
+ (Object) file
readonly
Returns the value of attribute file.
Class Method Summary (collapse)
Class Attribute Details
+ (Object) dir (readonly)
Returns the value of attribute dir
9 10 11 |
# File 'lib/pry-exception_explorer/shim_builder.rb', line 9 def dir @dir end |
+ (Object) file (readonly)
Returns the value of attribute file
9 10 11 |
# File 'lib/pry-exception_explorer/shim_builder.rb', line 9 def file @file end |
Class Method Details
+ (Object) compile
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/pry-exception_explorer/shim_builder.rb', line 49 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 |
+ (Object) create_directory_and_source_file
42 43 44 45 46 47 |
# File 'lib/pry-exception_explorer/shim_builder.rb', line 42 def self.create_directory_and_source_file FileUtils.mkdir_p(@dir) File.open(@file, 'w') do |f| f.puts(ShimCode) end end |