ruby-debug / debase

BSD 2-Clause "Simplified" License
209 stars 32 forks source link

"Step over/next" command often performs "continue" in ruby 2.6 #75

Closed rockorequin closed 3 years ago

rockorequin commented 5 years ago

With ruby 2.6.3 and ruby-debug-ide (I use Netbeans 11), I find that the 'Step Over' command often just continues until the next breakpoint. 'Step Over' works fine in ruby 2.5.5.

These issues might be related: https://github.com/deivid-rodriguez/byebug/issues/550 https://github.com/googleapis/google-cloud-ruby/issues/3022

Quoting from the latter:

Ruby 2.6 changed the behavior of TracePoint with regard to line tracing at the beginning of a method. The Debugger code sometimes responds to a call tracepoint by enabling a line tracepoint. In Ruby < 2.6, this works and allows the first line in the method to trigger the line tracepoint. However, in Ruby >= 2.6, the first line in the method does not trigger the new tracepoint. (This happens only if the line tracepoint was only activated inside the call tracepoint's callback. If the line tracepoint was active previously, then it properly triggers on the method's first line.)

I don't know if this might be related to the TracePoint changes listed here: https://rubyreferences.github.io/rubychanges/2.6.html#tracepoint-improvements

ViugiNick commented 5 years ago

@rockorequin Could you provide a sample script to reproduce the problem?

rockorequin commented 5 years ago

This script shows the problem for me: with 2.6.3p62, if I put a breakpoint on the line "k = DateTime.parse..." line and then do a 'next' when it hits that line, instead of stopping on the "puts" line, the code stops at ruby-debug-ide.rb#101, ie the line saying: if bt && !bt.is_a?(SystemExit).

require 'rails'

class Test
  def a
    k = DateTime.parse('2019-1-1').to_date.end_of_day
    puts "Hello!"
    k + 1.day
  end
end

j = Test.new.a
rockorequin commented 5 years ago

@ViugiNick Did you have any luck reproducing this?

rockorequin commented 5 years ago

Fwiw, I tried ruby 2.7.0-preview1 and it seems that it doesn't have this problem, so maybe it's a bug in the underlying ruby-2.6 tracepoint API.

ViugiNick commented 5 years ago

@rockorequin looks like you are right. Are you ok with using 2.7. or should I try to fix this for 2.6.?

rockorequin commented 5 years ago

@ViugiNick Personally I'm fine with using 2.7 for now or I can go back to 2.5 if 2.7 breaks something down the line. Perhaps it could be noted as a known issue with 2.6 in the readme?

jvilk-stripe commented 5 years ago

I think the byebug maintainer figured out the issue with 2.6, and 2.6.4 might fix:

https://github.com/deivid-rodriguez/byebug/issues/550#issuecomment-525921168

iox commented 4 years ago

I can confirm. I just upgraded from 2.6.3 to 2.6.5 and the problem with debase and "step over" is gone. I think this issue can be closed :)