Giter VIP home page Giter VIP logo

rbdbgr's Introduction

A modular, testable debugger for Ruby 1.9. A total rewrite of ruby-debug.

In order to use this debugger, you’ll need a patched Ruby 1.9 and some additional packages.

Apply threadframe-ruby-1.9.patch to the Ruby 1.9 source. Build Ruby 1.9 and install that. Next build and install rb-threadframe, which gives access to stack frames. It has a number of other cool extensions to the Thread, RubyVM:InstructionSequence, Proc, and Method classes.

Also, you need columnize which should be gem installable:

gem install columnize

Also you need linecache for Ruby 1.9. Unfortunately there are several out there. Use the ruby-1.9 branch from linecache:

svn co svn://rubyforge.org/var/svn/rocky-hacks/linecache/branches/ruby-1.9

Finally you need rb-trace.

I realize this is a bit of work to do. Right now this debugger is geared more for those who are willing to roll up their sleeves and help out than for novices.

Assuming the above checks out…

Running if the rbdbgr gem is installed:

 rbdbgr ruby-program [program]

If your program needs options of its own:

 rbdbgr -- ruby-program [program args...]

If you want to run from the source tree you can do that too:

 cd place-where-rbdbgr-is-installed:
 ./bin/rbdbgr -- ruby-program [program args...]

Running from inside irb:

 require 'rbdbgr' 
 Debugger.debug { your code }

The return value from Debugger is the return value of the block, i.e. the final value in the block.

You can run the same thing inside your Ruby program, but probably you don’t want to give a block. Instead, you may want to have debugging start on the next statement in the code:

 require 'rbdbgr' 
 Debugger.debug # Don't stop here...
 work # but stop here.

or if you haven’t mucked around with $0 and ARGV, you might try:

 Debugger.debug(:set_restart=>true)

which informs the debugger on how to restart the program (via the restart command) using the values of ARGV and $0 at the time Debugger.debug was called.

The above is really shorthand for something like:

 $rbdbgr = Debugger.new(:set_restart=>true) 
 $rbdbgr.debugger

The global variable $rbdbgr set holds debugger settings, such as “autolist” or “autoeval” settings and breakpoint information.

Due to the line-event orientation in ruby-debug, it occasionally it was convenient to add a synchronous stop in your program. I don’t think that will as necessary here, but if you do call to the debugger at the point of the call rather than the subsequent stopping point, set opts[:immediate] to true. Example:

 # ... work, work, work 
 mydbg.debugger(:immediate=>true) # enter debugger here 
 # ... work, work, work

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.