KEMBAR78
Principles in software debugging | PPTX
Principles in 
Software Debugging 
Udacity CS259 Software Debugging class summary 
https://www.udacity.com/course/cs259 
+PipatMethavanitpong 
@fulcronz27
Be Scientific 
Causes Effect 
1. Reason an outcome 
2. Make a hypothesis 
3. Test the theory 
4. Repeat 1. if not true
3 States of Error 
Defect 
Error in code 
•Sloppy writing 
•Corner cases 
Infection 
Error in program 
states 
•Step upon defect code 
•Carry undesired states 
Failure 
Error in execution 
•Infections become 
severe 
•Cannot maintain 
functioning
Program State Timeline 
Fail 
3 States of Error 
Step on a defect code 
Chain reaction 
Some infections are handled 
More chain reaction 
Fatal infection happens
Program State Timeline 
Fail 
Chain Causes 
Step on a defect code 
Chain reaction 
Some infections are handled 
More chain reaction 
Fatal infection happens 
Then we can itch the right spots 

Chain Causes 
• Information can come in bulk 
• Core dump after crashed 
• Crash report submissions by users 
• Execution log 
• Not all information is relevant to error 
• Spend more time 
• Don’t know what to look for 
• Looking for dependencies 
• Control dependency – A statement that depends on a decision 
• If-else / Switch / For-loop / etc. 
• Data dependency – A statement that depends on data 
• Conditional Expression 
• Chain these dependencies together 
• Backward slice – All statements that influence a statement 
• Forward slice – All statements that depend on a statement 
S0 S1 S2 S3
Debugging Techniques 
• Assertion 
• An if-else like statement e.g. assert x == 9 
• Use to confirm a state / Narrow down possiblities 
• Included in debug mode 
• May be removed in build mode 
• Code Coverage 
• Record which lines are executed 
• Tracing 
• Record how a program runs 
• Granularity of what are recorded depends on implementation 
• Python has these trace events fired: “call”, “return”, “line”, etc. 
• https://docs.python.org/2.7/library/sys.html?highlight=settrace#sys.settrace
Picking the Relevance 
• Delta Debugging 
• Given a set of variables’ value, a program fails 
• All variables may not involve with the failure 
• Find the smallest subset that can fail the 
program 
• To use these values 
• Initial values 
• Injected in an interested program state 
• Phi Scoring 
• Pair code coverage and program’s outcomes (pass or fail) 
• Obtain statistics of 4 values : n11, n10, n01, n00 
Fail Pass 
Covered n11 n10 
• Compute phi value from the equation 
푛11∙푛00−푛01∙푛10 
푅표푤1∙푅표푤2∙퐶표푙푢푚푛1∙퐶표푙푢푚푛2 
• High value = More relevant 
Row1 
= n11+n10 
Not 
covered 
n01 n00 
Row2 
=n01+n00 
Column 1 
= n11+n01 
Column 2 
= n10+n00
Managing Bugs in a Project 
Removing bugs is important 
Managing removing bugs is also important
Problem Life Cycle 
Unconfirmed 
•A bug report is 
submitted 
New 
•The bug is 
confirmed as 
new by a 
committee 
Assigned 
•Responsible 
developers are 
assigned to fix 
Resolved 
•The developers 
say the bug is 
fixed 
Verified 
•The committee 
confirms the 
fix 
Closed 
•The bug is 
officially dead 
• Record a bug state properly 
• Fix in timely manner 
• Skill matching
Defect Map 
Bug 
Database 
Version 
Database 
Bug ID 
Bug problem 
Bug detail 
Revision ID 
Revised code 
Revision meta 
e.g. fixed bug ID 
Give a 
relationship 
between code 
and a bug
Defect Map (2) 
Bug 
Database 
Version 
Database 
Bug ID 
Bug problem 
Bug detail 
Revision ID 
Revised code 
Revision meta 
e.g. fixed bug ID 
Components 
Directories 
Files 
Get statistics of 
which are likely 
problematic
This does not cover 
the whole story 
If you are interested, please make a visit to the course website 
https://www.udacity.com/course/cs259 
Have a good day

Principles in software debugging

  • 1.
    Principles in SoftwareDebugging Udacity CS259 Software Debugging class summary https://www.udacity.com/course/cs259 +PipatMethavanitpong @fulcronz27
  • 2.
    Be Scientific CausesEffect 1. Reason an outcome 2. Make a hypothesis 3. Test the theory 4. Repeat 1. if not true
  • 3.
    3 States ofError Defect Error in code •Sloppy writing •Corner cases Infection Error in program states •Step upon defect code •Carry undesired states Failure Error in execution •Infections become severe •Cannot maintain functioning
  • 4.
    Program State Timeline Fail 3 States of Error Step on a defect code Chain reaction Some infections are handled More chain reaction Fatal infection happens
  • 5.
    Program State Timeline Fail Chain Causes Step on a defect code Chain reaction Some infections are handled More chain reaction Fatal infection happens Then we can itch the right spots 
  • 6.
    Chain Causes •Information can come in bulk • Core dump after crashed • Crash report submissions by users • Execution log • Not all information is relevant to error • Spend more time • Don’t know what to look for • Looking for dependencies • Control dependency – A statement that depends on a decision • If-else / Switch / For-loop / etc. • Data dependency – A statement that depends on data • Conditional Expression • Chain these dependencies together • Backward slice – All statements that influence a statement • Forward slice – All statements that depend on a statement S0 S1 S2 S3
  • 7.
    Debugging Techniques •Assertion • An if-else like statement e.g. assert x == 9 • Use to confirm a state / Narrow down possiblities • Included in debug mode • May be removed in build mode • Code Coverage • Record which lines are executed • Tracing • Record how a program runs • Granularity of what are recorded depends on implementation • Python has these trace events fired: “call”, “return”, “line”, etc. • https://docs.python.org/2.7/library/sys.html?highlight=settrace#sys.settrace
  • 8.
    Picking the Relevance • Delta Debugging • Given a set of variables’ value, a program fails • All variables may not involve with the failure • Find the smallest subset that can fail the program • To use these values • Initial values • Injected in an interested program state • Phi Scoring • Pair code coverage and program’s outcomes (pass or fail) • Obtain statistics of 4 values : n11, n10, n01, n00 Fail Pass Covered n11 n10 • Compute phi value from the equation 푛11∙푛00−푛01∙푛10 푅표푤1∙푅표푤2∙퐶표푙푢푚푛1∙퐶표푙푢푚푛2 • High value = More relevant Row1 = n11+n10 Not covered n01 n00 Row2 =n01+n00 Column 1 = n11+n01 Column 2 = n10+n00
  • 9.
    Managing Bugs ina Project Removing bugs is important Managing removing bugs is also important
  • 10.
    Problem Life Cycle Unconfirmed •A bug report is submitted New •The bug is confirmed as new by a committee Assigned •Responsible developers are assigned to fix Resolved •The developers say the bug is fixed Verified •The committee confirms the fix Closed •The bug is officially dead • Record a bug state properly • Fix in timely manner • Skill matching
  • 11.
    Defect Map Bug Database Version Database Bug ID Bug problem Bug detail Revision ID Revised code Revision meta e.g. fixed bug ID Give a relationship between code and a bug
  • 12.
    Defect Map (2) Bug Database Version Database Bug ID Bug problem Bug detail Revision ID Revised code Revision meta e.g. fixed bug ID Components Directories Files Get statistics of which are likely problematic
  • 13.
    This does notcover the whole story If you are interested, please make a visit to the course website https://www.udacity.com/course/cs259 Have a good day