Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IRB with tracer flag is not working #5595

Closed
Adithya-copart opened this issue Feb 6, 2019 · 5 comments
Closed

IRB with tracer flag is not working #5595

Adithya-copart opened this issue Feb 6, 2019 · 5 comments
Milestone

Comments

@Adithya-copart
Copy link

@Adithya-copart Adithya-copart commented Feb 6, 2019

Environment

  • jruby 9.2.6.0-SNAPSHOT (2.5.3) 2019-02-06 c498366 Java HotSpot(TM) 64-Bit Server VM 25.191-b12 on 1.8.0_191-b12 +jit [darwin-x86_64]
  • Darwin MB-ADPENTELA.local 17.4.0 Darwin Kernel Version 17.4.0: Sun Dec 17 09:19:54 PST 2017; root:xnu-4570.41.2~1/RELEASE_X86_64 x86_64

Expected Behavior

$ irb --tracer
2.5.1 :001 > 

Actual Behavior

$ irb --tracer
ArgumentError: tried to create Proc object without a block
               proc at org/jruby/RubyKernel.java:1392
         add_filter at /Users/adpentela/.rvm/rubies/jruby-head/lib/ruby/stdlib/tracer.rb:263
  initialize_tracer at /Users/adpentela/.rvm/rubies/jruby-head/lib/ruby/stdlib/irb/ext/tracer.rb:19
       <module:IRB> at /Users/adpentela/.rvm/rubies/jruby-head/lib/ruby/stdlib/irb/ext/tracer.rb:70
             <main> at /Users/adpentela/.rvm/rubies/jruby-head/lib/ruby/stdlib/irb/ext/tracer.rb:14
            require at org/jruby/RubyKernel.java:984
             (root) at /Users/adpentela/.rvm/rubies/jruby-head/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:1
            require at /Users/adpentela/.rvm/rubies/jruby-head/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:54
        use_tracer= at /Users/adpentela/.rvm/rubies/jruby-head/lib/ruby/stdlib/irb/extend-command.rb:241
         initialize at /Users/adpentela/.rvm/rubies/jruby-head/lib/ruby/stdlib/irb/context.rb:46
         initialize at /Users/adpentela/.rvm/rubies/jruby-head/lib/ruby/stdlib/irb.rb:410
             <main> at /Users/adpentela/.rvm/rubies/jruby-head/bin/irb:13

I was playing with the --tracer flag in MRI and tried it in JRuby which failed with the following error.

@enebo
Copy link
Member

@enebo enebo commented Feb 6, 2019

This is fixed by #5596. Be aware you need to pass --debug to jruby to run tracer:

jruby --debug -S irb --trace
@enebo enebo closed this Feb 6, 2019
@Adithya-copart
Copy link
Author

@Adithya-copart Adithya-copart commented Feb 7, 2019

Thanks for the fix.
It works as expected with jruby --debug -S irb --tracer

@headius
Copy link
Member

@headius headius commented Feb 7, 2019

This was fixed a different way in 9dd7241.

The proc behavior here became a feature in Ruby largely by accident, or in response to the lack of syntax for capturing the current block (def foo(&block)). With that syntax added, and given the desire to reduce the number of methods that have "special" visibility into the caller's scope, we do not support calling proc without a block of some kind.

@headius
Copy link
Member

@headius headius commented Feb 7, 2019

Link #3915 and #4456.

@Adithya-copart
Copy link
Author

@Adithya-copart Adithya-copart commented Jul 17, 2019

jruby --debug -S irb --tracer is not working for me.
I tried 9.2.6.0, 9.2.7.0 and jruby-head.

It appears that a block is being passed here:

Tracer.add_filter {
|event, file, line, id, binding, *rests|
/^#{Regexp.quote(@CONF[:IRB_LIB_PATH])}/ !~ file and
File::basename(file) != "irb.rb"
}

and the method definition for add_filter expects a block argument:

def add_filter(&p) # :nodoc:
@filters.push p
end

$ jruby --debug -S irb --tracer
ArgumentError: wrong number of arguments (given 1, expected 0)
         add_filter at /Users/adpentela/.rvm/rubies/jruby-9.2.7.0/lib/ruby/stdlib/tracer.rb:144
         add_filter at /Users/adpentela/.rvm/rubies/jruby-9.2.7.0/lib/ruby/stdlib/tracer.rb:264
  initialize_tracer at /Users/adpentela/.rvm/rubies/jruby-9.2.7.0/lib/ruby/stdlib/irb/ext/tracer.rb:19
       <module:IRB> at /Users/adpentela/.rvm/rubies/jruby-9.2.7.0/lib/ruby/stdlib/irb/ext/tracer.rb:70
             <main> at /Users/adpentela/.rvm/rubies/jruby-9.2.7.0/lib/ruby/stdlib/irb/ext/tracer.rb:14
            require at org/jruby/RubyKernel.java:987
             (root) at /Users/adpentela/.rvm/rubies/jruby-9.2.7.0/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:1
            require at /Users/adpentela/.rvm/rubies/jruby-9.2.7.0/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:54
        use_tracer= at /Users/adpentela/.rvm/rubies/jruby-9.2.7.0/lib/ruby/stdlib/irb/extend-command.rb:241
         initialize at /Users/adpentela/.rvm/rubies/jruby-9.2.7.0/lib/ruby/stdlib/irb/context.rb:46
         initialize at /Users/adpentela/.rvm/rubies/jruby-9.2.7.0/lib/ruby/stdlib/irb.rb:410
             <main> at /Users/adpentela/.rvm/rubies/jruby-9.2.7.0/bin/jirb:13


$ irb -r 'tracer'
jruby-9.2.7.0 :001 > Tracer.method(:add_filter).parameters
 => [[:block, :p]] 
jruby-9.2.7.0 :002 > Tracer.method(:add_filter).source_location
 => ["/Users/adpentela/.rvm/rubies/jruby-9.2.7.0/lib/ruby/stdlib/tracer.rb", 263] 
jruby-9.2.7.0 :003 > Single = Tracer.new
 => #<Tracer:0x6c6cb480 @filters=[], @threads={2002=>0}, @get_line_procs={}> 
jruby-9.2.7.0 :004 > Single.method(:add_filter).source_location
 => ["/Users/adpentela/.rvm/rubies/jruby-9.2.7.0/lib/ruby/stdlib/tracer.rb", 144] 
jruby-9.2.7.0 :005 > Single.method(:add_filter).parameters
 => [[:block, :p]] 
jruby-9.2.7.0 :006 > 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants