principles in software debugging

Post on 22-May-2015

468 Views

Category:

Engineering

3 Downloads

Preview:

Click to see full reader

DESCRIPTION

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

TRANSCRIPT

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

+PipatMethavanitpong@fulcronz27

Be Scientific

Causes Effect

1. Reason an outcome

2. Make a hypothesis

3. Test the theory4. 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

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

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

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

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

• 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

Managing Bugs in a ProjectRemoving bugs is importantManaging 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 IDBug problem

Bug detail

Revision IDRevised codeRevision meta

e.g. fixed bug ID

Give a relationship between code and a bug

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

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

top related