SlideShare a Scribd company logo
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

More Related Content

Similar to Ruby Debug (20)

PDF
RubyMotion: Under the Hood
Joshua Ballanco
 
PDF
Baruco 2014 - Rubymotion Workshop
Brian Sam-Bodden
 
PDF
The story of language development
Hiroshi SHIBATA
 
PDF
IJTC%202009%20JRuby
tutorialsruby
 
PDF
IJTC%202009%20JRuby
tutorialsruby
 
KEY
ShRUG 5 - Scottish Ruby Conf edition
PatchSpace Ltd
 
PDF
Introduction of Tools for providing rich user experience in debugger
Naoto Ono
 
PDF
Ruby Presentation
platico_dev
 
PDF
Surge2012
davidapacheco
 
KEY
MacRuby: What is it? and why should you care?
Joshua Ballanco
 
KEY
Ruby'izing iOS development
toamitkumar
 
PDF
Ruby Programming Introduction
Anthony Brown
 
PDF
Future of Ruby on the Web
Future Insights
 
PDF
Ruby, Meet iPhone
Atomic Object
 
KEY
Your fist RubyMotion Application
toamitkumar
 
PDF
Web Development With Ruby - From Simple To Complex
Brian Hogan
 
PDF
Xcode, Basics and Beyond
rsebbe
 
PPTX
Debugging Tips and Tricks - iOS Conf Singapore 2015
Fahim Farook
 
PPT
debugging (1).ppt
jerlinS1
 
PPT
An important characteristic of a test suite that is computed by a dynamic ana...
jeyasrig
 
RubyMotion: Under the Hood
Joshua Ballanco
 
Baruco 2014 - Rubymotion Workshop
Brian Sam-Bodden
 
The story of language development
Hiroshi SHIBATA
 
IJTC%202009%20JRuby
tutorialsruby
 
IJTC%202009%20JRuby
tutorialsruby
 
ShRUG 5 - Scottish Ruby Conf edition
PatchSpace Ltd
 
Introduction of Tools for providing rich user experience in debugger
Naoto Ono
 
Ruby Presentation
platico_dev
 
Surge2012
davidapacheco
 
MacRuby: What is it? and why should you care?
Joshua Ballanco
 
Ruby'izing iOS development
toamitkumar
 
Ruby Programming Introduction
Anthony Brown
 
Future of Ruby on the Web
Future Insights
 
Ruby, Meet iPhone
Atomic Object
 
Your fist RubyMotion Application
toamitkumar
 
Web Development With Ruby - From Simple To Complex
Brian Hogan
 
Xcode, Basics and Beyond
rsebbe
 
Debugging Tips and Tricks - iOS Conf Singapore 2015
Fahim Farook
 
debugging (1).ppt
jerlinS1
 
An important characteristic of a test suite that is computed by a dynamic ana...
jeyasrig
 

More from Rob Kaufman (8)

PDF
How to Get Your Idea Built
Rob Kaufman
 
PDF
Developer Flow
Rob Kaufman
 
ODP
Learned from Woodworking
Rob Kaufman
 
ODP
Testing Philosphies
Rob Kaufman
 
ODP
Tanning Bed
Rob Kaufman
 
ODP
Ruby 1.9 Or Bust Presentation
Rob Kaufman
 
ODP
Mysql S&M
Rob Kaufman
 
ODP
Action Mailer In Action
Rob Kaufman
 
How to Get Your Idea Built
Rob Kaufman
 
Developer Flow
Rob Kaufman
 
Learned from Woodworking
Rob Kaufman
 
Testing Philosphies
Rob Kaufman
 
Tanning Bed
Rob Kaufman
 
Ruby 1.9 Or Bust Presentation
Rob Kaufman
 
Mysql S&M
Rob Kaufman
 
Action Mailer In Action
Rob Kaufman
 
Ad

Recently uploaded (20)

PDF
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
PPTX
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PDF
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PDF
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PPTX
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
PDF
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PDF
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
PDF
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
PDF
July Patch Tuesday
Ivanti
 
PDF
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
July Patch Tuesday
Ivanti
 
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
Ad

Ruby Debug

  • 1. Notch8.com Slide No. 1 by Rob Kaufman [email protected] 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 [email protected] http://notch8.com http://www.slideshare.net/notch8 http://speakerrate.com/notch8 @orangewolf