Closed st0012 closed 11 months ago
Excited for this one! 😁
Is this intentional?
[master]$ RUBY_DEBUG_IRB_CONSOLE=true exe/rdbg -O target.rb
DEBUGGER: Debugger can attach via UNIX domain socket (/run/user/1000/ruby-debug-ko1-223275)
/home/ko1/ruby/install/trunk/lib/ruby/gems/3.3.0+0/gems/debug-1.8.0/lib/debug/color.rb:22: warning: already initialized constant DEBUGGER__::Color::SUPPORT_COLORABLE_OPTION
/home/ko1/ruby/debug/lib/debug/color.rb:22: warning: previous definition of SUPPORT_COLORABLE_OPTION was here
[1, 10] in target.rb
1|
=> 2| n = 10
3| p 1
4| p 2
5| p 3
6| p 4
7| p 5
and
irb:rdbg(main):002> n
[1, 10] in target.rb
1|
2| n = 10
=> 3| p 1
4| p 2
5| p 3
6| p 4
7| p 5
8|
9|
10| __END__
=>#0 <main> at target.rb:3
irb:rdbg(main):003>
(n
as next
command)
For the remote connection, hmm... ignore this option? It is safer strategy for VSCode (DAP).
@ko1 great catch on the doc and remote mode issue. I've fixed both now.
(n as next command)
Yes this is expected. The irb:rdbg
integration only handles IRB commands and passes other types of input to debug
.
Yes this is expected. The
irb:rdbg
integration only handles IRB commands and passes other types of input todebug
.
This is why I could not allow to input Ruby expression directly (and allow with Reline prompt changing).
Could you consider to use escaping such as , next
which is used on VSCode DAP REPL?
Thanks for raising this 🙏 I talked to a few users during RubyConf and some said they did experience the issue before.
But we all think it's better not to add the comma prefix. Because it means users will need to constantly be aware of which commands are from IRB (without comma) and which are from debug
(with comma), which increases the learning curve for the feature.
Alternatively, I think we can add an input hint to let user know the current input will be treated as a debug
command through https://github.com/ruby/irb/pull/768.
Alternatively, I think we can add an input hint to let user know the current input will be treated as a debug command through https://github.com/ruby/irb/pull/768.
It is one idea. How to know the string is debug command or not?
@ko1 In IRB v1.10
, I added hint to irb:rdbg
session, which only show up when the input will be processed as debug
command. And it will be removed once the user hits enter so it doesn't pollute the output history. Finally, it will be disabled if the user has no_hint
set for debug
.
I've bumped the PR's IRB requirement to v1.10
to take advantage of this feature. Here's a short demo:
https://github.com/ruby/debug/assets/5079556/a69fe51b-561a-423e-b0b8-d3b424ebc2c2
Thank you. It's great.
Motivation
Currently, the
irb
command always opens up a fresh IRB session, which means:debug
's commands in this mode.debug
commands, users need to leave the IRB session first, which means losing IRB commands or feature like multi-line input.So in this PR, I enhanced the
irb
command by making it activate IRB's newirb:debug
integration.And if users want to always activate the new IRB console, without constantly typing
irb
command manually, they can achieve this by settingCONFIG[:irb_console]
totrue
.Closes https://github.com/ruby/irb/issues/712
Changes
When the new
irb
command is executed, it will:irb:rdbg
console, which is achieved by replacingdebug
'sUI_LocalConsole
UI with IRB'sIRB::Debug::UI
.debug
gem skip IRB's frames.Context#evaluate
method so when it evaluates IRB commands frozen threads will be temporarily unfroze.Furthermore, if users set
RUBY_DEBUG_IRB_CONSOLE
orCONFIG[:irb_console]
totrue
, then theirb:rdbg
console will be opened automatically in the sessions.Main differences
debug
's commands, instead of just IRB's.debug
's default console.irb:rdbg
console, users get hint when their input is going to be processed as adebug
command:https://github.com/ruby/debug/assets/5079556/a69fe51b-561a-423e-b0b8-d3b424ebc2c2