Slide 1

Slide 1 text

- Kunal Kushwaha

Slide 2

Slide 2 text

 Debugging is a methodical process of finding and reducing the number of bugs, or defects, in a computer program or a piece of electronic hardware, thus making it behave as expected

Slide 3

Slide 3 text

 Writing new code / functions  Modifying existing code.  What we do in our code? ◦ Essentially it will do following  Some mathematical calculation based on data we have.  Data manipulation/ memory manipulation.  On Stack  On Heap.  Conditions  Execution path

Slide 4

Slide 4 text

 Calculation logic in code is as per desired logic. ◦ Output of such logic must me tested w.r.t. all possible conditions (best case, worst cases and boundary cases)  Data Manipulation ◦ On Stack  Correct usage of stack  Conditions of stack overflow.  Passing address of stack allocated memory to such function, which are out of scope of functions stack.

Slide 5

Slide 5 text

◦ On Heap.  Free all allocated memory.  Memory under-run/over-run issues.  Uninitialized memory access/manipulation.  Execution paths ◦ A function can have various execution paths depending on if-else, switch, goto usage in code. ◦ All execution paths must be executed at-least once with all possible conditions. ◦ Terminating condition for loops.

Slide 6

Slide 6 text

 Methods to catch the bug at earliest. ◦ Usage of prints ◦ Usage of Asserts – defensing programming.  Methods to debug newly added function(s). ◦ In, Out parameters and return values. ◦ ASSERT for mandatory parameters for expected value or range. (used for debug version only) ◦ Handle the graceful exit from function with proper error return value (wherever applicable) ◦ Defined return path and value.

Slide 7

Slide 7 text

◦ Can test computation's in code with helps of prints. ◦ If coping data to some memory location, check for size of copy and start address of storage. ( Buffer over-run / under-run conditions). ◦ Global structure management - use of reference count. ◦ Memory corruptions  Padding – add some signature at start and end of memory allocated while allocation, and check while freeing it.

Slide 8

Slide 8 text

 Functions / Macros ◦ Test for best case, worst case and boundary cases. ◦ Invoke functions/Macros from test code and verify if it works as expected in all scenarios.  Modification in current code. ◦ Verify for all modifications, if they are not breaking or introducing new bug to existing function.

Slide 9

Slide 9 text

No content