SlideShare une entreprise Scribd logo
1  sur  36
Télécharger pour lire hors ligne
The ultimate
guide to ruby
debugging
Rafael Rosa Fu

March 2012 - Montreal.rb

@rafaelrosafu
The ultimate
guide to ruby
debugging
Rafael Rosa Fu

March 2012 - Montreal.rb

@rafaelrosafu
Ruby debugging
basics
Rafael Rosa Fu

March 2012 - Montreal.rb

@rafaelrosafu
About me
More on that later
Why?
● TDD won't save you all the time
● Understand untested, legacy, complicated
code
● Understand unexpected behavior
● Interactive coding
Why?
● "When I coded in Delphi 2 I had support for it
on my IDE"
How?
●
●
●
●

Stack traces
puts, p, pp
Logging
debug module

● ruby-debug
○ ruby-debug19
● Pry
○ pry-nav
○ pry-stack_explorer
How?
●
●
●
●

Stack traces
puts, p, pp
Logging
debug module

● ruby-debug
○ ruby-debug19
● Pry
○ pry-nav
○ pry-stack_explorer
ruby-debug
Created by Kent Sibilev and Rocky Bernstein
● https://github.com/ruby-debug/ruby-debug
● http://bashdb.sourceforge.net/ruby-debug.
html
ruby-debug19 is a port by Mark Moseley
ruby-debug for 1.8.7
1. gem install ruby-debug
2. profit
ruby-debug for 1.9.x
1. gem install ruby-debug19
2. profit (almost)
● Workaround for 1.9.3:
○ Need newer versions for linecache and ruby-debugbase, not on rubygems
○ Some stuff is still broken
○ https://gist.github.com/2047760
○ Thanks to @fredostarr, @spastorino, @rafaeldx7
and @garyharan
ruby-debug
●
●
●
●
●
●

Follow the code execution
Inspect objects
Set breakpoints
See the stack
Change state (be careful)
Debug remotely
ruby-debug demo
● Lots of commands
○
○
○
○
○
○
●

debugger, rdebug
list, help, quit
p, pp, ps, display, info
break, next, step, continue
disable, condition
irb, where, edit, set, show

Fingers crossed
ruby-debug demo

Live demos always go wrong
Sorry in advance :)
Pry
Pry
● Developed by John Mair (@banisterfiend)
● http://github.com/pry/pry
● Started as a turbo irb
● An ecosystem is growing around it
○ Lots of plugins
Pry
● gem install pry
● gem install pry-doc
Pry demo
● Nice features
○
○
○
○

pagination
autocomplete
syntax highlight
highly customizable

● Lots of commands and features
○
○
○
○
●
●

ls, ls --help
cd, nesting, exit
.commands
show-doc, show-method, edit-method

pry-nav is not ready for primetime
pry-stack_explorer is ok
Lessons learned
● Debugging is not a bad thing when used
properly and sparingly
● Basic tools solve ~ 90% of the issues
● BDD/TDD will save you from debugging
most of the time
● The future is quite cloudy for Ruby debug
tools:
○ https://github.com/rocky/rb-trepanning
○ Cross-implementation?
○ http://blog.bithug.org/2011/09/maglev-debug
References - ruby-debug
● http://bashdb.sourceforge.net/ruby-debug.html
● http://railscasts.com/episodes/54-debugging-with-ruby●
●
●
●

debug
http://guides.rubyonrails.
org/debugging_rails_applications.html
https://github.com/ruby-debug
https://github.com/mark-moseley/ruby-debug/
https://gist.github.com/2047760
References - Pry
● http://pry.github.com
● https://github.com/pry
● http://banisterfiend.wordpress.com/2012/02/14/the-pry●
●
●

ecosystem/
http://pry.github.com/screencasts.html
○ Special thanks to @fnando :)
http://railscasts.com/episodes/280-pry-with-rails
http://twitter.com/banisterfiend
Questions

?
I just need 5 more minutes after this :)
About me

http://flagwallpapers.com/water-color-brazilian-
About me
● Coding professionally for 16 years
● Agilist, product and community guy too
● I love Ruby
"Ruby is designed to make programmers
happy"
- Matz
About me
About me
Ruby community in Brazil

40 to 60 people every month
Ruby community in Brazil

https://picasaweb.google.com/105291946909431816672
Ruby community in Brazil

https://picasaweb.google.com/105291946909431816672
Ruby community in Brazil

http://groups.google.com/group/dojo_sp
Ruby community in Brazil

http://pothix.com/blog/events/encontro-de-numero-5-do-guru-
Ruby community in Brazil

http://blog.lambda3.com.br/2012/02/dojo-dojo-
Ruby community in Brazil

~ 1,500 attendees, this year will be the 5th edition
http://www.flickr.
Ruby community in Brazil

~ 1,500 attendees, this year will be the 5th edition
http://www.flickr.
Ruby community in Brazil

Everybody is invited - August 30 and 31 2012 - São Paulo
http://www.flickr.
Thank you
Merci :)
@rafaelrosafu
rrosa@iweb.com
rafaelrosafu@gmail.com
grokpodcast.com
linkedin.com/in/rafaelrosafu

Contenu connexe

Tendances

DIve into the Open World - Presentation outline
DIve into the Open World - Presentation outline DIve into the Open World - Presentation outline
DIve into the Open World - Presentation outline
R.Harish Navnit
 

Tendances (20)

T3chFest 2017 - La Revolucion del Open Source
T3chFest 2017 - La Revolucion del Open SourceT3chFest 2017 - La Revolucion del Open Source
T3chFest 2017 - La Revolucion del Open Source
 
Go at Skroutz
Go at SkroutzGo at Skroutz
Go at Skroutz
 
RxNetty
RxNettyRxNetty
RxNetty
 
Last 2 Months in PHP - January 2018
Last 2 Months in PHP - January 2018Last 2 Months in PHP - January 2018
Last 2 Months in PHP - January 2018
 
Introduction to Vim 8.0
Introduction to Vim 8.0Introduction to Vim 8.0
Introduction to Vim 8.0
 
PHP Application Performance
PHP Application PerformancePHP Application Performance
PHP Application Performance
 
7 recomendaciones para migrar tus aplicaciones a Jakarta EE utilizando Apache...
7 recomendaciones para migrar tus aplicaciones a Jakarta EE utilizando Apache...7 recomendaciones para migrar tus aplicaciones a Jakarta EE utilizando Apache...
7 recomendaciones para migrar tus aplicaciones a Jakarta EE utilizando Apache...
 
FTC7 Michel Lefranc - Developing software based on the FSDL software library ...
FTC7 Michel Lefranc - Developing software based on the FSDL software library ...FTC7 Michel Lefranc - Developing software based on the FSDL software library ...
FTC7 Michel Lefranc - Developing software based on the FSDL software library ...
 
Es fácil contribuir al open source - Bolivia JUG 2020
Es fácil contribuir al open source - Bolivia JUG 2020Es fácil contribuir al open source - Bolivia JUG 2020
Es fácil contribuir al open source - Bolivia JUG 2020
 
Paving the road with Jakarta EE and Apache TomEE - JCON 2021
Paving the road with Jakarta EE  and Apache TomEE - JCON 2021Paving the road with Jakarta EE  and Apache TomEE - JCON 2021
Paving the road with Jakarta EE and Apache TomEE - JCON 2021
 
How Badoo Saved $1M Switching to PHP7 - Nikolay Krapivnyy - PHPDay Verona 2016
How Badoo Saved $1M Switching to PHP7 - Nikolay Krapivnyy - PHPDay Verona 2016How Badoo Saved $1M Switching to PHP7 - Nikolay Krapivnyy - PHPDay Verona 2016
How Badoo Saved $1M Switching to PHP7 - Nikolay Krapivnyy - PHPDay Verona 2016
 
NE Scala 2016 roundup
NE Scala 2016 roundupNE Scala 2016 roundup
NE Scala 2016 roundup
 
Its easy! contributing to open source - Devnexus 2020
Its easy! contributing to open source - Devnexus 2020Its easy! contributing to open source - Devnexus 2020
Its easy! contributing to open source - Devnexus 2020
 
TypeScript no Grupo Bandeirantes
TypeScript no Grupo BandeirantesTypeScript no Grupo Bandeirantes
TypeScript no Grupo Bandeirantes
 
Pavimentando el Camino con Jakarta EE 9 y Apache TomEE 9.0.0
Pavimentando el Camino con Jakarta EE 9 y Apache TomEE 9.0.0Pavimentando el Camino con Jakarta EE 9 y Apache TomEE 9.0.0
Pavimentando el Camino con Jakarta EE 9 y Apache TomEE 9.0.0
 
Advantages of Python Learning | Why Python
Advantages of Python Learning | Why PythonAdvantages of Python Learning | Why Python
Advantages of Python Learning | Why Python
 
Aprende, contribuye, y surfea Cloud Native Java - GuateJUG 2021
Aprende, contribuye, y surfea Cloud Native Java - GuateJUG 2021Aprende, contribuye, y surfea Cloud Native Java - GuateJUG 2021
Aprende, contribuye, y surfea Cloud Native Java - GuateJUG 2021
 
Untitled talk at Riviera.rb
Untitled talk at Riviera.rbUntitled talk at Riviera.rb
Untitled talk at Riviera.rb
 
DIve into the Open World - Presentation outline
DIve into the Open World - Presentation outline DIve into the Open World - Presentation outline
DIve into the Open World - Presentation outline
 
My talk at LVEE 2016
My talk at LVEE 2016My talk at LVEE 2016
My talk at LVEE 2016
 

Similaire à Montreal.rb ruby debugging basics - march 20th 2012

Idiomatic R for Rosetta Code (2013)
Idiomatic R for Rosetta Code (2013)Idiomatic R for Rosetta Code (2013)
Idiomatic R for Rosetta Code (2013)
Peter Kofler
 
Writing a Ruby Gem for beginners
Writing a Ruby Gem for beginnersWriting a Ruby Gem for beginners
Writing a Ruby Gem for beginners
ConFoo
 
Debugging Rails 3 Applications
Debugging Rails 3 ApplicationsDebugging Rails 3 Applications
Debugging Rails 3 Applications
Nathan Broadbent
 
Creating a mature puppet system
Creating a mature puppet systemCreating a mature puppet system
Creating a mature puppet system
rkhatibi
 

Similaire à Montreal.rb ruby debugging basics - march 20th 2012 (20)

rubyonrails
rubyonrailsrubyonrails
rubyonrails
 
rubyonrails
rubyonrailsrubyonrails
rubyonrails
 
Idiomatic R for Rosetta Code (2013)
Idiomatic R for Rosetta Code (2013)Idiomatic R for Rosetta Code (2013)
Idiomatic R for Rosetta Code (2013)
 
Ruby confhighlights
Ruby confhighlightsRuby confhighlights
Ruby confhighlights
 
Test Driven Development with PHP
Test Driven Development with PHPTest Driven Development with PHP
Test Driven Development with PHP
 
Introduction to rails
Introduction to railsIntroduction to rails
Introduction to rails
 
Groovy android
Groovy androidGroovy android
Groovy android
 
Gdb basics for my sql db as (percona live europe 2019)
Gdb basics for my sql db as (percona live europe 2019)Gdb basics for my sql db as (percona live europe 2019)
Gdb basics for my sql db as (percona live europe 2019)
 
Writing a Ruby Gem for beginners
Writing a Ruby Gem for beginnersWriting a Ruby Gem for beginners
Writing a Ruby Gem for beginners
 
Efficient Django
Efficient DjangoEfficient Django
Efficient Django
 
Passing the Joel Test in the PHP World (phpbnl10)
Passing the Joel Test in the PHP World (phpbnl10)Passing the Joel Test in the PHP World (phpbnl10)
Passing the Joel Test in the PHP World (phpbnl10)
 
ENIB 2015 2016 - CAI Web S02E03- Forge JS 1/4 - La forge JavaScript
ENIB 2015 2016 - CAI Web S02E03- Forge JS 1/4 - La forge JavaScriptENIB 2015 2016 - CAI Web S02E03- Forge JS 1/4 - La forge JavaScript
ENIB 2015 2016 - CAI Web S02E03- Forge JS 1/4 - La forge JavaScript
 
Fuzzing softwares for bugs - OWASP Seasides
Fuzzing softwares for bugs - OWASP SeasidesFuzzing softwares for bugs - OWASP Seasides
Fuzzing softwares for bugs - OWASP Seasides
 
Debugging Rails 3 Applications
Debugging Rails 3 ApplicationsDebugging Rails 3 Applications
Debugging Rails 3 Applications
 
Drupal and contribution (2010 - 2011 / 2)
Drupal and contribution (2010 - 2011 / 2)Drupal and contribution (2010 - 2011 / 2)
Drupal and contribution (2010 - 2011 / 2)
 
How to control physical devices with mruby
How to control physical devices with mrubyHow to control physical devices with mruby
How to control physical devices with mruby
 
Creating a Mature Puppet System
Creating a Mature Puppet SystemCreating a Mature Puppet System
Creating a Mature Puppet System
 
Creating a mature puppet system
Creating a mature puppet systemCreating a mature puppet system
Creating a mature puppet system
 
Xdebug for Beginners
Xdebug for BeginnersXdebug for Beginners
Xdebug for Beginners
 
Making CLIs with Node.js
Making CLIs with Node.jsMaking CLIs with Node.js
Making CLIs with Node.js
 

Dernier

Dernier (20)

Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
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
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
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
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 

Montreal.rb ruby debugging basics - march 20th 2012