Skip to content

Debugger doesn't seem to work with the JIT #2942

Open
chrisseaton opened this Issue Feb 13, 2014 · 1 comment

2 participants

@chrisseaton

I'm trying out the Rubinius debugger, but I can't seem to get it set a breakpoint on a method that has already been compiled. They do work before the method is compiled.

Expected behaviour is that the breakpoints would work on compiled code, and presumably the compiled code would be deoptimized when I install the breakpoint.

This is with v2.2.4, Mac, x86_64.

Take this test file, test.rb.

require 'rubinius/debugger'

def foo
  a = 1
  b = 2
  c = 3
end

10_000_000.times do
  foo
end

Rubinius::Debugger.start

10_000_000.times do
  foo
end

Run it and set a breakpoint on line 5. The breakpoint doesn't seem to work.

$ rubinius/bin/ruby test.rb

| Breakpoint: Object#__script__ at test.rb:13 (38)
| 13: Rubinius::Debugger.start
debug> b Object#foo:5
| Set breakpoint 1: test.rb:5 (+4)
debug> c
$

Perhaps it's the JIT - try it with JIT disabled.

$ rubinius/bin/ruby -Xint test.rb 

| Breakpoint: Object#__script__ at test.rb:13 (38)
| 13: Rubinius::Debugger.start
debug> b Object#foo:5
| Set breakpoint 1: test.rb:5 (+4)
debug> c

| Breakpoint: Object#foo at test.rb:5 (4)
| 5:   b = 2
debug> exit
$

Now it works.

We can also make it work by not running enough iterations to provoke the JIT -
change 10_000_000 to 1.

$ rubinius/bin/ruby test.rb 

| Breakpoint: Object#__script__ at test.rb:13 (37)
| 13: Rubinius::Debugger.start
debug> b Object#foo:5
| Set breakpoint 1: test.rb:5 (+4)
debug> c

| Breakpoint: Object#foo at test.rb:5 (4)
| 5:   b = 2
debug> exit
$
@YorickPeterse YorickPeterse added the JIT label Feb 15, 2014
@chrisseaton

I'll partially provide a solution to my own problem -- I needed to use jit.check_debugging, to get the compiled code to periodically poll to jump back to the interpreter.

I'll leave this open as a bug as I don't think his isn't as clear as it could be -- at the moment it fails depending on whether a method has been compiled, which a normal user may not be aware of. It doesn't even provide an error message -- I could be waiting for the breakpoint to be hit, not aware that it's running in compiled code.

Could Rubinius deoptimize the method when I install the breakpoint? Or tell me if I try to install a breakpoint in a method that has been compiled, and tell me to use this flag?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.