I've been watching a thread on ruby-talk about the possibility to have a faster debugger for Ruby.
Now when Ruby 1.8.4 has a better C based API for tracing code execution, it is possible to significantly speed up debug.rb. I've been playing with this idea for last two days and came up with ruby-debug extension:
Follow these easy steps:
- Download extension ruby-debug-0.1.gem.
- Install it with
sudo gem install ruby-debug-0.1.gem Use either
$ rdebug _your-script_Or for your Rails application:
Add to your config/environments/development.rb
require 'ruby-debug'Use Kernel#debugger method to interrupt your application and invoke debugger
def myaction ... debugger ... end
Enjoy.
Update. I've created a project on rubyforge.org for this extension and uploaded a bugfix version 0.1.2. Now you don't have to download the gem file from this site. Just use
$ gem install ruby-debug
command to install it.
I'd try this out if you gave a little more information out about how it works, what it does, and how it is better than existing libraries. Sounds interesting, but not enough to download & play with yet.
Justin,
This extension has the same interface as debug.rb library which is bundled with Ruby. The only difference that a substantial amount of debug.rb is implemented in C using new hook API. This way the debugger has much better performance. For example, if you try debugging any Rails application with standard debug.rb, you will find the performance of your application running under debug.rb unacceptably poor. With this extension you won't see the difference, well almost.
The usage is quite simple. As I noted in this article you add
require "ruby-debug"statement into your config/environments/development.rb file and in any of your actions or any other methods you call a debugger by using Kernel#debugger method. As soon as you hit this method, you will get a debugger prompt. Try help command for the list of available commands. Btw, make sure that you are running webrick though, becuase lighttpd creates one or many fastcgi processes that don't have access to your terminal. Have fun.