Adding "yield" command

27 views
Skip to first unread message

Dave

unread,
Jul 26, 2011, 10:53:57 AM7/26/11
to Ruby Debugger
Is there interest in addition of a new "yield" command (or some such),
designed to automate stepping into the yielded block? This would be
equivalent to (and the trivial implementation is basically the same
as):
break __LINE__ + 1
next+
delete (last breakpoint)

I have that implemented for myself and I find it to save a ton of
time, since it's such a common operation. My all-ruby implementation
can't handle one-liners, nor can it detect if the next line isn't
actually inside a block (in which case it'll be equivalent to running
next+). Assuming that people like the idea of the command, and are
willing to accept the limitations of the current command, I can submit
patches soon (docs are TBD). If the idea is good, but the limitations
are unacceptable, I can look into a more complex implementation.
Otherwise I'll just put my patch set up somewhere for other people to
use as they wish.

Thanks
Dave

Roger Pack

unread,
Jul 26, 2011, 1:47:58 PM7/26/11
to ruby-d...@googlegroups.com
On Tue, Jul 26, 2011 at 8:53 AM, Dave <da...@mit.edu> wrote:
Is there interest in addition of a new "yield" command (or some such),
designed to automate stepping into the yielded block? This would be
equivalent to (and the trivial implementation is basically the same
as):
break __LINE__ + 1
next+
delete (last breakpoint)

doesn't next already do that, in debug1.9 anyway?
-roge-r

Rocky Bernstein

unread,
Jul 30, 2011, 11:16:00 PM7/30/11
to ruby-d...@googlegroups.com
Sorry for the delayed reply.

On Tue, Jul 26, 2011 at 10:53 AM, Dave <da...@mit.edu> wrote:
Is there interest in addition of a new "yield" command (or some such),
designed to automate stepping into the yielded block?

I understand there may be issues around yield in ruby-debug, but  I am not exactly certain what situation you encounter and specifically what you are asking for.  

Perhaps giving a the smallest program that can demonstrates the problem, and a session which show what you tried and what you got will clarify. And it can serve as a basis for which  to consider and judge existing alternatives.

 
This would be
equivalent to (and the trivial implementation is basically the same
as):
break __LINE__ + 1
next+
delete (last breakpoint)

continue __LINE__ + 1 
is the same as "break __LINE__ + 1"; "delete" (last breakpoint)


I have that implemented for myself and I find it to save a ton of
time, since it's such a common operation. My all-ruby implementation
can't handle one-liners, nor can it detect if the next line isn't
actually inside a block (in which case it'll be equivalent to running
next+). Assuming that people like the idea of the command, and are
willing to accept the limitations of the current command, I can submit
patches soon (docs are TBD). If the idea is good, but the limitations
are unacceptable, I can look into a more complex implementation.
Otherwise I'll just put my patch set up somewhere for other people to
use as they wish.

Thanks
Dave

As I said above, I realize there are issues regarding "yield" in ruby-debug. Perhaps what you are asking for is addressed by the newer debuggers.

In the debugger-enhanced patches for YARV 1.9.2 used  by rb-trepanning, a "yield" event was added. 
For rubinius, rbx-trepanning understands when a block is about to be yielded and considers this in stepping. 

Ruby-core developers have said there will be no more feature enhancements to MRI 1.8, and I am generally not interested in more kludgy workarounds to ruby-debug. 

That said, it is fairly straight-forward how to add new debugger commands in ruby-debug. In the trepanning debuggers though it is even easier as there is a user directory where you can create for your own debugger commands. In ruby-debug there is only one command directory.
Reply all
Reply to author
Forward
0 new messages