Anda di halaman 1dari 30

Automated Fixing of Programs

with Contracts

MIDHUN
MOHAN
S7
ROLL NO
1

OUTLINE
Introduction
Background

Preliminaries

How Auto Fix Works


Experimental results.
Coclusion

INTRODUCTION
A programmer always faces two challenges

1.Finding faults
2.Correcting them

tool

What is
th
Autofix

faults
software

:Is a technique and supporting


that can generate correction for
faults of general purpose
completely automatically.

AUTOFIX IN ACTION..
A doubly-linked list implementing TWO_WAY_SORTED_SET

Some features of class TWO_WAY_SORTED_SET .

Continues

Correction of the error in move_item


automatically generated by AutoFix.

PRELIMINARIES
Contracts

How Auto Fix Works???

Auto Fix starts with a set of test cases that expose a specific fa

10

Candidate fixes...

11

Snap shots..
It consisting of a triple:

(l,p,v)
where l=program location
p=Boolean predicate
v=Boolean value
The snap shots come from two sources
Enumeration

12

Invariant Analysis
collection of predicates that all hold at l(location)

in every run of the tests.


For each location l reached by some test there are
-> passing invariant
->Failing invariant
Passing Invariant: ( l):Collection of predicates that hold

in all passing test.


Failing Invariant:( l): collection of predicates that hold in all
failing tests .

13

Enumeration
Only considering snapshots corresponding

to actual test executions avoids a blow-up


in the size of snap

The number of snapshots enumerated

for each fault ranged from about a dozen to


few hundreds

14

Fault Localization
The goal of the fault localization phase is to

determine which snapshots in snap(T) are reliable


characterizations of the reasons for the fault
under analysis

Static Analysis

The static analysis performed by


Auto Fix is based on simple measures of proximity
and similarity
Control dependence
Expression dependence

15

CONTROL
DEPENDENCE

Auto Fix uses control


dependence to
rank locations (in
snapshots) according to
proximity to the
location of failure.

16

EXPRESSION
DEPENDENCE

Auto Fix uses


expression
dependence to rank
expressions (in
snapshots) according
to similarity to the
contract clause
violated in a failure

Dynamic
Analysis

It is used to determine
which locations are likely to host the cause

of failure.
Dynamic score dyn (l,p,v) measure how often it appears in failing runs
as opposed to passing runs.
Principle for computing the dynamic score:

li
(l,p,v) t if li loc (t), l=li and v=[p]
t
For every test t, there is (t) describes ts contribution to the
dynamic score(l,p,v).
Large (t) implies (l,p,v) is a source of error if t is a failing test

cases.

17

meets the following requirements

If there is at least one


failing test case,
the overall score
assigned to(l,p,v)must
be positive

18

The magnitude of each


failing test cases
contribution (t) to the
dynamic score assigned
to(l,p,v)decreases as
more failing test cases
for that snap shots are
available

The evidence
provided by one
failing test case
alone is stronger
than the evidence
provided by one
passing test case

Overall score
AutoFix combines the

various metrics(static
and dynamic) into an
overall score
susp(l,p,v)

19

Fix Action Synthesis


AutoFix tries to build fixing actions (snippets of

instructions) that modify the value of p at l so that


the execution can hopefully continue without
triggering the fault.
Find an action snip that satisfies the specification
require p = v do snip ensure p v end
Auto fix uses 2 strategies for generating fixing
actions
Setting: Modifying the value of variables or
objects through assignments or routine calls
Replacement: Modifying the value of expression
directly where they are used in the program
20

Behavioral Models
;l

try to modify the program state by calling routines on the current or other objects .

21

Candidate Fix Generation


For a given snap shot (l,p,v), Injecting any fix

actions at location gives a modified program that


is a candidate fix
We inject fix actions in two phases
Fix schema:A template that abstracts common
instruction patterns

Schema Instantiation:we instantiate the fix


schema with the snapshots predicate p and some
fixing action it induces

22

Fix validation

23

Fix Ranking
The AutoFix algorithm often finds several valid

fixes for a given fault.

It is programmers responsibility to select which

one to deploy

AutoFix ranks the valid fixes according to the

suspiciousness score susp(l,p,v) of the snapshot


(l,p,v) that determined each fix.

24

Experimental Evaluation
It addresses the following questions

25

Experimental setup
Experimental subjects:

The experiments targeted 4 code bases


Base: Is a data structure.
TxtLib: Is a library to manipulate text
documents
Cards:Is an on-line card gaming system
E-Learn: Is an application supporting elearning.

26

#c:no of classes,#kLOC:thousands of lines codes,#R:no of


routines,,#Q:boolean queries,#pre:no of cotract clause in pre
conditions,#post:post conditions and class invariants(#inv)

27

Experimental results

Auto Fix produced

valid fixes for


86(42%) of 204
faults

28

Other results..

Auto fix produced valid fixes in4

29

conclusion
Auto fix is an important contribution towards the

ideal of automatic debugging


AutoFix generated fixes for 42 percent of the
faults.
running on standard hardware, it required an
average time per fix under 20 minutes
Contracts plays an immediate role.
With AutoFix, the programmers debugging effort
could be reduced to almost zero in many cases

30

Anda mungkin juga menyukai