Intro to Debugging - raisercostin/software-wiki GitHub Wiki
-
Notions: binary search,
git bisect
-
The process is described tangentially here: http://raisercostin.org/2014/03/11/health-debugging-engineer-style
-
How debugging works
- We have a system that doesn't work properly.
- Doesn't work properly means that under testing(specific set of steps) the expected result is different than the actual result. Notice here the parts and read more about them at Testing, Test-Driven-Development, Intro to Quality
- steps
- expected result
- actual result
- Having a bug means that at least once at some moment in the execution flow an operation creates a bit in the wrong way: 0 when should be 1 or the other way.
- In practice most probably there are multiple bits that are created wrongly but we focus on finding any one of them (we will try to find first in the execution flow but we can't be sure). After we fix any of the bits we can move to second and so on. This means that any system with bugs can be reduced to a system with one bug + a system with the rest of the bugs.
- With this context debugging means: find the bit that is wrongly created and conclude that the piece of code that created/influenced it is the buggy one. The buggy piece of code is initially the whole system and via debugging you're getting closer and closer to the smallest piece of code that is buggy. In the end you should find the one line of code to be blamed (an operation code that should be other operation code).
- There are at least 3 types of going from buggy-system to buggy-line-of-code:
- Code Inspection - Traverse entire code base in a specific way:
- Change Review - start with latest changes - see and learn to use
git bisect
- Code Review - reviewing is rarely doing deep analysis. The deepest analysis is made when things are created/wrote not on read.
- Exhaustive Inspection Analysis
- Static Code Analysis - see tools for this but this is undirected bug hunting: the bugs might have a small impact
- Exhaustive Human Code Analysis - nobody is doing that except for rocket, aviation and nuclear industries
- Change Review - start with latest changes - see and learn to use
- Fast Debugging - This type of debugging is based on intuitions on what's most probable cause of the issue. See where is the bug?
- Methodical Debugging
- terms:
- synonyms: thorough, complete with regard to every detail; not superficial or partial, rigorous, in-depth, exhaustive, minute, detailed, close, meticulous, scrupulous, assiduous, conscientious, painstaking, methodical, careful, sedulous, complete, comprehensive, elaborate, full, intensive, extensive, widespread, sweeping, searching, all-embracing
- sinonime: aprofundat, temeinic, complet, detaliat, amănunţit, minuţios, profund, conştiincios, perfect, desăvârşit, total, scrupulos, absolut
- This method assumes knowing what binary search is. What we're doing is a binary search in the execution space (pre-order traversal of the execution tree where each node is a block of code that could execute other blocks) that is a specific technique based on the Divide and Conquer (Divide et Impera) general strategy.
- terms:
- Code Inspection - Traverse entire code base in a specific way: