Connecting to a running ruby process

P

Piyush Ranjan

[Note: parts of this message were removed to make it a legal post.]

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
 
J

Jakub Pavlík jn.

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)
 
B

Brian Candler

Piyush said:
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
http://bashdb.sourceforge.net/ruby-debug.html

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top