debug_inspector 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0055983985b3e3b9bb36058348588eac38022787
4
+ data.tar.gz: 776758a397d1e33b3345588331ef3bcb8a3e4051
5
+ SHA512:
6
+ metadata.gz: b115b41121a9a3d6220f2aa473014a577318873c99f54d53adab1f3b24a25ccdb8a7afce7629e0b6e462ed79958f1bd3df6a7b932db1564593c61e44a46ff4fd
7
+ data.tar.gz: ab115e7bc09e1bb42987da24f1104ae047a7109916142ab9e855318db5aa007756f03a9c45574974149ee6065010d745e154bfb159ba6b10cec5a166549823c4
@@ -0,0 +1,15 @@
1
+ language: ruby
2
+ sudo: false
3
+ before_install:
4
+ - gem install bundler
5
+ rvm:
6
+ - 2.0.0
7
+ - 2.1.10
8
+ - 2.2.7
9
+ - 2.3.4
10
+ - 2.4.1
11
+ - ruby-head
12
+ matrix:
13
+ allow_failures:
14
+ - rvm: ruby-head
15
+ fast_finish: true
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ gem 'rake'
data/README.md CHANGED
@@ -1,11 +1,15 @@
1
- debug_inspector
1
+ debug_inspector [![Build Status](https://travis-ci.org/banister/debug_inspector.svg?branch=master)](https://travis-ci.org/banister/debug_inspector)
2
2
  ===============
3
3
 
4
- (C) John Mair (banisterfiend) 2012
5
-
6
4
  _A Ruby wrapper for the new MRI 2.0 debug\_inspector API_
7
5
 
8
- **This library only works on MRI 2.0. Requiring it on unsupported Rubies will result in a no-op**
6
+ The `debug_inspector` C extension and API were designed and built by [Koichi Sasada](https://github.com/ko1), this project
7
+ is just a gemification of his work.
8
+
9
+ **NOTES:**
10
+
11
+ * This library makes use of the new debug inspector API in MRI 2.0.0, **do not use this library outside of debugging situations**.
12
+ * Only works on MRI 2.0. Requiring it on unsupported Rubies will result in a no-op
9
13
 
10
14
  Usage
11
15
  -----
@@ -13,17 +17,24 @@ Usage
13
17
  ```ruby
14
18
  require 'debug_inspector'
15
19
 
16
- # binding of nth caller frame (returns a Binding object)
17
- RubyVM::DebugInspector.open { |i| i.frame_binding(n) }
20
+ # Open debug context
21
+ # Passed `dc' is only active in a block
22
+ RubyVM::DebugInspector.open { |dc|
23
+ # backtrace locations (returns an array of Thread::Backtrace::Location objects)
24
+ locs = dc.backtrace_locations
18
25
 
19
- # iseq of nth caller frame (returns a RubyVM::InstructionSequence object)
20
- RubyVM::DebugInspector.open { |i| i.frame_iseq(n) }
26
+ # you can get depth of stack frame with `locs.size'
27
+ locs.size.times do |i|
28
+ # binding of i-th caller frame (returns a Binding object or nil)
29
+ p dc.frame_binding(i)
21
30
 
22
- # class of nth caller frame
23
- RubyVM::DebugInspector.open { |i| i.frame_class(n) }
31
+ # iseq of i-th caller frame (returns a RubyVM::InstructionSequence object or nil)
32
+ p dc.frame_iseq(i)
24
33
 
25
- # backtrace locations (returns an array of Thread::Backtrace::Location objects)
26
- RubyVM::DebugInspector.open { |i| i.backtrace_locations }
34
+ # class of i-th caller frame
35
+ p dc.frame_class(i)
36
+ end
37
+ }
27
38
  ```
28
39
 
29
40
  Contact
@@ -36,7 +47,7 @@ License
36
47
 
37
48
  (The MIT License)
38
49
 
39
- Copyright (c) 2012 (John Mair)
50
+ Copyright (c) 2012-2013 (John Mair)
40
51
 
41
52
  Permission is hereby granted, free of charge, to any person obtaining
42
53
  a copy of this software and associated documentation files (the
data/Rakefile CHANGED
@@ -1,6 +1,7 @@
1
1
  $:.unshift 'lib'
2
2
  require 'rake/clean'
3
3
  require "debug_inspector/version"
4
+ require 'rake/testtask'
4
5
 
5
6
  dlext = RbConfig::CONFIG['DLEXT']
6
7
  direc = File.expand_path(File.dirname(__FILE__))
@@ -8,18 +9,21 @@ CLOBBER.include("**/*.#{dlext}", "**/*~", "**/*#*", "**/*.log", "**/*.o")
8
9
  CLEAN.include("ext/**/*.#{dlext}", "ext/**/*.log", "ext/**/*.o",
9
10
  "ext/**/*~", "ext/**/*#*", "ext/**/*.obj", "**/*#*", "**/*#*.*",
10
11
  "ext/**/*.def", "ext/**/*.pdb", "**/*_flymake*.*", "**/*_flymake", "**/*.rbc")
12
+
13
+ Rake::TestTask.new(:test) do |t|
14
+ t.libs << "test"
15
+ t.test_files = FileList["test/**/*_test.rb"]
16
+ t.warning = true
17
+ t.verbose = true
18
+ end
19
+
11
20
  desc "Show version"
12
21
  task :version do
13
22
  puts "debug_inspector version: #{DebugInspector::VERSION}"
14
23
  end
15
24
 
16
25
  desc "run tests"
17
- task :default => [:test]
18
-
19
- desc "Run tests"
20
- task :test do
21
- sh "bacon -Itest -rubygems -a -q"
22
- end
26
+ task :default => [:compile, :test]
23
27
 
24
28
  task :pry do
25
29
  puts "loading debug_inspector into pry"
@@ -12,4 +12,6 @@ Gem::Specification.new do |s|
12
12
  s.files = `git ls-files`.split("\n")
13
13
  s.platform = Gem::Platform::RUBY
14
14
  s.extensions = ["ext/debug_inspector/extconf.rb"]
15
+ s.license = 'MIT'
16
+ s.add_development_dependency 'minitest', '>= 5'
15
17
  end
@@ -10,15 +10,7 @@
10
10
  **********************************************************************/
11
11
 
12
12
  #include "ruby/ruby.h"
13
-
14
- typedef struct rb_debug_inspector_struct rb_debug_inspector_t;
15
- typedef VALUE (*rb_debug_inspector_func_t)(const rb_debug_inspector_t *, void *);
16
-
17
- VALUE rb_debug_inspector_open(rb_debug_inspector_func_t func, void *data);
18
- VALUE rb_debug_inspector_frame_binding_get(const rb_debug_inspector_t *dc, int index);
19
- VALUE rb_debug_inspector_frame_class_get(const rb_debug_inspector_t *dc, int index);
20
- VALUE rb_debug_inspector_frame_iseq_get(const rb_debug_inspector_t *dc, int index);
21
- VALUE rb_debug_inspector_backtrace_locations(const rb_debug_inspector_t *dc);
13
+ #include "ruby/debug.h"
22
14
 
23
15
  static size_t
24
16
  di_size(const void *dummy)
@@ -37,7 +29,7 @@ di_get_dc(VALUE self)
37
29
  const rb_debug_inspector_t *dc;
38
30
  TypedData_Get_Struct(self, const rb_debug_inspector_t, &di_data_type, dc);
39
31
  if (dc == 0) {
40
- rb_raise(rb_eArgError, "invalid inspector context");
32
+ rb_raise(rb_eArgError, "invalid debug context");
41
33
  }
42
34
  return dc;
43
35
  }
@@ -70,6 +62,13 @@ di_frame_iseq(VALUE self, VALUE index)
70
62
  return rb_debug_inspector_frame_iseq_get(dc, NUM2INT(index));
71
63
  }
72
64
 
65
+ static VALUE
66
+ di_frame_self(VALUE self, VALUE index)
67
+ {
68
+ const rb_debug_inspector_t *dc = di_get_dc(self);
69
+ return rb_debug_inspector_frame_self_get(dc, NUM2INT(index));
70
+ }
71
+
73
72
  static VALUE
74
73
  breakpoint_i(const rb_debug_inspector_t *dc, void *ptr)
75
74
  {
@@ -114,4 +113,5 @@ Init_debug_inspector(void)
114
113
  rb_define_method(cDebugInspector, "frame_binding", di_binding, 1);
115
114
  rb_define_method(cDebugInspector, "frame_class", di_frame_class, 1);
116
115
  rb_define_method(cDebugInspector, "frame_iseq", di_frame_iseq, 1);
116
+ rb_define_method(cDebugInspector, "frame_self", di_frame_self, 1);
117
117
  }
@@ -1,3 +1,3 @@
1
1
  module DebugInspector
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -0,0 +1,7 @@
1
+ require File.dirname(__FILE__) + '/test_helper'
2
+
3
+ class BasicTest < MiniTest::Test
4
+ def test_version
5
+ assert(DebugInspector::VERSION)
6
+ end
7
+ end
@@ -0,0 +1,5 @@
1
+ lib_dir = File.dirname(__FILE__) + '/../lib'
2
+
3
+ require 'minitest/autorun'
4
+ $:.unshift lib_dir unless $:.include?(lib_dir)
5
+ require 'debug_inspector'
metadata CHANGED
@@ -1,16 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: debug_inspector
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
5
- prerelease:
4
+ version: 0.0.3
6
5
  platform: ruby
7
6
  authors:
8
7
  - John Mair (banisterfiend)
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-02-13 00:00:00.000000000 Z
13
- dependencies: []
11
+ date: 2017-05-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: minitest
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '5'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '5'
14
27
  description: A Ruby wrapper for the MRI 2.0 debug_inspector API
15
28
  email:
16
29
  - jrmair@gmail.com
@@ -19,6 +32,8 @@ extensions:
19
32
  - ext/debug_inspector/extconf.rb
20
33
  extra_rdoc_files: []
21
34
  files:
35
+ - ".travis.yml"
36
+ - Gemfile
22
37
  - README.md
23
38
  - Rakefile
24
39
  - debug_inspector.gemspec
@@ -26,28 +41,30 @@ files:
26
41
  - ext/debug_inspector/extconf.rb
27
42
  - lib/debug_inspector.rb
28
43
  - lib/debug_inspector/version.rb
44
+ - test/basic_test.rb
45
+ - test/test_helper.rb
29
46
  homepage: https://github.com/banister/debug_inspector
30
- licenses: []
47
+ licenses:
48
+ - MIT
49
+ metadata: {}
31
50
  post_install_message:
32
51
  rdoc_options: []
33
52
  require_paths:
34
53
  - lib
35
54
  required_ruby_version: !ruby/object:Gem::Requirement
36
- none: false
37
55
  requirements:
38
- - - ! '>='
56
+ - - ">="
39
57
  - !ruby/object:Gem::Version
40
58
  version: '0'
41
59
  required_rubygems_version: !ruby/object:Gem::Requirement
42
- none: false
43
60
  requirements:
44
- - - ! '>='
61
+ - - ">="
45
62
  - !ruby/object:Gem::Version
46
63
  version: '0'
47
64
  requirements: []
48
65
  rubyforge_project:
49
- rubygems_version: 1.8.23
66
+ rubygems_version: 2.5.1
50
67
  signing_key:
51
- specification_version: 3
68
+ specification_version: 4
52
69
  summary: A Ruby wrapper for the MRI 2.0 debug_inspector API
53
70
  test_files: []