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

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

Closed
chrisseaton opened this Issue Feb 13, 2014 · 3 comments

Comments

Projects
None yet
3 participants
@chrisseaton
Copy link
Contributor

chrisseaton commented Feb 13, 2014

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

This comment has been minimized.

Copy link
Contributor

chrisseaton commented May 8, 2014

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?

@chrisseaton

This comment has been minimized.

Copy link
Contributor

chrisseaton commented Mar 23, 2017

This doesn't apply now that Rubinius doesn't have a JIT, so closing.

@brixen

This comment has been minimized.

Copy link
Member

brixen commented Mar 27, 2017

@chrisseaton the new interpreter / JIT won't use the old mechanism anyway, so this wouldn't apply. Thanks for closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment