ruby-debug version 0.8 has been released!

Posted on March 15, 2007

This is mostly a maintenance release. The major change is that ruby-debug has been split in two parts:

  1. ruby-debug-base gem contains the debugger core API written in C. Use this gem if you want to create your own interface to the debugger and don't want to depend on changes to the ruby-debug CLI. The API is considered somewhat stable.

  2. ruby-debug gem depends on ruby-debug-base and provides CLI interface.

The idea is that if you are working on an integration with ruby-debug and find that the command set provided by ruby-debug is too limited for your purposes, you create a new gem and make it depended on ruby-debug-base. The only requirement is that you provide and register Debugger.handler like so:

    class MyHandler
      def at_line(context, file, line)...

      def at_breakoint(context, breakpoint)...

      def at_catchpoint(context, exception)...

      def at_tracing(context, file, line)...
    end
    Debugger.handler = MyHandler.new

The handler implements four callback methods that are invoked by the debugger. Each method receives the current context (Debugger::Context) as the first parameters. Please refer to the rdoc bundled with ruby-debug-base gem for the description of debugger API and consider ruby-debug gem as an example of such interface implementation.

One interesting example of such alternative interfaces could be the DBGP protocol that is becoming common in the field of dynamic languages.

Comments
  1. James HMarch 15, 2007 @ 06:06 PM

    Thanks as always for your work on this project. It's saved my ass more than once.

  2. Martin HessMarch 18, 2007 @ 05:59 PM

    I'm getting an error with this version: 5$ rdebug -sn ./hello.rb
    /opt/local/lib/ruby/gems/1.8/gems/ruby-debug-0.8/cli/ruby-debug.rb:21:in interface=': undefined local variable or methodprocessor' for Debugger:Module (NameError) from /opt/local/lib/ruby/gems/1.8/gems/ruby-debug-0.8/cli/ruby-debug.rb:31:in start_remote' from /opt/local/lib/ruby/gems/1.8/gems/ruby-debug-0.8/bin/rdebug:103 from /opt/local/bin/rdebug:16:inload' from /opt/local/bin/rdebug:16

  3. KentMarch 19, 2007 @ 03:48 AM

    Martin,

    Thanks for the bug report. I'm preparing a new version for upload.

  4. Chris RaschMarch 21, 2007 @ 01:39 PM

    When I try to run the following script:

    $ cat test.rb

    !/usr/bin/env ruby

    require 'ruby-debug'

    puts 'ok' debugger

    I get this error message:

    /usr/local/lib/ruby/gems/1.8/gems/ruby-debug-base-0.8.1/lib/ruby-debug-base.rb:184:in current_context': Debugger.start is not called yet. (RuntimeError) from /usr/local/lib/ruby/gems/1.8/gems/ruby-debug-base-0.8.1/lib/ruby-debug-base.rb:184:indebugger' from ./test.rb:6

    Any ideas what I'm doing wrong? Thanks for any help!

    Here's my dev environment:

    system: 10.4.8 Tiger (Client, with devtools installed)

    ruby --version ruby 1.8.5 (2006-08-25) [powerpc-darwin8.7.0]

    gem list --local ruby-debug (0.8.1, 0.4.5) Command line interface (CLI) for ruby-debug-base ruby-debug-base (0.8.1) Fast Ruby debugger

  5. Chris RaschMarch 21, 2007 @ 03:43 PM

    I think I figured out what I was doing wrong--full description is here:

    http://crasch.livejournal.com/532732.html

  6. evanMarch 24, 2007 @ 04:02 PM

    Kent, what if you made 'debugger()' automatically call 'Debugger.start()' if the debugger wasn't already started? It would help the people migrating from 'breakpoint'.

  7. KentMarch 24, 2007 @ 09:21 PM

    evan,

    Good idea. I'll change this method in the next version.

  8. Han HollMarch 27, 2007 @ 08:35 AM

    Hi, Just a small question: if you use debug_method :method, and you're done, how can you let the program continue ? There should probably a command undebug_method :method, but I haven't found it. Fantastic program, by the way.

    Han Holl

  9. Eric PromislowMay 02, 2007 @ 06:54 PM

    Seems that ruby-debug-base breaks when trying to debug ruby 1.8.4 on a 64-bit Linux (Ubuntu Dapper Drake) system.

    Here's what I've tried:

    Win32 (XP Server): 1.8.4 - ok 1.8.5 - ok 1.8.6 - ok

    Linux FedoraCore 6 (32 bit): 1.8.4 - ok 1.8.5 - ok 1.8.6 - ok

    Linux Ubuntu DapperDan 64 bit (AMD): 1.8.6 - ok 1.8.4 - fails as below

    On an Ubuntu/64 (Dapper Dan) machine running Ruby 1.8.4 I get this error:

    rdbgp/loader.rb:98:in `start_dbpg_client': undefined method `handler=' for Debugger:Module (NoMethodError)
     from rdbgp.rb:115:in `get_going'
     from rdbgp.rb:125
    

    Let me outline the code, as I might be doing something dumb here: ================ rdbgp.rb: ================

    module Debugger
      class << self
        ...
        def get_going()
          require 'rdbgp/loader'
          Debugger.start_client(options)
          Debugger.current_context.stop_next = 1
        end
      end
    end
    
    ================
    rdbgp/loader.rb:
    ================
    
    require 'rubygems'
    require 'ruby-debug-base'
    
    module Debugger
      class << self
        def start_client(options)
          @processor = CommandProcessor.new(options)
          Debugger.handler = @processor   ##**SPLAT**##
        end
        ...
      end
    end