Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Ruby Debug


Published on

Published in: Technology
  • Free Shed Plans, 12000 SHED PLANS. FREE SHED PLANS CLICK HERE ✱✱✱
    Are you sure you want to  Yes  No
    Your message goes here

Ruby Debug

  1. 1. Slide No. 1 by Rob Kaufman @orangewolf
  2. 2. Ruby Debugger Slide No. 2 Ruby Debugger: Beyond “puts”
  3. 3. Ruby Debugger Slide No. 3 Installation Ruby 1.8 gem install ruby-debug Ruby 1.9.2 gem install ruby-debug19 Ruby 1.9.3 see ruby-debug
  4. 4. Ruby Debugger Slide No. 4 Bundler group :test, :development do gem "ruby-debug", :platform => :ruby_18 gem "ruby-debug19", :platform => :ruby_19 end
  5. 5. Ruby Debugger Slide No. 5 Basic Usage Starting a program in the debugger rdebug my_file.rb Starting with a running program debugger statement Starting the Rails server rails server --debugger
  6. 6. Ruby Debugger Slide No. 6 Debugger Commandsbacktrace putl finishdelete set jumpenable tmate phelp where reloadlist catch sourceps display undisplaysave exit continuethread irb editvar next framebreak quit killdisable show ppeval trace restartinfo condition stepmethod down up
  7. 7. Ruby Debugger Slide No. 7 Most Important h[elp] Displays the help message for an item or the list of commands (rdb:1) help delete del[ete][ nnn...] delete some or all breakpoints (rdb:1) help Available commands: backtrace delete enable help list ps save thread var break disable eval info method putl set tmate where catch display exit irb next quit show trace condition down finish jump p reload source undisplay continue edit frame kill pp restart step up
  8. 8. Ruby Debugger Slide No. 8 Seeing disp[lay] expression Displays value of expression undisp[lay] [ n] Removes display of n p expression Evaluates the expression m[ethod] i[instance] object Displays instance methods of object m[ethod] class| module Displays instance methods of the class or module
  9. 9. Ruby Debugger Slide No. 9 Seeing v[ar] g[lobal] Displays global variables v[ar] l[ocal] Displays local variables v[ar] i[instance] object Displays instance variables of object v[ar] c[onst] object Displays constants of object
  10. 10. Ruby Debugger Slide No. 10 Moving c[ont] Continues execution s[tep] [ n] Executes next n lines stepping into methods n[ext] [ n] Executes next n lines stepping over methods fin[ish] Finishes execution of the current method q[uit] Exits debugger
  11. 11. Ruby Debugger Slide No. 11 Where am I? w[here] Displays stack frame l[ist][<-| n- m>] Displays source lines from n to m up [ n] Moves up n levels in the stack frame down [ n] Moves down n levels in the stack frame
  12. 12. Ruby Debugger Slide No. 12 There are others:Setting and clearing breakpoints and watchpointsThread manipulation
  13. 13. Ruby Debugger Slide No. 13 What if Im in Passenger Rack-debug Add “rack-debug” to Gemfile for development In config/environments/development.rb require rack/debug # for rails 2.3.x config.middleware.use Rack::Debug # for rails 3.0.x config.middleware.use Rack::Debug Add “require rack-debug/tasks” to Rakefile Restart passenger Run the listener “rake debug”
  14. 14. Ruby Debugger Slide No. 14 What if Im Using an IDE? Ruby-debug-ide integrates with Emacs, Vim, Rubymine, etc
  15. 15. Ruby Debugger Slide No. 15 Next Steps The Rails Guide Checkout Pry
  16. 16. Slide No. 16 by Rob Kaufman @orangewolf