Connecting to a running ruby process

Hi!
Is there any way you can connect to a running ruby process (for instance
a
mongrel) and ‘talk’ to it like we can do in lisp using slime ?
For instance in you may connect to a running lisp image (like a
hunchentoot
web server) and inspect variables as they get created and destroyed. I
find
such a ‘back-door’(if we may call it) very powerful. I remember there
was
something called a breakpoint or debug built into rails. However that is
not
what I am actually looking at.

Piyush

Hi!
Is there any way you can connect to a running ruby process (for instance a
mongrel) and ‘talk’ to it like we can do in lisp using slime ?
For instance in you may connect to a running lisp image (like a hunchentoot
web server) and inspect variables as they get created and destroyed. I find
such a ‘back-door’(if we may call it) very powerful. I remember there was
something called a breakpoint or debug built into rails. However that is not
what I am actually looking at.

Piyush

Look at LiveConsole:
http://rubyforge.org/projects/live-console/
(Maybe it isn’t directly what you need, but it might help)


“Configure complete, now type ‘make’ and PRAY.”

            (configure script of zsnes - www.zsnes.com)

Piyush R. wrote:

Hi!
Is there any way you can connect to a running ruby process (for instance
a
mongrel) and ‘talk’ to it like we can do in lisp using slime ?

Try the ruby-debug gem (which is what rails uses). Unfortunately, the
supplied documentation is pretty poor, but there is a pretty good doc at

Separate process debugging can be done via rdebug command line flags, or
by calling Debugger methods explicitly:

$ cat p1.rb
require ‘rubygems’
require ‘ruby-debug’

Debugger.wait_connection = true
Debugger.start_remote
Debugger.post_mortem

Debugger.breakpoint
a = 1 - 1
b = 2 / a
c = a + b
puts c

$ ruby p1.rb

In another window: rdebug -c to single step, inspect variables etc. in
the first process.