SlideShare ist ein Scribd-Unternehmen logo
1 von 16
Notch8.com
                                                Slide No. 1




                               by
                        Rob Kaufman
                      rob@notch8.com
                      http://notch8.com
             http://www.slideshare.net/notch8
              http://speakerrate.com/notch8
                         @orangewolf
Notch8.com                Ruby Debugger
                                          Slide No. 2




             Ruby Debugger:
              Beyond “puts”
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
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
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
Notch8.com                  Ruby Debugger
                                            Slide No. 6




             Debugger Commands

backtrace       putl           finish
delete          set            jump
enable          tmate          p
help            where          reload
list            catch          source
ps              display        undisplay
save            exit           continue
thread          irb            edit
var             next           frame
break           quit           kill
disable         show           pp
eval            trace          restart
info            condition      step
method          down           up
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
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
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
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
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
Notch8.com                                 Ruby Debugger
                                                           Slide No. 12




                   There are others:
Setting and clearing breakpoints and watchpoints

Thread manipulation
Notch8.com                                   Ruby Debugger
                                                             Slide No. 13




               What if I'm 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”
Notch8.com                               Ruby Debugger
                                                         Slide No. 14




             What if I'm Using an IDE?
  Ruby-debug-ide integrates with Emacs, Vim, Rubymine, etc
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/
Notch8.com
                                                Slide No. 16




                               by
                        Rob Kaufman
                      rob@notch8.com
                      http://notch8.com
             http://www.slideshare.net/notch8
              http://speakerrate.com/notch8
                         @orangewolf

Weitere ähnliche Inhalte

Ähnlich wie Ruby Debug

Introduction to Ruby on Rails
Introduction to Ruby on RailsIntroduction to Ruby on Rails
Introduction to Ruby on Rails
Manoj Kumar
 
Ruby on rails探索
Ruby on rails探索Ruby on rails探索
Ruby on rails探索
Mu Chun Wang
 
Ruby 1.9 And Rails 3.0
Ruby 1.9 And Rails 3.0Ruby 1.9 And Rails 3.0
Ruby 1.9 And Rails 3.0
ArrrrCamp
 
Debugging Rails 3 Applications
Debugging Rails 3 ApplicationsDebugging Rails 3 Applications
Debugging Rails 3 Applications
Nathan Broadbent
 

Ähnlich wie Ruby Debug (20)

Contribute to rails
Contribute to railsContribute to rails
Contribute to rails
 
PDF Ruby on Rails 3 Day BC
 PDF Ruby on Rails 3 Day BC PDF Ruby on Rails 3 Day BC
PDF Ruby on Rails 3 Day BC
 
Hacking with ruby2ruby
Hacking with ruby2rubyHacking with ruby2ruby
Hacking with ruby2ruby
 
JRuby, Ruby, Rails and You on the Cloud
JRuby, Ruby, Rails and You on the CloudJRuby, Ruby, Rails and You on the Cloud
JRuby, Ruby, Rails and You on the Cloud
 
Speedy TDD with Rails
Speedy TDD with RailsSpeedy TDD with Rails
Speedy TDD with Rails
 
Introduction to Ruby on Rails
Introduction to Ruby on RailsIntroduction to Ruby on Rails
Introduction to Ruby on Rails
 
Ruby on Rails Presentation
Ruby on Rails PresentationRuby on Rails Presentation
Ruby on Rails Presentation
 
Ruby on rails探索
Ruby on rails探索Ruby on rails探索
Ruby on rails探索
 
Debugging on rails
Debugging on railsDebugging on rails
Debugging on rails
 
Debugging on Rails. Mykhaylo Sorochan
Debugging on Rails. Mykhaylo SorochanDebugging on Rails. Mykhaylo Sorochan
Debugging on Rails. Mykhaylo Sorochan
 
Connecting the Worlds of Java and Ruby with JRuby
Connecting the Worlds of Java and Ruby with JRubyConnecting the Worlds of Java and Ruby with JRuby
Connecting the Worlds of Java and Ruby with JRuby
 
Ruby 1.9 And Rails 3.0
Ruby 1.9 And Rails 3.0Ruby 1.9 And Rails 3.0
Ruby 1.9 And Rails 3.0
 
.NET Architects Day - DNAD 2011
.NET Architects Day - DNAD 2011.NET Architects Day - DNAD 2011
.NET Architects Day - DNAD 2011
 
09 - Fábio Akita - Além do rails
09 - Fábio Akita - Além do rails09 - Fábio Akita - Além do rails
09 - Fábio Akita - Além do rails
 
From dot net_to_rails
From dot net_to_railsFrom dot net_to_rails
From dot net_to_rails
 
Monkeybars in the Manor
Monkeybars in the ManorMonkeybars in the Manor
Monkeybars in the Manor
 
Building web framework with Rack
Building web framework with RackBuilding web framework with Rack
Building web framework with Rack
 
Jaoo Michael Neale 09
Jaoo Michael Neale 09Jaoo Michael Neale 09
Jaoo Michael Neale 09
 
How to Begin to Develop Ruby Core
How to Begin to Develop Ruby CoreHow to Begin to Develop Ruby Core
How to Begin to Develop Ruby Core
 
Debugging Rails 3 Applications
Debugging Rails 3 ApplicationsDebugging Rails 3 Applications
Debugging Rails 3 Applications
 

Mehr von Rob Kaufman (7)

How to Get Your Idea Built
How to Get Your Idea BuiltHow to Get Your Idea Built
How to Get Your Idea Built
 
Learned from Woodworking
Learned from WoodworkingLearned from Woodworking
Learned from Woodworking
 
Testing Philosphies
Testing PhilosphiesTesting Philosphies
Testing Philosphies
 
Tanning Bed
Tanning BedTanning Bed
Tanning Bed
 
Ruby 1.9 Or Bust Presentation
Ruby 1.9 Or Bust PresentationRuby 1.9 Or Bust Presentation
Ruby 1.9 Or Bust Presentation
 
Mysql S&M
Mysql S&MMysql S&M
Mysql S&M
 
Action Mailer In Action
Action Mailer In ActionAction Mailer In Action
Action Mailer In Action
 

Kürzlich hochgeladen

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 

Kürzlich hochgeladen (20)

TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 

Ruby Debug

  • 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. Notch8.com Ruby Debugger Slide No. 2 Ruby Debugger: Beyond “puts”
  • 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. 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. 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. Notch8.com Ruby Debugger Slide No. 6 Debugger Commands backtrace putl finish delete set jump enable tmate p help where reload list catch source ps display undisplay save exit continue thread irb edit var next frame break quit kill disable show pp eval trace restart info condition step method down up
  • 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. 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. 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. 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. 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. Notch8.com Ruby Debugger Slide No. 12 There are others: Setting and clearing breakpoints and watchpoints Thread manipulation
  • 13. Notch8.com Ruby Debugger Slide No. 13 What if I'm 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. Notch8.com Ruby Debugger Slide No. 14 What if I'm Using an IDE? Ruby-debug-ide integrates with Emacs, Vim, Rubymine, etc
  • 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. Notch8.com Slide No. 16 by Rob Kaufman rob@notch8.com http://notch8.com http://www.slideshare.net/notch8 http://speakerrate.com/notch8 @orangewolf