Skip to content

Incorrect binding.source_location line with -Xcompile.mode=JIT (confuses pry) + confusing output when using native launcher #8445

@ivoanjo

Description

@ivoanjo

Hey!

I randomly bumped into this one while testing a new release of pry-debugger-jruby.

It seems binding.source_location is off by a few lines when -Xcompile.mode=JIT is being used, which confuses pry since it uses that to display source code.

Example used below:

puts RUBY_DESCRIPTION

# require 'bundler/inline'

# gemfile do
#   source 'https://rubygems.org'

#   gem 'pry'
# end

# require 'pry'

def some_method
  puts binding.source_location
  # binding.pry
  Hello.new.potato
  puts 'Hello, World!'
end

class Hello
  def potato
    puts "potato1"
    puts "potato2"
  end
end

some_method

(You can comment out the pry parts to see how pry misbehaves)

Environment Information

Provide at least:

  • JRuby version (jruby -v) and command line (flags, JRUBY_OPTS, etc)

jruby 9.4.6.0 (3.1.4) 2024-02-20 576fab2c51 OpenJDK 64-Bit Server VM 23.0.1+8-FR on 23.0.1+8-FR +jit [x86_64-linux]
jruby -Xcompile.mode=JIT --debug test/test.rb

  • Operating system and platform (e.g. uname -a)

Linux 6.8.0-48-generic #48~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Oct 7 11:24:13 UTC 2 x86_64 x86_64 x86_64 GNU/Linux

Expected Behavior

$ jruby -Xcompile.mode=OFF --debug test/test.rb
jruby 9.4.6.0 (3.1.4) 2024-02-20 576fab2c51 OpenJDK 64-Bit Server VM 23.0.1+8-FR on 23.0.1+8-FR [x86_64-linux]
test/test.rb
14
potato1
potato2
Hello, World!

Correct line is shown (14)

Actual Behavior

$ jruby -Xcompile.mode=JIT --debug test/test.rb
jruby 9.4.6.0 (3.1.4) 2024-02-20 576fab2c51 OpenJDK 64-Bit Server VM 23.0.1+8-FR on 23.0.1+8-FR +jit [x86_64-linux]
test/test.rb
21
potato1
potato2
Hello, World!

Incorrect line is shown (21)


As always, thanks for the amazing work on JRuby, and very looking forward to the next release 🙏

(Also, this doesn't block me at all -- just a see something, say something kinda report! :D )

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions