Keystrokes between `debugger` sessions seem to persist
Your environment
-
ruby -v: ruby 3.2.2 (2023-03-30 revision e51014f9c0) [arm64-darwin22] -
rdbg -v: rdbg 1.9.2
Describe the bug
After hitting a debugger break point once, and using c to move on, if you hit Enter before the next break point, the next breakpoint is skipped.
To Reproduce
Script:
require "debug"; def my_method; 2.times { |i| p i; debugger; sleep 1 }; end
Without hitting Enter:
https://github.com/ruby/debug/assets/54629302/2c5779ef-a054-4db9-97d0-1f09eaf05e49
With hitting Enter during the first sleep:
https://github.com/ruby/debug/assets/54629302/808ccb30-456a-4888-9794-96f514f8189f
Expected behavior
The execution should stop at the next breakpoint regardless of what keystrokes are used between breakpoints.
Additional context
None.
wow I see... Should we consume all input before REPL?
advices are very welcome If someone knows a techniques about it on other implementations
Should we consume all input before REPL?
Hmm possibly, is that considered unconventional? Might be worth looking at how pry handles this.
Or maybe just ignore previous REPL if in-between sessions.
The source of the issue:
https://github.com/ruby/debug/blob/0b77e8294b5b220b3b2a089bf09f94808654899a/lib/debug/session.rb#L1146-L1152
I too recently encountered this same issue. makes it hard to clear extra lines in the console
Been seeing the same issue. This didn't use to be the case. Maybe we can track down when this started?
Maybe we can track down when this started?
I think it was introduced here. And there's this related follow-up issue.
I think a sensible middle ground would be to skip the repeat functionality on enter / empty line until the prompt is displaying. Or discard empty line input altogether until then.
@ko1 What do you think about an option where Rails could turn off this repeater behavior? Right now ruby/debug is not all that usable in Rails because of this issue.
Sorry for long absent.
I have two options.
- clear
$stdinjust before printing prompt. - provide an option to disable repeating input.
I made patches for 1 and 2. 1 seems aggressive, but I'll try to merge.
2 is conservative approach, so no problem to introduce (RUBY_DEBUG_NO_REPEAT or no_repeat option).
BTW, I confirmed that:
a. pry behaves similar (typed "foo" while sleeping appears on the prompt) , but pry doesn't have repeating previous command with white space, there is no same issue. b. gdb behaves similar and has same issue.
For 1, I found that the patch makes failure on remote debugging features.
Thank you @ko1, it seems we can close this issue off in that case?
@dhh I opened https://github.com/rails/rails/pull/55214 if we want to enable the config option in new Rails apps.
When would you not want to have the no repeat thing on? I'd very much prefer if Rails could just run with the default Debug options in place.,