13
Principles in Software Debugging Udacity CS259 Software Debugging class summary https:// www.udacity.com/course/cs259 +PipatMethavanitp ong @fulcronz2 7

Principles in software debugging

Embed Size (px)

DESCRIPTION

My summary from Udacity's software debugging class. Give a brief review of debugging approaches.

Citation preview

Page 1: Principles in software debugging

Principles in Software DebuggingUdacity CS259 Software Debugging class summaryhttps://www.udacity.com/course/cs259

+PipatMethavanitpong@fulcronz27

Page 2: Principles in software debugging

Be Scientific

Causes Effect

1. Reason an outcome

2. Make a hypothesis

3. Test the theory4. Repeat 1. if not

true

Page 3: Principles in software debugging

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

Page 4: Principles in software debugging

3 States of Error

Program State Timeline

Fail

Step on a defect code

Chain reaction

Some infections are handled

Fatal infection happens

More chain reaction

Page 5: Principles in software debugging

Chain Causes

Program State Timeline

Fail

Step on a defect code

Chain reaction

Some infections are handled

Fatal infection happens

More chain reaction

Then we can itch the right spots

Page 6: Principles in software debugging

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 statementS0 S1 S2 S3

Page 7: Principles in software debugging

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

Page 8: Principles in software debugging

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

• Compute phi value from the equation

• High value = More relevant

Fail Pass

Covered n11 n10

Row1 = n11+n10

Not cover

edn01 n00

Row2=n01+n00

Column 1= n11+n01

Column 2= n10+n00

Page 9: Principles in software debugging

Managing Bugs in a ProjectRemoving bugs is importantManaging removing bugs is also important

Page 10: Principles in software debugging

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

Page 11: Principles in software debugging

Defect Map

Bug Database

Version Database

Bug IDBug problem

Bug detail

Revision IDRevised codeRevision meta

e.g. fixed bug ID

Give a relationship between code and a bug

Page 12: Principles in software debugging

Defect Map (2)

Bug Database

Version Database

Bug IDBug problem

Bug detail

Revision IDRevised codeRevision meta

e.g. fixed bug ID

Components

Directories

Files

Get statistics of which are likely

problematic

Page 13: Principles in software debugging

This does not cover the whole storyIf you are interested, please make a visit to the course websitehttps://www.udacity.com/course/cs259

Have a good day