Giter Club home page Giter Club logo

debug_inspector's People

Contributors

banister avatar codegoalie avatar eregon avatar hisaichi5518 avatar junaruga avatar kerrizor avatar ko1 avatar r-obert avatar robindaugherty avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

debug_inspector's Issues

Bundler is failing to install native extensions

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.

debug_inspector.so cannot be found

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.

require_relative "debug_inspector.#{dlext}"

I think this line should refer to the ext folder.

Please have a look at this issue.

Warning: description and summary are identical

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

JRuby

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?

rename gem to rubyvm-debug_inspector

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

Renaming the module from RubyVM::DebugInspector to DebugInspector (required for TruffleRuby support)

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

binding.call(1).break not valid on debug gem which was builtin on Ruby 3.1release.

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)

image

But, when if change code to this:

puts 100
brk!
puts 200

when run ruby 1.rb, get this. (it was unexpected)

image

as you can see, the => not stop on correct position. (which we expected to on same line as brk! as pry! does)

Thank you.

Can debug_inspector be written using ffi, so as to not require native compilation?

(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)

Use an offset to hide extra frames on TruffleRuby?

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:

@offset = DebugInspector.open do |dc|
dc.backtrace_locations.index { |loc| loc.path == __FILE__ and loc.label == "setup" }
end

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.