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

Re-open #5595: jruby --debug -S irb --tracer is not working #5795

Closed
Adithya-copart opened this issue Jul 17, 2019 · 5 comments
Closed

Re-open #5595: jruby --debug -S irb --tracer is not working #5795

Adithya-copart opened this issue Jul 17, 2019 · 5 comments
Milestone

Comments

@Adithya-copart
Copy link

@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 > 

Originally posted by @Adithya-copart in #5595 (comment)

@Adithya-copart Adithya-copart changed the title Re-open #5595 Re-open #5595: jruby --debug -S irb --tracer is not working Jul 17, 2019
@enebo
Copy link
Member

@enebo enebo commented Jul 18, 2019

Something is seriously wrong with our copy of tracer.rb. We maybe merged it improperly at some point. The error makes sense as written:

def foo(&a)
  p a
end;
a = proc {}; foo a

Each called to add_filter should be passing &a and not a.

Loading

@enebo enebo added this to the JRuby 9.2.8.0 milestone Jul 18, 2019
@enebo
Copy link
Member

@enebo enebo commented Jul 18, 2019

It looks like this is all my fault. @Adithya-copart can you test this patch (I am landing on master so you can try it by getting HEAD as well):

diff --git a/lib/ruby/stdlib/tracer.rb b/lib/ruby/stdlib/tracer.rb
index 57bec731d7..c4d99c1aa1 100644
--- a/lib/ruby/stdlib/tracer.rb
+++ b/lib/ruby/stdlib/tracer.rb
@@ -248,7 +248,7 @@ class Tracer
   #   })
 
   def Tracer.set_get_line_procs(file_name, &p)
-    Single.set_get_line_procs(file_name, p)
+    Single.set_get_line_procs(file_name, &p)
   end
 
   ##
@@ -261,7 +261,7 @@ class Tracer
   #   end
 
   def Tracer.add_filter(&p)
-    Single.add_filter(p)
+    Single.add_filter(&p)
   end
 end

Loading

@enebo enebo closed this in 67fed2f Jul 18, 2019
@Adithya-copart
Copy link
Author

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

@enebo Confirmed this is fixed in jruby-head.

$ jruby --debug -S irb --tracer
jruby-head :001 > 

Loading

@Adithya-copart
Copy link
Author

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

@enebo FYI, If you're not aware already, I noticed the same issue in ruby-head.

Looks like the last commit to tracer.rb is ruby/ruby@e6f8382#diff-3b83199cba295b54ba1e3170616c9d22

Loading

@enebo
Copy link
Member

@enebo enebo commented Jul 18, 2019

@Adithya-copart we wil get this merged over on MRI as well. Thans for pointing that out.

Loading

headius added a commit to headius/jruby that referenced this issue Aug 27, 2019
This relates to jruby#5847 and jruby#5795.
The diffs from CRuby in our tracer.rb were not quite equivalent
since the original would also accespt a Proc passed as an
argument. I've changed the logic here to use that argument or fall
back on a passed block.

There's also changes to how we invoke event hooks. The first just
unifies the JIT and interpreter to call the same logic. The
the second mimics CRuby when there's a frame klass and it is
either an included module or a singleton. These latter changes fix
the remaining failures in CRuby's test_tracer.rb.
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
2 participants