banister / debug_inspector Goto Github PK
View Code? Open in Web Editor NEWA Ruby wrapper for the MRI 2.0 debug_inspector API
License: MIT License
A Ruby wrapper for the MRI 2.0 debug_inspector API
License: MIT License
Hi!
I'm trying to bundle install
in a brand new rails project and I'm getting the following error:
Installing debug_inspector 0.0.2 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/Users/andrew/.rbenv/versions/2.2.3/bin/ruby -r ./siteconf20151102-26699-1vldpwo.rb extconf.rb
creating Makefile
make "DESTDIR=" clean
make "DESTDIR="
compiling debug_inspector.c
linking shared-object debug_inspector.bundle
ld: library not found for -lgmp
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [debug_inspector.bundle] Error 1
make failed, exit code 2
Gem files will remain installed in /Users/andrew/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/debug_inspector-0.0.2 for inspection.
Results logged to /Users/andrew/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/extensions/x86_64-darwin-14/2.2.0-static/debug_inspector-0.0.2/gem_make.out
An error occurred while installing debug_inspector (0.0.2), and Bundler cannot continue.
Make sure that `gem install debug_inspector -v '0.0.2'` succeeds before bundling.
I'm using Ruby 2.2.3, installed with rbenv, and OS X El Capitan.
Please include licensing info to gemspec as well. Thanks.
Hey, to make https://github.com/banister/binding_of_caller compatible with Ruby 3, we need to use a variant of this gem that support Ruby 3, too (e.g. master
:) ).
Any chance someone can cut a new release and push it to rubygems.org? Thank you!!!
LoadError:
cannot load such file -- /opt/apps/forem/vendor/bundle/ruby/2.7.0/gems/debug_inspector-1.0.0/lib/debug_inspector.so
The latest upgrade seems to find wrong place of the "debug_inspector.so"
The "debug_inspector.so" file is located under the ext folder not lib folder.
I think this line should refer to the ext folder.
Please have a look at this issue.
summary
and description
should be not same text.
$ which gem
/usr/local/ruby-2.4.1/bin/gem
$ gem --version
2.6.11
$ gem build debug_inspector.gemspec
WARNING: description and summary are identical
WARNING: See http://guides.rubygems.org/specification-reference/ for help
Successfully built RubyGem
Name: debug_inspector
Version: 0.0.3
File: debug_inspector-0.0.3.gem
debug_inspector.gemspec
s.summary = "A Ruby wrapper for the MRI 2.0 debug_inspector API"
s.description = s.summary
Hi,
This might very well be a redundant question: is there any chance this port can be made to work without the underlining C implementation?
e.g. I want to utilise it within a JRuby application and although I can temporarily enable C extension support; that will option will be removed in future releases.
Just curious if a non-C variation existed?
Shouldn't gem name be rubyvm-debug_inspector?
VALUE rb_cRubyVM = rb_const_get(rb_cObject, rb_intern("RubyVM"));
VALUE cDebugInspector = rb_define_class_under(rb_cRubyVM, "DebugInspector", rb_cObject);
And, mv lib/debug_inspector.rb lib/rubyvm/debug_inspector.rb
, so:
RubyVM::DebugInspector::VERSION
TruffleRuby implements the debug_inspector C API since a few releases.
So it should be easy to get this gem working on TruffleRuby.
However, there is one big issue, this gem defines RubyVM::DebugInspector and not DebugInspector.
RubyVM should really never be defined on any Ruby but CRuby, otherwise various other gems fail as they assume that if RubyVM is defined then CRuby-specific APIs under RubyVM are defined too:
https://github.com/search?q=defined%3F%28RubyVM%29&type=code
https://cs.github.com/?q=defined%3F%28RubyVM%29
For example, there is lots of code like this:
if defined?(RubyVM)
RubyVM::InstructionSequence...
From #35
So, could this gem define top-level DebugInspector?
It could still define RubyVM::DebugInspector on CRuby (or if defined?(RubyVM)
) for compatibility.
I think it's be best to use deprecate_constant
though so usages of RubyVM::DebugInspector
get replaced by DebugInspector
.
cc @bjfish
I guess that it is recommended to add license file such as LICENSE.txt
or LICENSE.md
by github or generally rather than including it in README.md
.
It is also recommended on Fedora Project (Linux OS project).
We can create it from github Web UI.
https://help.github.com/articles/adding-a-license-to-a-repository/
Here is a sample for that.
https://github.com/rspec/rspec-core
@banister I can work for that if you like.
Hello,
debug_inspector
is a part of Rails.
and debug_inspector
RPM package is manged by Fedora Project.
https://admin.fedoraproject.org/pkgdb/package/rpms/rubygem-debug_inspector/
So, I want to add unit tests to test debug_inspector
.
And I guess that nowadays minitest
is best choice for that.
Can you add the tests?
I am going to send pull-request as my proposal.
I guess this issue caused by this gem, so, i create a new issue here too.
feel free to close one of them, thank you.
I want warp offical binding.break
into a method, assume, named: brk!
.
following is attempt: (compare to pry)
require 'binding_of_caller'
class Binding
def _break
require 'debug'
warn 'laoding break'
self.break
end
def _pry
require 'pry'
warn 'loading pry'
self.pry
end
end
class Object
def brk!
binding.of_caller(1)._break
end
def pry!
binding.of_caller(1)._pry
end
end
What i expected is, wrappered brk! behavior like wrapped pry!.
e.g. asssume, we have 1.rb code like this:
puts 100
pry!
puts 200
when run with ruby 1.rb
, get this: (it was expected)
But, when if change code to this:
puts 100
brk!
puts 200
when run ruby 1.rb
, get this. (it was unexpected)
as you can see, the =>
not stop on correct position. (which we expected to on same line as brk! as pry! does)
Thank you.
(Sorry for the cross-post to debug_inspector and binding_of_caller...)
It seems like ffi
should be possible to wrap the debugging API, without the need for native code compilation.
Is something along these lines possible?
#!/usr/bin/env ruby
require 'ffi'
module Peek
extend FFI::Library
ffi_lib "ruby"
# ./include/ruby/debug.h:43:typedef VALUE (*rb_debug_inspector_func_t)(const rb_debug_inspector_t *, void *);
# ./include/ruby/debug.h:45:VALUE rb_debug_inspector_open(rb_debug_inspector_func_t func, void *data);
attach_function :rb_debug_inspector_open, [
callback([ :pointer, :pointer ], :pointer), :pointer
], :pointer
Callback = FFI::Function.new(:pointer, [:pointer, :pointer]) do |a, b|
'???'
end
end
p Peek.rb_debug_inspector_open(Peek::Callback, nil)
Currently:
$ ruby -v -rdebug_inspector -e 'tap { 1.times { DebugInspector.open { |dc| pp dc.backtrace_locations; p dc.frame_binding(1) } } }'
ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x86_64-linux]
["-e:1:in `open'",
"-e:1:in `block (2 levels) in <main>'",
"-e:1:in `times'",
"-e:1:in `block in <main>'",
"<internal:kernel>:90:in `tap'",
"-e:1:in `<main>'"]
#<Binding:0x00007fa9fa275dc0>
$ ruby -v -rdebug_inspector -e 'tap { 1.times { DebugInspector.open { |dc| pp dc.backtrace_locations; p dc.frame_binding(3) } } }'
truffleruby 24.0.0-dev-4cd14c48, like ruby 3.2.2, GraalVM CE Native [x86_64-linux]
["/home/eregon/.rubies/truffleruby-dev/lib/truffle/truffle/cext.rb:1750:in `rb_ensure'",
"exception.c:107:in `rb_ensure'",
"/home/eregon/.rubies/truffleruby-dev/lib/truffle/truffle/cext_ruby.rb:40:in `open'",
"-e:1:in `block (2 levels) in <main>'",
"<internal:core> core/integer.rb:148:in `times'",
"-e:1:in `block in <main>'",
"<internal:core> core/kernel.rb:517:in `tap'",
"-e:1:in `<main>'"]
#<Binding:0xbf8>
So there are 2 more frames on TruffleRuby due to the call to rb_ensure() which is actually part of the stacktrace, unlike on CRuby.
We could potentially try to apply an offset in this C extension to hide this.
OTOH, people might want to filter the open
call and maybe even some callers, in which case such filtering code would work for both without any changes.
Example of such filtering:
debug_inspector/test/basic_test.rb
Lines 5 to 7 in 582251c
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.