debug_inspector 0.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 0818f4d1a14ebba76cdf967f063526c1caae14f6
4
- data.tar.gz: 5999c5d5a10721d1a824c648d1c9825491c5a1b0
2
+ SHA256:
3
+ metadata.gz: a9c0e6d3b5bd68235adc5212ad47f99333f9522b6c4b823cb783eb94a2d59d90
4
+ data.tar.gz: e90e6a29a0fdaf86d2259a825ec4bd0b1687e572b90cc24d6d6f889dcb225747
5
5
  SHA512:
6
- metadata.gz: c1598e9ae43dd251033b733e15998a5e40f1acd13ea3cdca657a371377dbae8da4739f51423e18d099723efa0e6b587ef0af14cf7a525a75f03235a056045fca
7
- data.tar.gz: b33a0f6ff4a4ea8db69186c7578768e8309138dd84357b9cea49966ac1abd3291e3f65f6ed9816efa03c1325c05fc57be38f13e0196ff5d299e3a927337a5531
6
+ metadata.gz: df09cff61314f0af4f9fe0584e7417b0faa756652f1b6157895aae17cd852125a5b8c0535adfdfcdae8fd78e6e5ad845ac6101841373eba4eb75c29894a0674d
7
+ data.tar.gz: 1f329aeae5a8036e9959bdb43095ffcc92110a83f803f9835554a9b5a6b05253cf704006607d321d2abbe02847cce38f4f1f64c975197c03afa746b99c6e717f
@@ -0,0 +1,112 @@
1
+ name: Test
2
+
3
+ on:
4
+ push:
5
+ branches: [ master ]
6
+ schedule:
7
+ - cron: '0 0 11,25 * *' # roughly every two weeks to run on new Ruby versions
8
+ pull_request:
9
+ branches: [ master ]
10
+ workflow_dispatch:
11
+
12
+ jobs:
13
+ test:
14
+ name: "Unit"
15
+ runs-on: ${{ matrix.os }}
16
+ strategy:
17
+ fail-fast: false
18
+ matrix:
19
+ os:
20
+ - macos-latest
21
+ - ubuntu-latest
22
+ - windows-latest
23
+ ruby:
24
+ - "2.1"
25
+ - "2.2"
26
+ - "2.3"
27
+ - "2.4"
28
+ - "2.5"
29
+ - "2.6"
30
+ - "2.7"
31
+ - "3.0"
32
+
33
+ steps:
34
+
35
+ - uses: actions/checkout@v2
36
+
37
+ - name: Set up Ruby
38
+ uses: ruby/setup-ruby@v1
39
+ with:
40
+ ruby-version: ${{ matrix.ruby }}
41
+ bundler-cache: true
42
+
43
+ - name: Test
44
+ run: bundle exec rake
45
+
46
+ system:
47
+ name: "System"
48
+ runs-on: ${{ matrix.os }}
49
+ strategy:
50
+ fail-fast: false
51
+ matrix:
52
+ os:
53
+ - macos-latest
54
+ - ubuntu-latest
55
+ - windows-latest
56
+ ruby:
57
+ # This includes rubies that are not actually extended by this gem.
58
+ # We want to make sure the gem silently fails to load on those platforms.
59
+ - "2"
60
+ - "3.0"
61
+ - "jruby"
62
+ - "truffleruby"
63
+ exclude:
64
+ # Windows releases of jruby and truffleruby have issues. Skip them for now.
65
+ - { ruby: "jruby", os: "windows-latest" }
66
+ - { ruby: "truffleruby", os: "windows-latest" }
67
+
68
+ steps:
69
+
70
+ - uses: actions/checkout@v2
71
+
72
+ - name: Set up Ruby
73
+ uses: ruby/setup-ruby@v1
74
+ with:
75
+ ruby-version: ${{ matrix.ruby }}
76
+ bundler-cache: true
77
+
78
+ - name: Build gem
79
+ run: bundle exec gem build --verbose debug_inspector.gemspec
80
+
81
+ - name: Install gem
82
+ run: gem install --verbose debug_inspector*.gem
83
+
84
+ - name: Create directory for gem test
85
+ run: mkdir -p tmp/gem-test
86
+
87
+ - name: Create test Gemfile
88
+ run: echo "gem 'debug_inspector'" > Gemfile
89
+ working-directory: ./tmp/gem-test
90
+
91
+ - name: Get gem installation path
92
+ id: gem_path
93
+ run: |
94
+ gem_path=$(bundle show debug_inspector)
95
+ echo "gem_path is ${gem_path}"
96
+ echo "::set-output name=path::${gem_path}"
97
+ shell: bash
98
+ working-directory: ./tmp/gem-test
99
+
100
+ - name: List installed gem contents
101
+ run: find .
102
+ shell: bash
103
+ working-directory: ${{ steps.gem_path.outputs.path }}
104
+
105
+ - name: Test gem load
106
+ run: bundle exec ruby -e "require 'debug_inspector'"
107
+ working-directory: ./tmp/gem-test
108
+
109
+ - name: Test gem functionality
110
+ if: ${{ matrix.ruby != 'jruby' && matrix.ruby != 'truffleruby' }}
111
+ run: bundle exec ruby -e "require 'debug_inspector'; RubyVM::DebugInspector.open { |dc| dc.frame_binding(1) }"
112
+ working-directory: ./tmp/gem-test
data/.gitignore ADDED
@@ -0,0 +1,16 @@
1
+ Gemfile.lock
2
+
3
+ /.bundle/
4
+ /.yardoc
5
+ /_yardoc/
6
+ /coverage/
7
+ /doc/
8
+ /pkg/
9
+ /spec/reports/
10
+ /tmp/
11
+ *.bundle
12
+ *.so
13
+ *.o
14
+ *.a
15
+ mkmf.log
16
+ Makefile
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in debug_inspector.gemspec
4
+ gemspec
5
+
6
+ gem "rake"
7
+ gem "rake-compiler"
8
+ gem "minitest"
data/README.md CHANGED
@@ -1,11 +1,19 @@
1
+ [![Build Status](https://github.com/banister/debug_inspector/workflows/Test/badge.svg?branch=master&event=push)](https://github.com/banister/debug_inspector/actions?query=branch%3Amaster)
2
+ [![Gem Version](https://img.shields.io/gem/v/debug_inspector.svg)](https://rubygems.org/gems/debug_inspector)
3
+
1
4
  debug_inspector
2
5
  ===============
3
6
 
4
- (C) John Mair (banisterfiend) 2012
7
+ _A Ruby wrapper for the MRI 2.0+ debug\_inspector API_
8
+
9
+ The `debug_inspector` C extension and API were designed and built by [Koichi Sasada](https://github.com/ko1), this project
10
+ is just a gemification of his work.
5
11
 
6
- _A Ruby wrapper for the new MRI 2.0 debug\_inspector API_
12
+ **NOTES:**
7
13
 
8
- ** This library only works on MRI 2.0. Requiring it on unsupported Rubies will resort in a no-op **
14
+ * **Do not use this library outside of debugging situations**.
15
+ * This library makes use of the debug inspector API which was new in MRI 2.0.0.
16
+ * Only works on MRI 2 and 3. Requiring it on unsupported Rubies will result in a no-op
9
17
 
10
18
  Usage
11
19
  -----
@@ -13,19 +21,33 @@ Usage
13
21
  ```ruby
14
22
  require 'debug_inspector'
15
23
 
16
- # binding of nth caller frame (returns a Binding object)
17
- RubyVM::DebugInspector.open { |i| i.frame_binding(n) }
24
+ # Open debug context
25
+ # Passed `dc' is only active in a block
26
+ RubyVM::DebugInspector.open { |dc|
27
+ # backtrace locations (returns an array of Thread::Backtrace::Location objects)
28
+ locs = dc.backtrace_locations
18
29
 
19
- # iseq of nth caller frame (returns a RubyVM::InstructionSequence object)
20
- RubyVM::DebugInspector.open { |i| i.frame_iseq(n) }
30
+ # you can get depth of stack frame with `locs.size'
31
+ locs.size.times do |i|
32
+ # binding of i-th caller frame (returns a Binding object or nil)
33
+ p dc.frame_binding(i)
21
34
 
22
- # class of nth caller frame
23
- RubyVM::DebugInspector.open { |i| i.frame_class(n) }
35
+ # iseq of i-th caller frame (returns a RubyVM::InstructionSequence object or nil)
36
+ p dc.frame_iseq(i)
24
37
 
25
- # backtrace locations (returns an array of Thread::Backtrace::Location objects)
26
- RubyVM::DebugInspector.open { |i| i.backtrace_locations }
38
+ # class of i-th caller frame
39
+ p dc.frame_class(i)
40
+ end
41
+ }
27
42
  ```
28
43
 
44
+ Development
45
+ -----------
46
+
47
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
48
+
49
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
50
+
29
51
  Contact
30
52
  -------
31
53
 
@@ -36,7 +58,7 @@ License
36
58
 
37
59
  (The MIT License)
38
60
 
39
- Copyright (c) 2012 (John Mair)
61
+ Copyright (c) 2012-2013 (John Mair)
40
62
 
41
63
  Permission is hereby granted, free of charge, to any person obtaining
42
64
  a copy of this software and associated documentation files (the
data/Rakefile CHANGED
@@ -1,72 +1,27 @@
1
- $:.unshift 'lib'
2
- require 'rake/clean'
3
- require "debug_inspector/version"
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
4
3
 
5
- dlext = RbConfig::CONFIG['DLEXT']
6
- direc = File.expand_path(File.dirname(__FILE__))
7
- CLOBBER.include("**/*.#{dlext}", "**/*~", "**/*#*", "**/*.log", "**/*.o")
8
- CLEAN.include("ext/**/*.#{dlext}", "ext/**/*.log", "ext/**/*.o",
9
- "ext/**/*~", "ext/**/*#*", "ext/**/*.obj", "**/*#*", "**/*#*.*",
10
- "ext/**/*.def", "ext/**/*.pdb", "**/*_flymake*.*", "**/*_flymake", "**/*.rbc")
11
- desc "Show version"
12
- task :version do
13
- puts "debug_inspector version: #{DebugInspector::VERSION}"
14
- end
15
-
16
- 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
23
-
24
- task :pry do
25
- puts "loading debug_inspector into pry"
26
- sh "pry -r #{direc}/lib/debug_inspector"
27
- end
4
+ def can_compile_extensions?
5
+ RUBY_ENGINE == "ruby"
6
+ end
28
7
 
29
- desc "build the binaries"
30
- task :compile do
31
- chdir "#{direc}/ext/debug_inspector/" do
32
- sh "ruby extconf.rb"
33
- sh "make clean"
34
- sh "make"
35
- sh "cp *.#{dlext} ../../lib/"
36
- end
8
+ Rake::TestTask.new(:test) do |t|
9
+ t.libs << "test"
10
+ t.libs << "lib"
11
+ t.test_files = FileList["test/**/*_test.rb"]
12
+ t.warning = true
13
+ t.verbose = true
37
14
  end
38
15
 
39
- desc 'cleanup the extensions'
40
- task :cleanup do
41
- sh "rm -rf lib/debug_inspector.#{dlext}"
42
- chdir "#{direc}/ext/debug_inspector/" do
43
- sh 'make clean' rescue nil
44
- end
45
- end
46
-
47
- desc "(re)install gem"
48
- task :reinstall => :gem do
49
- sh "gem uninstall debug_inspector" rescue nil
50
- sh "gem install -l #{direc}/debug_inspector-#{DebugInspector::VERSION}.gem"
51
- end
52
-
53
- task :install => :reinstall
54
-
55
- desc "build all platform gems at once"
56
- task :gem => [:clean, :rmgems] do
57
- sh "gem build #{direc}/debug_inspector.gemspec"
58
- end
16
+ require "rake/extensiontask"
59
17
 
60
- desc "remove all platform gems"
61
- task :rmgems do
62
- sh "rm #{direc}/*.gem" rescue nil
18
+ if can_compile_extensions?
19
+ task :build => :compile
20
+ task :default => [:clobber, :compile, :test]
21
+ else
22
+ task :default => [:test]
63
23
  end
64
24
 
65
- desc "build and push latest gems"
66
- task :pushgems => :gem do
67
- chdir(direc) do
68
- Dir["*.gem"].each do |gemfile|
69
- sh "gem push #{gemfile}"
70
- end
71
- end
25
+ Rake::ExtensionTask.new("debug_inspector") do |ext|
26
+ ext.lib_dir = "lib"
72
27
  end
@@ -1,15 +1,37 @@
1
- # -*- encoding: utf-8 -*-
2
- require File.expand_path('../lib/debug_inspector/version', __FILE__)
3
-
4
- Gem::Specification.new do |s|
5
- s.name = "debug_inspector"
6
- s.version = DebugInspector::VERSION
7
- s.authors = ["John Mair (banisterfiend)"]
8
- s.email = ["jrmair@gmail.com"]
9
- s.homepage = "https://github.com/banister/debug_inspector"
10
- s.summary = "A Ruby wrapper for the MRI 2.0 debug_inspector API"
11
- s.description = s.summary
12
- s.files = `git ls-files`.split("\n")
13
- s.platform = Gem::Platform::RUBY
14
- s.extensions = ["ext/debug_inspector/extconf.rb"]
1
+ # We don't want to define any constants if the gem extension isn't loaded, so not requiring the version file.
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "debug_inspector"
5
+ spec.version = "1.1.0"
6
+ spec.authors = ["John Mair (banisterfiend)"]
7
+ spec.email = ["jrmair@gmail.com"]
8
+
9
+ spec.summary = %q{A Ruby wrapper for the MRI 2.0 debug_inspector API}
10
+ spec.description = <<-TXT
11
+ Adds methods to RubyVM::DebugInspector to allow for inspection of backtrace frames.
12
+
13
+ The debug_inspector C extension and API were designed and built by Koichi Sasada, this project is just a gemification of his work.
14
+
15
+ This library makes use of the debug inspector API which was added to MRI 2.0.0.
16
+ Only works on MRI 2 and 3. Requiring it on unsupported Rubies will result in a no-op.
17
+
18
+ Recommended for use only in debugging situations. Do not use this in production apps.
19
+ TXT
20
+ spec.homepage = "https://github.com/banister/debug_inspector"
21
+ spec.license = "MIT"
22
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.0")
23
+
24
+ spec.metadata["homepage_uri"] = spec.homepage
25
+ spec.metadata["source_code_uri"] = "https://github.com/banister/debug_inspector"
26
+ spec.metadata["changelog_uri"] = "https://github.com/banister/debug_inspector/releases"
27
+
28
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
29
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|bin)/}) }
30
+ end
31
+
32
+ spec.require_paths = ["lib"]
33
+
34
+ if RUBY_ENGINE == "ruby"
35
+ spec.extensions = ["ext/debug_inspector/extconf.rb"]
36
+ end
15
37
  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,16 +1,17 @@
1
1
  def fake_makefile
2
- File.open(File.join(File.dirname(__FILE__), "Makefile"), "w") {|f|
3
- f.puts %[install:\n\techo "Nada."]
2
+ File.open("Makefile", "w") { |f|
3
+ f.puts '.PHONY: install'
4
+ f.puts 'install:'
5
+ f.puts "\t" + '@echo "This Ruby not supported by/does not require debug_inspector."'
4
6
  }
5
7
  end
6
8
 
7
- def mri_2?
9
+ def mri_2_or_3?
8
10
  defined?(RUBY_ENGINE) && RUBY_ENGINE == "ruby" &&
9
- RUBY_VERSION =~ /^2/
11
+ RUBY_VERSION =~ /^[23]/
10
12
  end
11
13
 
12
-
13
- if mri_2?
14
+ if mri_2_or_3?
14
15
  require 'mkmf'
15
16
  create_makefile('debug_inspector')
16
17
  else
@@ -1,5 +1,17 @@
1
+ require 'rbconfig'
2
+ dlext = RbConfig::CONFIG['DLEXT']
1
3
  begin
2
- require 'debug_inspector.so'
4
+ # If the installation task did its job, the extension is in lib/ next to this file.
5
+ require "debug_inspector.#{dlext}"
6
+ # We only want to define constants if the extension has loaded.
7
+ require_relative "rubyvm/debug_inspector/version"
3
8
  rescue LoadError
9
+ begin
10
+ # If not, maybe the extension is in ext/
11
+ require_relative "../ext/debug_inspector/debug_inspector.#{dlext}"
12
+ # We only want to define constants if the extension has loaded.
13
+ require_relative "rubyvm/debug_inspector/version"
14
+ rescue LoadError => e
15
+ puts "debug_inspector extension was not loaded"
16
+ end
4
17
  end
5
-
@@ -0,0 +1,4 @@
1
+ class RubyVM::DebugInspector
2
+ # Don't forget to update the version string in the gemspec file.
3
+ VERSION = "1.1.0"
4
+ end
metadata CHANGED
@@ -1,16 +1,24 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: debug_inspector
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Mair (banisterfiend)
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-02-08 00:00:00.000000000 Z
11
+ date: 2021-03-23 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: A Ruby wrapper for the MRI 2.0 debug_inspector API
13
+ description: |
14
+ Adds methods to RubyVM::DebugInspector to allow for inspection of backtrace frames.
15
+
16
+ The debug_inspector C extension and API were designed and built by Koichi Sasada, this project is just a gemification of his work.
17
+
18
+ This library makes use of the debug inspector API which was added to MRI 2.0.0.
19
+ Only works on MRI 2 and 3. Requiring it on unsupported Rubies will result in a no-op.
20
+
21
+ Recommended for use only in debugging situations. Do not use this in production apps.
14
22
  email:
15
23
  - jrmair@gmail.com
16
24
  executables: []
@@ -18,32 +26,39 @@ extensions:
18
26
  - ext/debug_inspector/extconf.rb
19
27
  extra_rdoc_files: []
20
28
  files:
29
+ - ".github/workflows/test.yml"
30
+ - ".gitignore"
31
+ - Gemfile
21
32
  - README.md
22
33
  - Rakefile
23
34
  - debug_inspector.gemspec
24
35
  - ext/debug_inspector/debug_inspector.c
25
36
  - ext/debug_inspector/extconf.rb
26
37
  - lib/debug_inspector.rb
38
+ - lib/rubyvm/debug_inspector/version.rb
27
39
  homepage: https://github.com/banister/debug_inspector
28
- licenses: []
29
- metadata: {}
40
+ licenses:
41
+ - MIT
42
+ metadata:
43
+ homepage_uri: https://github.com/banister/debug_inspector
44
+ source_code_uri: https://github.com/banister/debug_inspector
45
+ changelog_uri: https://github.com/banister/debug_inspector/releases
30
46
  post_install_message:
31
47
  rdoc_options: []
32
48
  require_paths:
33
49
  - lib
34
50
  required_ruby_version: !ruby/object:Gem::Requirement
35
51
  requirements:
36
- - - '>='
52
+ - - ">="
37
53
  - !ruby/object:Gem::Version
38
- version: '0'
54
+ version: '2.0'
39
55
  required_rubygems_version: !ruby/object:Gem::Requirement
40
56
  requirements:
41
- - - '>='
57
+ - - ">="
42
58
  - !ruby/object:Gem::Version
43
59
  version: '0'
44
60
  requirements: []
45
- rubyforge_project:
46
- rubygems_version: 2.0.0.rc.2
61
+ rubygems_version: 3.1.4
47
62
  signing_key:
48
63
  specification_version: 4
49
64
  summary: A Ruby wrapper for the MRI 2.0 debug_inspector API