Module: PryExceptionExplorer::ShimBuilder
- Defined in:
- lib/pry-exception_explorer/shim_builder.rb
Constant Summary collapse
- Dyname =
"so"
- 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
Class Attribute Summary collapse
-
.dir ⇒ Object
readonly
Returns the value of attribute dir.
-
.file ⇒ Object
readonly
Returns the value of attribute file.
Class Method Summary collapse
Class Attribute Details
.dir ⇒ Object (readonly)
Returns the value of attribute dir.
9 10 11 |
# File 'lib/pry-exception_explorer/shim_builder.rb', line 9 def dir @dir end |
.file ⇒ Object (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
.compile ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/pry-exception_explorer/shim_builder.rb', line 55 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 |