pry-exception_explorer 0.1.0pre3 → 0.1.1pre1

Sign up to get free protection for your applications and to get access to all the features.
@@ -44,8 +44,8 @@ PryExceptionExplorer::Commands = Pry::CommandSet.new do
44
44
  command "enter-exception", "Enter the context of the last exception" do
45
45
  ex = _pry_.last_exception
46
46
  if ex && ex.exception_call_stack
47
- PryStackExplorer.create_and_push_frame_manager(_pry_.last_exception.exception_call_stack, _pry_)
48
- PryStackExplorer.frame_manager(_pry_).user[:exception] = _pry_.last_exception
47
+ PryStackExplorer.create_and_push_frame_manager(ex.exception_call_stack, _pry_)
48
+ PryStackExplorer.frame_manager(_pry_).user[:exception] = ex
49
49
  PryStackExplorer.frame_manager(_pry_).refresh_frame
50
50
  elsif ex
51
51
  output.puts "Current exception can't be entered! (perhaps a C exception)"
@@ -10,4 +10,24 @@ Pry::CLI.add_options do
10
10
  exit
11
11
  end
12
12
 
13
+ on "c-exceptions", "Experimental hook for C exceptions" do
14
+ require 'pry-exception_explorer/shim_builder'
15
+
16
+ binary_name = "lib_overrides.#{PryExceptionExplorer::ShimBuilder::Dyname}"
17
+
18
+ if !File.exists? File.join PryExceptionExplorer::ShimBuilder.dir, binary_name
19
+ puts "First run, building shim"
20
+ PryExceptionExplorer::ShimBuilder.compile
21
+ puts "Hopefully built...!"
22
+ end
23
+
24
+ if RUBY_PLATFORM =~ /darwin/
25
+ ENV['DYLD_FORCE_FLAT_NAMESPACE'] = "1"
26
+ ENV['DYLD_INSERT_LIBRARIES'] = File.join PryExceptionExplorer::ShimBuilder.dir, binary_name
27
+ else
28
+ ENV['LD_PRELOAD'] = File.join PryExceptionExplorer::ShimBuilder.dir, binary_name
29
+ end
30
+
31
+ exec("pry")
32
+ end
13
33
  end
@@ -0,0 +1,83 @@
1
+ require 'rbconfig'
2
+ require 'fileutils'
3
+
4
+ module PryExceptionExplorer
5
+ module ShimBuilder
6
+ class << self
7
+ attr_reader :dir, :file
8
+ end
9
+
10
+ @dir = File.expand_path('~/.pry-exception_explorer')
11
+ @file = File.join(@dir, "raise_shim.c")
12
+
13
+ if RUBY_PLATFORM =~ /darwin/
14
+ Dyname = "dylib"
15
+ else
16
+ Dyname = "so"
17
+ end
18
+
19
+ ShimCode = <<-EOF
20
+ #include <stdio.h>
21
+ #include <dlfcn.h>
22
+ #include <stdlib.h>
23
+ #include <unistd.h>
24
+ #include <ruby.h>
25
+
26
+ void
27
+ rb_raise(unsigned long exc, const char *fmt, ...)
28
+ {
29
+ static void (*libruby_rb_raise)
30
+ (unsigned long exc, const char *fmt, ...) = NULL;
31
+
32
+ void * handle;
33
+ char * error;
34
+
35
+ if (!libruby_rb_raise) {
36
+ handle = dlopen("#{RbConfig::CONFIG['libdir']}/libruby.#{Dyname}", RTLD_LAZY);
37
+ if (!handle) {
38
+ fputs(dlerror(), stderr);
39
+ exit(1);
40
+ }
41
+ libruby_rb_raise = dlsym(handle, "rb_raise");
42
+ if ((error = dlerror()) != NULL) {
43
+ fprintf(stderr, "%s", error);
44
+ exit(1);
45
+ }
46
+ }
47
+
48
+ rb_funcall(rb_cObject, rb_intern("raise"), 2, exc, rb_str_new2("hooked exception (pry)"));
49
+ }
50
+ EOF
51
+
52
+ def self.create_directory_and_source_file
53
+ FileUtils.mkdir_p(@dir)
54
+ File.open(@file, 'w') do |f|
55
+ f.puts(ShimCode)
56
+ end
57
+ end
58
+
59
+ def self.compile
60
+ create_directory_and_source_file
61
+
62
+ # -L
63
+ lib_dir = RbConfig::CONFIG['libdir']
64
+
65
+ # -I
66
+ arch_include = File.join RbConfig::CONFIG['includedir'], "ruby-1.9.1", RbConfig::CONFIG['arch']
67
+ backward_include = File.join RbConfig::CONFIG['includedir'], "ruby-1.9.1", "ruby/backward"
68
+ ruby191_include = File.join RbConfig::CONFIG['includedir'], "ruby-1.9.1"
69
+
70
+ if RUBY_PLATFORM =~ /darwin/
71
+ compile_line = "gcc -Wall -L#{lib_dir} -lruby -I#{arch_include} -I#{backward_include} -I#{ruby191_include} -o lib_overrides.dylib -dynamiclib #{@file}"
72
+ else
73
+ compile_line = "gcc -Wall -O2 -fpic -shared -ldl -g -I#{arch_include} -I#{backward_include} -I#{ruby191_include} -o lib_overrides.so #{@file}"
74
+ end
75
+
76
+ FileUtils.chdir @dir do
77
+ system(compile_line)
78
+ end
79
+
80
+ end
81
+ end
82
+ end
83
+
@@ -1,3 +1,3 @@
1
1
  module PryExceptionExplorer
2
- VERSION = "0.1.0pre3"
2
+ VERSION = "0.1.1pre1"
3
3
  end
metadata CHANGED
@@ -1,35 +1,40 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: pry-exception_explorer
3
- version: !ruby/object:Gem::Version
4
- version: 0.1.0pre3
3
+ version: !ruby/object:Gem::Version
5
4
  prerelease: 5
5
+ version: 0.1.1pre1
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - John Mair (banisterfiend)
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-12-16 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
12
+
13
+ date: 2011-12-17 00:00:00 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
15
16
  name: pry-stack_explorer
16
- requirement: &70174405621960 !ruby/object:Gem::Requirement
17
+ prerelease: false
18
+ requirement: &id001 !ruby/object:Gem::Requirement
17
19
  none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: '0'
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
22
24
  type: :runtime
23
- prerelease: false
24
- version_requirements: *70174405621960
25
+ version_requirements: *id001
25
26
  description: FIX ME
26
27
  email: jrmair@gmail.com
27
28
  executables: []
29
+
28
30
  extensions: []
31
+
29
32
  extra_rdoc_files: []
30
- files:
33
+
34
+ files:
31
35
  - lib/pry-exception_explorer/cli.rb
32
36
  - lib/pry-exception_explorer/exception_wrap.rb
37
+ - lib/pry-exception_explorer/shim_builder.rb
33
38
  - lib/pry-exception_explorer/version.rb
34
39
  - lib/pry-exception_explorer.rb
35
40
  - test/test.rb
@@ -38,26 +43,30 @@ files:
38
43
  - Rakefile
39
44
  homepage: https://github.com/banister/pry-exception_explorer
40
45
  licenses: []
46
+
41
47
  post_install_message:
42
48
  rdoc_options: []
43
- require_paths:
49
+
50
+ require_paths:
44
51
  - lib
45
- required_ruby_version: !ruby/object:Gem::Requirement
52
+ required_ruby_version: !ruby/object:Gem::Requirement
46
53
  none: false
47
- requirements:
48
- - - ! '>='
49
- - !ruby/object:Gem::Version
50
- version: '0'
51
- required_rubygems_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: "0"
58
+ required_rubygems_version: !ruby/object:Gem::Requirement
52
59
  none: false
53
- requirements:
54
- - - ! '>'
55
- - !ruby/object:Gem::Version
60
+ requirements:
61
+ - - ">"
62
+ - !ruby/object:Gem::Version
56
63
  version: 1.3.1
57
64
  requirements: []
65
+
58
66
  rubyforge_project:
59
- rubygems_version: 1.8.10
67
+ rubygems_version: 1.8.11
60
68
  signing_key:
61
69
  specification_version: 3
62
70
  summary: FIX ME
63
71
  test_files: []
72
+