SlideShare a Scribd company logo
2
Most read
19
Most read
21
Most read
Debugging
Finding and solving
problems in software
What is debugging?
"Bug" and "debugging" are attributed to the
discovery of a moth found in a Mark II computer at
Harvard University.
Debugging is not troubleshooting
Debugging Rules...
1. Understand the system
2. Make it fail
3. Quit thinking and look
4. Divide and Conquer
5. Change one thing at a time
6. Keep an audit trail
7. Check the plug
8. Get a fresh view
9. If you didn't fix it, it aint fixed
Debugging - A Simple Method
a) Start
|
b) Construct a Hypothesis
|
c) Construct an Experiment
|
d) Hypothesis Proved? - goto b)
|
Need more evidence? - goto c)
|
Stop
1. Understanding the System
Know the fundamentals of the system
Understand the frameworks involved
Read the API's and communication interfaces
Know your tools
Understand what each module of the system does
2. Make it Fail
Start at the beginning
Automate the failure
No detail is insignificant
Intermittent failures?
Isolate the failure
Build debugging tools and test harnesses
3. Quit thinking and look
Gather the low level details and "see" the failure
Understand the context of the bug
Design instrumentation in:
●Runtime statistics
●Status messages
●Debug logging - be descriptive!!!
●Deployment time environment checks
Hypothesise and test
4. Divide and Conquer
Narrow the search down, software AND
hardware. Successive approximation.
Start at the bad end (e.g. the error log) and work
your way up the chain looking at the various
points on the way
Fix the bugs you know about - fixing one could
fix the other
Fix the noise first, but don't go nuts
5. Change one thing at a time
Compare with a good one !
Use a rifle not a shotgun
What's changed recently, it used to work!
Separate environment and product
6. Keep an audit trail
Keep a day book of what you did
During debugging write down...
1.What you did...
2.In what order...
3.And what happened!
Be specific and consistent
Correlate symptoms with others
Version control and change logs are great for
determining an audit trail of what's changed
7. Check the plug
Question your assumptions
8. Get a Fresh View
Get another viewpoint on the solution
Talk to somebody about the problem
Ask an expert:
●Email the author
●Check the forums
●Subscribe to the mailing list
Make sure you report symptoms not theories
9. If you didn't fix it, it aint fixed!
The most important lesson by far...
●Fix the root cause
●Make sure it can't possibly happen again
●Fix the process at fault
"We didn't see an issue until we deployed into the production
environment"
= Deploy early and deploy often
Debugging Methods and Tools
Debugging Methods
Print/Trace Debugging - watching the flow of execution after
adding print statements to the original code
Remote Debugging - connect to a remote system with a
debugger, monitor the execution and state
Post Mortem Debugging - analysis of a memory dump from a
program that has crashed
Profiling - not debugging per se, but a useful technique for
analysing a running program to look for issues
Lesser Known (?) Debugging Methods
Rubber Ducking - explaining your problem to someone
else. Stating the problem aloud in order to work it out.
Failfirst - Write a unit test that exposes the failure, correct the
code and make it pass
Saff Squeeze - Write a system test, inline code, write test, repeat
until fixed
http://www.threeriversinstitute.org/HitEmHighHitEmLow.html
Chaos Monkey - AWS Netflix approach - randomly kill and test
areas. Fail consistently to test fault tolerant software.
http://www.codinghorror.com/blog/2011/04/working-with-the-chaos-monkey.html
Eclipse Debugging 1
Set breakpoints in the code
Step into, over, return
Watches - display a variable value
Hit counts
Setting an exception breakpoint
Setting a method breakpoint
Eclipse Debugging 2
Class load breakpoint
Using display after a breakpoint has been hit
Attaching a remote debugger via a JDB agent
Bug Taxonomies and Bug Types
There are ways to categorise bugs... lots of
taxonomies available from research literature
Some bug types include:
●Bohrbug - bug that manifests itself consistently
under a set of conditions
●Heisenbug - bug that alters its' characteristics
when studied
Preventing Bugs
Debugging is hard and expensive in terms of fixing
the bug, testing it and re-deploying it...
We can try and prevent bugs with:
●Code Review
●Defensive Programming
●Precondition, postcondition and invariant checking
●Assertions
Further Resources
●Debugging - The 9 Indispensable Rules for Finding
Even The Most Elusive Software and Hardware
Problems - David Agans
●Debug It! : Find, Repair and Prevent Bugs in Your
Code (Pragmatic Programmers) - Paul Butcher
●Testing Education -
http://www.testingeducation.org/a/bugtax.pdf
●Lars Vogels Debugging Overview (2011) -
http://www.vogella.de/articles/EclipseDebugging/artic

More Related Content

PDF
MuleSoft Event Driven Architecture (EDA Patterns in MuleSoft) - VirtualMuleys63
PDF
Git 101: Git and GitHub for Beginners
PPTX
Relational databases vs Non-relational databases
PDF
Smart energy meter ppt
PDF
Web development ppt
PDF
Aml & kyc
PPTX
Video compression
PDF
Frequency-Shift Keying
MuleSoft Event Driven Architecture (EDA Patterns in MuleSoft) - VirtualMuleys63
Git 101: Git and GitHub for Beginners
Relational databases vs Non-relational databases
Smart energy meter ppt
Web development ppt
Aml & kyc
Video compression
Frequency-Shift Keying

What's hot (20)

PPT
PPT
Debugging
PPTX
Basics of JAVA programming
ODP
The Art Of Debugging
PPTX
Master page in Asp.net
PPTX
Exception Handling in Java
PPTX
Input Validation
PDF
Java I/o streams
PPTX
Web Engineering - Web Application Testing
PPTX
graphics programming in java
PDF
Action Bar in Android
PPTX
Buffer overflow attacks
DOCX
Evolving role of Software,Legacy software,CASE tools,Process Models,CMMI
PPTX
Java swing
PPTX
Need of object oriented programming
PPTX
Garbage collection algorithms
PPT
Java layoutmanager
PPTX
Bug tracking system ppt
PPTX
Introduction to Software Engineering
PPTX
Notification android
Debugging
Basics of JAVA programming
The Art Of Debugging
Master page in Asp.net
Exception Handling in Java
Input Validation
Java I/o streams
Web Engineering - Web Application Testing
graphics programming in java
Action Bar in Android
Buffer overflow attacks
Evolving role of Software,Legacy software,CASE tools,Process Models,CMMI
Java swing
Need of object oriented programming
Garbage collection algorithms
Java layoutmanager
Bug tracking system ppt
Introduction to Software Engineering
Notification android
Ad

Similar to Debugging (20)

PPTX
Testing & should i do it
PDF
5-Ways-to-Revolutionize-Your-Software-Testing
PPTX
Cinci ug-january2011-anti-patterns
PPTX
QA Best Practices
PPTX
assertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
PPTX
Debugging
PPT
An important characteristic of a test suite that is computed by a dynamic ana...
PPT
debugging (1).ppt
PPTX
Debugging with visual studio beyond 'F5'
PPT
Assessing Unit Test Quality
PPTX
Preocupações Desenvolvedor Ágil
PDF
Test Drive Development
DOCX
Code review guidelines
PDF
Debugging in Software Engineering SE Unit-4 Part-6.pdf
PPT
PHP - Introduction to PHP Bugs - Debugging
PPTX
6 easy bug tracking tips & tricks every developer should know!
PPTX
Stop fearing legacy code
PDF
Become a Better Developer with Debugging Techniques for Drupal (and more!)
PPS
Why Unit Testingl
PPS
Why Unit Testingl
Testing & should i do it
5-Ways-to-Revolutionize-Your-Software-Testing
Cinci ug-january2011-anti-patterns
QA Best Practices
assertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
Debugging
An important characteristic of a test suite that is computed by a dynamic ana...
debugging (1).ppt
Debugging with visual studio beyond 'F5'
Assessing Unit Test Quality
Preocupações Desenvolvedor Ágil
Test Drive Development
Code review guidelines
Debugging in Software Engineering SE Unit-4 Part-6.pdf
PHP - Introduction to PHP Bugs - Debugging
6 easy bug tracking tips & tricks every developer should know!
Stop fearing legacy code
Become a Better Developer with Debugging Techniques for Drupal (and more!)
Why Unit Testingl
Why Unit Testingl
Ad

More from Jonathan Holloway (11)

PPTX
The Role of the Architect
PPTX
Spring boot - an introduction
PPTX
Jenkins CI presentation
PPTX
Mockito intro
PPTX
SOLID principles
PPTX
Application design for the cloud using AWS
PPTX
Building data pipelines
PPTX
Introduction to JVM languages and Fantom (very brief)
PDF
Database migration with flyway
PDF
Lightweight web frameworks
PDF
Introduction to using MongoDB with Ruby
The Role of the Architect
Spring boot - an introduction
Jenkins CI presentation
Mockito intro
SOLID principles
Application design for the cloud using AWS
Building data pipelines
Introduction to JVM languages and Fantom (very brief)
Database migration with flyway
Lightweight web frameworks
Introduction to using MongoDB with Ruby

Recently uploaded (20)

PDF
KodekX | Application Modernization Development
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Approach and Philosophy of On baking technology
PDF
Empathic Computing: Creating Shared Understanding
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
NewMind AI Monthly Chronicles - July 2025
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
cuic standard and advanced reporting.pdf
PDF
Modernizing your data center with Dell and AMD
PDF
Unlocking AI with Model Context Protocol (MCP)
KodekX | Application Modernization Development
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Reach Out and Touch Someone: Haptics and Empathic Computing
Approach and Philosophy of On baking technology
Empathic Computing: Creating Shared Understanding
The AUB Centre for AI in Media Proposal.docx
NewMind AI Monthly Chronicles - July 2025
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Digital-Transformation-Roadmap-for-Companies.pptx
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
Chapter 3 Spatial Domain Image Processing.pdf
Diabetes mellitus diagnosis method based random forest with bat algorithm
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
20250228 LYD VKU AI Blended-Learning.pptx
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
cuic standard and advanced reporting.pdf
Modernizing your data center with Dell and AMD
Unlocking AI with Model Context Protocol (MCP)

Debugging

  • 2. What is debugging? "Bug" and "debugging" are attributed to the discovery of a moth found in a Mark II computer at Harvard University. Debugging is not troubleshooting
  • 3. Debugging Rules... 1. Understand the system 2. Make it fail 3. Quit thinking and look 4. Divide and Conquer 5. Change one thing at a time 6. Keep an audit trail 7. Check the plug 8. Get a fresh view 9. If you didn't fix it, it aint fixed
  • 4. Debugging - A Simple Method a) Start | b) Construct a Hypothesis | c) Construct an Experiment | d) Hypothesis Proved? - goto b) | Need more evidence? - goto c) | Stop
  • 5. 1. Understanding the System Know the fundamentals of the system Understand the frameworks involved Read the API's and communication interfaces Know your tools Understand what each module of the system does
  • 6. 2. Make it Fail Start at the beginning Automate the failure No detail is insignificant Intermittent failures? Isolate the failure Build debugging tools and test harnesses
  • 7. 3. Quit thinking and look Gather the low level details and "see" the failure Understand the context of the bug Design instrumentation in: ●Runtime statistics ●Status messages ●Debug logging - be descriptive!!! ●Deployment time environment checks Hypothesise and test
  • 8. 4. Divide and Conquer Narrow the search down, software AND hardware. Successive approximation. Start at the bad end (e.g. the error log) and work your way up the chain looking at the various points on the way Fix the bugs you know about - fixing one could fix the other Fix the noise first, but don't go nuts
  • 9. 5. Change one thing at a time Compare with a good one ! Use a rifle not a shotgun What's changed recently, it used to work! Separate environment and product
  • 10. 6. Keep an audit trail Keep a day book of what you did During debugging write down... 1.What you did... 2.In what order... 3.And what happened! Be specific and consistent Correlate symptoms with others Version control and change logs are great for determining an audit trail of what's changed
  • 11. 7. Check the plug Question your assumptions
  • 12. 8. Get a Fresh View Get another viewpoint on the solution Talk to somebody about the problem Ask an expert: ●Email the author ●Check the forums ●Subscribe to the mailing list Make sure you report symptoms not theories
  • 13. 9. If you didn't fix it, it aint fixed! The most important lesson by far... ●Fix the root cause ●Make sure it can't possibly happen again ●Fix the process at fault "We didn't see an issue until we deployed into the production environment" = Deploy early and deploy often
  • 15. Debugging Methods Print/Trace Debugging - watching the flow of execution after adding print statements to the original code Remote Debugging - connect to a remote system with a debugger, monitor the execution and state Post Mortem Debugging - analysis of a memory dump from a program that has crashed Profiling - not debugging per se, but a useful technique for analysing a running program to look for issues
  • 16. Lesser Known (?) Debugging Methods Rubber Ducking - explaining your problem to someone else. Stating the problem aloud in order to work it out. Failfirst - Write a unit test that exposes the failure, correct the code and make it pass Saff Squeeze - Write a system test, inline code, write test, repeat until fixed http://www.threeriversinstitute.org/HitEmHighHitEmLow.html Chaos Monkey - AWS Netflix approach - randomly kill and test areas. Fail consistently to test fault tolerant software. http://www.codinghorror.com/blog/2011/04/working-with-the-chaos-monkey.html
  • 17. Eclipse Debugging 1 Set breakpoints in the code Step into, over, return Watches - display a variable value Hit counts Setting an exception breakpoint Setting a method breakpoint
  • 18. Eclipse Debugging 2 Class load breakpoint Using display after a breakpoint has been hit Attaching a remote debugger via a JDB agent
  • 19. Bug Taxonomies and Bug Types There are ways to categorise bugs... lots of taxonomies available from research literature Some bug types include: ●Bohrbug - bug that manifests itself consistently under a set of conditions ●Heisenbug - bug that alters its' characteristics when studied
  • 20. Preventing Bugs Debugging is hard and expensive in terms of fixing the bug, testing it and re-deploying it... We can try and prevent bugs with: ●Code Review ●Defensive Programming ●Precondition, postcondition and invariant checking ●Assertions
  • 21. Further Resources ●Debugging - The 9 Indispensable Rules for Finding Even The Most Elusive Software and Hardware Problems - David Agans ●Debug It! : Find, Repair and Prevent Bugs in Your Code (Pragmatic Programmers) - Paul Butcher ●Testing Education - http://www.testingeducation.org/a/bugtax.pdf ●Lars Vogels Debugging Overview (2011) - http://www.vogella.de/articles/EclipseDebugging/artic