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

2,179 views

Published on

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

Ruby Debug

  1. 1. Notch8.com Slide No. 1 by Rob Kaufman rob@notch8.com http://notch8.com http://www.slideshare.net/notch8 http://speakerrate.com/notch8 @orangewolf
  2. 2. Notch8.com Ruby Debugger Slide No. 2 Ruby Debugger: Beyond “puts”
  3. 3. Notch8.com 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 http://blog.wyeworks.com/2011/11/1/ruby-1-9-3-and- ruby-debug
  4. 4. Notch8.com 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. Notch8.com 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. Notch8.com 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. Notch8.com 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. Notch8.com 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. Notch8.com 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. Notch8.com 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. Notch8.com 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. Notch8.com Ruby Debugger Slide No. 12 There are others:Setting and clearing breakpoints and watchpointsThread manipulation
  13. 13. Notch8.com Ruby Debugger Slide No. 13 What if Im in Passenger Rack-debug https://github.com/ddollar/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. Notch8.com Ruby Debugger Slide No. 14 What if Im Using an IDE? Ruby-debug-ide integrates with Emacs, Vim, Rubymine, etc
  15. 15. Notch8.com Ruby Debugger Slide No. 15 Next Steps The Rails Guide http://guides.rubyonrails.org/debugging_rails_applications.html Checkout Pry http://pry.github.com/
  16. 16. Notch8.com Slide No. 16 by Rob Kaufman rob@notch8.com http://notch8.com http://www.slideshare.net/notch8 http://speakerrate.com/notch8 @orangewolf

×